Skip to content

Commit

Permalink
Treat variances in type accumulators and type maps the same
Browse files Browse the repository at this point in the history
Bonus point: No need to override applyPrefix in variances
accumulator. This means we have reduced three different ways
to compute the current variance to one.
  • Loading branch information
odersky committed Jul 31, 2017
1 parent 805fdd4 commit 60c7cac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3924,9 +3924,9 @@ object Types {

protected var variance = 1

protected def applyToPrefix(x: T, tp: NamedType) = {
protected final def applyToPrefix(x: T, tp: NamedType) = {
val saved = variance
variance = 0
variance = variance max 0 // see remark on NamedType case in TypeMap
val result = this(x, tp.prefix)
variance = saved
result
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ object Inferencing {
case _ =>
foldOver(vmap, t)
}
override def applyToPrefix(vmap: VarianceMap, t: NamedType) =
apply(vmap, t.prefix)
}

/** Include in `vmap` type variables occurring in the constraints of type variables
Expand Down

0 comments on commit 60c7cac

Please sign in to comment.