aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--tests/neg/patmat.scala24
2 files changed, 25 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index f7a96c6b4..262e6a087 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -751,7 +751,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
if (subtp <:< tp) true
else tp match {
case tp: TypeRef if tp.symbol.isClass =>
- tp.symbol.is(Trait) && isSubTypeOfParent(subtp, tp.parents.head)
+ tp.symbol.is(Trait) && isSubTypeOfParent(subtp, tp.firstParent)
case tp: TypeProxy => isSubTypeOfParent(subtp, tp.superType)
case _ => false
}
diff --git a/tests/neg/patmat.scala b/tests/neg/patmat.scala
new file mode 100644
index 000000000..e2ab9874e
--- /dev/null
+++ b/tests/neg/patmat.scala
@@ -0,0 +1,24 @@
+trait A
+trait B
+class C extends A with B
+case class D()
+object X {
+ def unapply(x: B): Boolean = false
+}
+
+object Test {
+ def main(args: Array[String]) = {
+ val ca: A = new C
+ ca match {
+ case x: B =>
+ case X() =>
+ case D() => // error: neither a subtype not a supertype
+ }
+ val cc = new C
+ cc match {
+ case x: B =>
+ case X() =>
+ case D() => // error: neither a subtype not a supertype
+ }
+ }
+}