aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-07 21:46:30 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-08 09:26:43 +0100
commit2f7e4a64179c4abf246aceff39857a14c8c46f68 (patch)
treee17dff7929499b5d7c03ee309cfffbdc7baed9e5 /src/dotty/tools/dotc
parent0067358e702ba7995e534a2272c569c4e2e4e80a (diff)
downloaddotty-2f7e4a64179c4abf246aceff39857a14c8c46f68.tar.gz
dotty-2f7e4a64179c4abf246aceff39857a14c8c46f68.tar.bz2
dotty-2f7e4a64179c4abf246aceff39857a14c8c46f68.zip
Better reporting for pattern matching errors.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala5
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala2
2 files changed, 4 insertions, 3 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