aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-21 18:19:09 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-23 11:30:01 +0200
commit9b576c2c1c36003e0ca0a760c36aae028991400f (patch)
treeb5192d5492616582de12dd67a6edad69fe5121d1 /src/dotty/tools/dotc/core/TypeComparer.scala
parent8bd14310f60c1be997a62eaba84dd49624ea2df6 (diff)
downloaddotty-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/core/TypeComparer.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index eb57119ff..805941c5d 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -364,7 +364,7 @@ class TypeComparer(initctx: Context) extends DotClass {
private def traceInfo(tp1: Type, tp2: Type) =
s"${tp1.show} <:< ${tp2.show}" +
- (if (ctx.settings.verbose.value) s"${tp1.getClass} ${tp2.getClass}" else "")
+ (if (ctx.settings.verbose.value) s" ${tp1.getClass} ${tp2.getClass}${if (frozenConstraint) " frozen" else ""}" else "")
def isSubType(tp1: Type, tp2: Type): Boolean = /*>|>*/ ctx.traceIndented(s"isSubType ${traceInfo(tp1, tp2)}", subtyping) /*<|<*/ {
if (tp2 eq NoType) false
@@ -592,7 +592,8 @@ class TypeComparer(initctx: Context) extends DotClass {
NamedType(tp1.prefix, tp1.name, sd.derivedSingleDenotation(sd.symbol, tp))
secondTry(OrType.make(derivedRef(tp11), derivedRef(tp12)), tp2)
case TypeBounds(lo1, hi1) =>
- if ((tp1.symbol is GADTFlexType) && !isSubTypeWhenFrozen(hi1, tp2))
+ if ((ctx.mode is Mode.GADTflexible) && (tp1.symbol is GADTFlexType) &&
+ !isSubTypeWhenFrozen(hi1, tp2))
trySetType(tp1, TypeBounds(lo1, hi1 & tp2))
else if (lo1 eq hi1) isSubType(hi1, tp2)
else tryRebase2nd
@@ -610,7 +611,8 @@ class TypeComparer(initctx: Context) extends DotClass {
}
def compareNamed: Boolean = tp2.info match {
case TypeBounds(lo2, hi2) =>
- if ((tp2.symbol is GADTFlexType) && !isSubTypeWhenFrozen(tp1, lo2))
+ if ((ctx.mode is Mode.GADTflexible) && (tp2.symbol is GADTFlexType) &&
+ !isSubTypeWhenFrozen(tp1, lo2))
trySetType(tp2, TypeBounds(lo2 | tp1, hi2))
else
((frozenConstraint || !isCappable(tp1)) && isSubType(tp1, lo2)