summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala2
-rw-r--r--test/files/run/t4897.check1
-rw-r--r--test/files/run/t4897.scala10
3 files changed, 12 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
index 4e4176e531..eef2c5fd3c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
@@ -1024,7 +1024,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
else expectedTp match {
// TODO: [SPEC] the spec requires `eq` instead of `==` for singleton types
// this implies sym.isStable
- case SingleType(_, sym) => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen))
+ case SingleType(_, sym) => and(equalsTest(gen.mkAttributedQualifier(expectedTp), testedBinder), typeTest(testedBinder, expectedTp.widen))
// must use == to support e.g. List() == Nil
case ThisType(sym) if sym.isModule => and(equalsTest(CODE.REF(sym), testedBinder), typeTest(testedBinder, expectedTp.widen))
case ConstantType(Constant(null)) if testedBinder.info.widen <:< AnyRefClass.tpe
diff --git a/test/files/run/t4897.check b/test/files/run/t4897.check
new file mode 100644
index 0000000000..17dda56fe1
--- /dev/null
+++ b/test/files/run/t4897.check
@@ -0,0 +1 @@
+joepie
diff --git a/test/files/run/t4897.scala b/test/files/run/t4897.scala
new file mode 100644
index 0000000000..a2ec3de37f
--- /dev/null
+++ b/test/files/run/t4897.scala
@@ -0,0 +1,10 @@
+class CSuper {
+ object A
+}
+class C extends CSuper {
+ def f = (A: AnyRef) match { case _: A.type => "joepie" }
+}
+
+object Test extends C with App {
+ println(f)
+} \ No newline at end of file