diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-26 16:57:38 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:04 +0200 |
commit | 8805dd4f821e06a688fcf492b61033fe0992e752 (patch) | |
tree | 47da644d5eba1c2c536183ef1e396d2333af59c6 /src/dotty/tools/dotc/core/ConstraintHandling.scala | |
parent | de5d8fe696cdf7acfa80991ceae322aedb1dfd20 (diff) | |
download | dotty-8805dd4f821e06a688fcf492b61033fe0992e752.tar.gz dotty-8805dd4f821e06a688fcf492b61033fe0992e752.tar.bz2 dotty-8805dd4f821e06a688fcf492b61033fe0992e752.zip |
When comparing types revert eta-expansion as needed
The problem is that some existential types read from Java (and Scala
as well? not sure) appear as naked typerefs. They consequently get
expanded via eta expansion to type lambdas. This commit compensates for
this by collapsing an eta expansion if this can make a subtype tests succeed
or a union or intersection be legal.
Also, take hk types into account for liftToClasses
Needs to special-treat TypeLambda and HKApply since otherwise
we risk creating malformed And-types.
Diffstat (limited to 'src/dotty/tools/dotc/core/ConstraintHandling.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/ConstraintHandling.scala | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/ConstraintHandling.scala b/src/dotty/tools/dotc/core/ConstraintHandling.scala index 66767d58a..44b6abe12 100644 --- a/src/dotty/tools/dotc/core/ConstraintHandling.scala +++ b/src/dotty/tools/dotc/core/ConstraintHandling.scala @@ -6,6 +6,7 @@ import Types._, Contexts._, Symbols._ import Decorators._ import config.Config import config.Printers._ +import TypeApplications.EtaExpansion import collection.mutable /** Methods for adding constraints and solving them. @@ -239,8 +240,6 @@ trait ConstraintHandling { def addParamBound(bound: PolyParam) = if (fromBelow) addLess(bound, param) else addLess(param, bound) - assert(param.isHK == bound.isHK, s"$param / $bound / $fromBelow") - /** Drop all constrained parameters that occur at the toplevel in `bound` and * handle them by `addLess` calls. * The preconditions make sure that such parameters occur only @@ -297,7 +296,13 @@ trait ConstraintHandling { case bound: PolyParam if constraint contains bound => addParamBound(bound) case _ => - val pbound = prune(bound) + var pbound = prune(bound) + if (pbound.isHK && !param.isHK) { + param match { + case EtaExpansion(tycon) if tycon.symbol.isClass => pbound = tycon + case _ => + } + } pbound.exists && ( if (fromBelow) addLowerBound(param, pbound) else addUpperBound(param, pbound)) } |