diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-21 18:19:09 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-23 11:30:01 +0200 |
commit | 9b576c2c1c36003e0ca0a760c36aae028991400f (patch) | |
tree | b5192d5492616582de12dd67a6edad69fe5121d1 /src/dotty/tools/dotc/typer/Applications.scala | |
parent | 8bd14310f60c1be997a62eaba84dd49624ea2df6 (diff) | |
download | dotty-9b576c2c1c36003e0ca0a760c36aae028991400f.tar.gz dotty-9b576c2c1c36003e0ca0a760c36aae028991400f.tar.bz2 dotty-9b576c2c1c36003e0ca0a760c36aae028991400f.zip |
Fix problem in unapply typing.
GADT bound resetting may only be applied when comparing
<pattern type> <: <expected type>, not when comparing the
other way around.
The fix revealed an error in a test case (t1048) which looks like a real error.
Therefore the test got moved to neg.
Conflicts:
src/dotty/tools/dotc/typer/Applications.scala
test/dotc/tests.scala
tests/disabled/t1048.scala
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index b2572dcda..2ff116f46 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -653,7 +653,7 @@ trait Applications extends Compatibility { self: Typer => /** Can `subtp` be made to be a subtype of `tp`, possibly by dropping some * refinements in `tp`? */ - def isSubTypeOfParent(subtp: Type, tp: Type): Boolean = + def isSubTypeOfParent(subtp: Type, tp: Type)(implicit ctx: Context): Boolean = if (subtp <:< tp) true else tp match { case RefinedType(parent, _) => isSubTypeOfParent(subtp, parent) @@ -671,7 +671,7 @@ trait Applications extends Compatibility { self: Typer => //fullyDefinedType(unapplyArgType, "extractor argument", tree.pos) unapp.println(i"case 1 $unapplyArgType ${ctx.typerState.constraint}") selType - } else if (isSubTypeOfParent(unapplyArgType, wpt)) { + } else if (isSubTypeOfParent(unapplyArgType, wpt)(ctx.addMode(Mode.GADTflexible))) { maximizeType(unapplyArgType) match { case Some(tvar) => def msg = @@ -703,7 +703,7 @@ trait Applications extends Compatibility { self: Typer => tree.pos) } - val dummyArg = dummyTreeOfType(ownType) + val dummyArg = dummyTreeOfType(unapplyArgType) val unapplyApp = typedExpr(untpd.TypedSplice(Apply(unapplyFn, dummyArg :: Nil))) val unapplyImplicits = unapplyApp match { case Apply(Apply(unapply, `dummyArg` :: Nil), args2) => assert(args2.nonEmpty); args2 |