aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala5
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala2
-rw-r--r--tests/pos/desugar.scala8
3 files changed, 10 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 023e7c2b5..cb14fd785 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -589,13 +589,14 @@ trait Applications extends Compatibility { self: Typer =>
case mt: MethodType if !mt.isDependent =>
val unapplyArgType = mt.paramTypes.head
println(s"unapp arg tpe = ${unapplyArgType.show}, pt = ${pt.show}")
+ def wpt = widenForMatchSelector(pt)
val ownType =
if (pt <:< unapplyArgType) {
fullyDefinedType(unapplyArgType, "extractor argument", tree.pos)
println(i"case 1 $unapplyArgType ${ctx.typerState.constraint}")
pt
}
- else if (unapplyArgType <:< widenForMatchSelector(pt)) {
+ else if (unapplyArgType <:< wpt) {
maximizeType(unapplyArgType) match {
case Some(tvar) =>
def msg =
@@ -621,7 +622,7 @@ trait Applications extends Compatibility { self: Typer =>
println(i"case 2 $unapplyArgType ${ctx.typerState.constraint}")
unapplyArgType
} else errorType(
- s"Pattern type ${unapplyArgType.show} is neither a subtype nor a supertype of selector type ${pt.show}",
+ i"Pattern type $unapplyArgType is neither a subtype nor a supertype of selector type $wpt",
tree.pos)
var argTypes = unapplyArgs(mt.resultType)
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index addd3d881..8325549e6 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -208,7 +208,7 @@ object Inferencing {
}
}
- /** Recursively and also follow type declarations and type aliases. */
+ /** Recursively widen and also follow type declarations and type aliases. */
def widenForMatchSelector(tp: Type)(implicit ctx: Context): Type = tp.widen match {
case tp: TypeRef if !tp.symbol.isClass => widenForMatchSelector(tp.bounds.hi)
case tp => tp
diff --git a/tests/pos/desugar.scala b/tests/pos/desugar.scala
index fbf55d18b..7a12de373 100644
--- a/tests/pos/desugar.scala
+++ b/tests/pos/desugar.scala
@@ -29,10 +29,14 @@ object desugar {
object patDefs {
- val xs = Cons(1, Cons(2, Nil))
+ val xs: List[Int] = Cons(1, Cons(2, Nil))
- val Cons(y, ys) = xs
+ val Cons(y, ys) = xs
val Cons(z, _) = xs
val Cons(_, _) = xs
+
+ val (cons: Cons[Int]) = xs
+
+ val x, y, z: Int = 1
}
} \ No newline at end of file