diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-01 21:35:58 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-10-11 19:21:02 +0200 |
commit | 98a69d90b16f0cc997255f097d3d5d9f2a60301b (patch) | |
tree | c3640fb82f53f4f6e250de59d3536f638b63f1aa /src/dotty/tools/dotc/core/ConstraintHandling.scala | |
parent | f6291e42082708e164ebc3456d84e69f4f29cf59 (diff) | |
download | dotty-98a69d90b16f0cc997255f097d3d5d9f2a60301b.tar.gz dotty-98a69d90b16f0cc997255f097d3d5d9f2a60301b.tar.bz2 dotty-98a69d90b16f0cc997255f097d3d5d9f2a60301b.zip |
Keep or types
Don't replace them by their dominators, unless one of the following holds:
- language:Scala2 mode is on
- we are at the point of findMember selection
- we compare with a higher-kinded application
This means approximateUnion is now split into harmonizeUnion and
orDominator which each implement one of the former's two functionalities.
Diffstat (limited to 'src/dotty/tools/dotc/core/ConstraintHandling.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/ConstraintHandling.scala | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/ConstraintHandling.scala b/src/dotty/tools/dotc/core/ConstraintHandling.scala index 5911af72c..84f531385 100644 --- a/src/dotty/tools/dotc/core/ConstraintHandling.scala +++ b/src/dotty/tools/dotc/core/ConstraintHandling.scala @@ -35,6 +35,15 @@ trait ConstraintHandling { /** If the constraint is frozen we cannot add new bounds to the constraint. */ protected var frozenConstraint = false + protected var alwaysFluid = false + + /** Perform `op` in a mode where all attempts to set `frozen` to true are ignored */ + def fluidly[T](op: => T): T = { + val saved = alwaysFluid + alwaysFluid = true + try op finally alwaysFluid = saved + } + /** We are currently comparing lambdas. Used as a flag for * optimization: when `false`, no need to do an expensive `pruneLambdaParams` */ @@ -126,14 +135,14 @@ trait ConstraintHandling { final def isSubTypeWhenFrozen(tp1: Type, tp2: Type): Boolean = { val saved = frozenConstraint - frozenConstraint = true + frozenConstraint = !alwaysFluid try isSubType(tp1, tp2) finally frozenConstraint = saved } final def isSameTypeWhenFrozen(tp1: Type, tp2: Type): Boolean = { val saved = frozenConstraint - frozenConstraint = true + frozenConstraint = !alwaysFluid try isSameType(tp1, tp2) finally frozenConstraint = saved } @@ -219,7 +228,7 @@ trait ConstraintHandling { // is not a union type, approximate the union type from above by an intersection // of all common base types. if (fromBelow && isOrType(inst) && isFullyDefined(inst) && !isOrType(upperBound)) - inst = inst.approximateUnion + inst = ctx.harmonizeUnion(inst) // 3. If instance is from below, and upper bound has open named parameters // make sure the instance has all named parameters of the bound. |