diff options
author | Martin Odersky <odersky@gmail.com> | 2016-07-18 12:55:07 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-18 13:09:21 +0200 |
commit | 60be18cce509bae1ed0d6c68b910f4bed10fa889 (patch) | |
tree | 00eb2520cf6562d2484e43088590f5cf869189a0 | |
parent | 7c0c1f31fda704e790ca7a9d260c8c956b28d447 (diff) | |
download | dotty-60be18cce509bae1ed0d6c68b910f4bed10fa889.tar.gz dotty-60be18cce509bae1ed0d6c68b910f4bed10fa889.tar.bz2 dotty-60be18cce509bae1ed0d6c68b910f4bed10fa889.zip |
Add test case
Also fix reviewers comments about `firstParent`
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 2 | ||||
-rw-r--r-- | tests/neg/patmat.scala | 24 |
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 + } + } +} |