summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala4
-rw-r--r--test/files/neg/bad-advice.check6
-rw-r--r--test/files/neg/bad-advice.flags1
-rw-r--r--test/files/neg/bad-advice.scala6
4 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 0c5f798c23..13fa2a947d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -285,8 +285,8 @@ trait TypeDiagnostics {
case xs => xs map (_ => "_") mkString (clazz.name + "[", ",", "]")
})+ "`"
- "\nNote: if you intended to match against the class, try "+ caseString
-
+ if (!clazz.exists) ""
+ else "\nNote: if you intended to match against the class, try "+ caseString
}
case class TypeDiag(tp: Type, sym: Symbol) extends Ordered[TypeDiag] {
diff --git a/test/files/neg/bad-advice.check b/test/files/neg/bad-advice.check
new file mode 100644
index 0000000000..03b3e4f616
--- /dev/null
+++ b/test/files/neg/bad-advice.check
@@ -0,0 +1,6 @@
+bad-advice.scala:4: error: pattern type is incompatible with expected type;
+ found : Bip.type
+ required: Int
+ case Bip => true
+ ^
+one error found
diff --git a/test/files/neg/bad-advice.flags b/test/files/neg/bad-advice.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/bad-advice.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/bad-advice.scala b/test/files/neg/bad-advice.scala
new file mode 100644
index 0000000000..b1955330d7
--- /dev/null
+++ b/test/files/neg/bad-advice.scala
@@ -0,0 +1,6 @@
+object Bip
+object Test {
+ def f(x: Int) = x match {
+ case Bip => true
+ }
+}