summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala1
-rw-r--r--test/files/neg/bug3392.check4
-rw-r--r--test/files/neg/bug3392.scala11
3 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index b35a23ed50..59cb6c4081 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3652,6 +3652,7 @@ trait Typers extends Modes {
// case x :: xs in class List would return the :: method)
// unless they are stable or are accessors (the latter exception is for better error messages).
def qualifies(sym: Symbol): Boolean = {
+ sym.hasRawInfo && // this condition avoids crashing on self-referential pattern variables
reallyExists(sym) &&
((mode & PATTERNmode | FUNmode) != (PATTERNmode | FUNmode) || !sym.isSourceMethod || sym.hasFlag(ACCESSOR))
}
diff --git a/test/files/neg/bug3392.check b/test/files/neg/bug3392.check
new file mode 100644
index 0000000000..cbae73ad3a
--- /dev/null
+++ b/test/files/neg/bug3392.check
@@ -0,0 +1,4 @@
+bug3392.scala:9: error: not found: value x
+ case x@A(x/*<-- refers to the pattern that includes this comment*/.Ex(42)) =>
+ ^
+one error found
diff --git a/test/files/neg/bug3392.scala b/test/files/neg/bug3392.scala
new file mode 100644
index 0000000000..655c2e84a3
--- /dev/null
+++ b/test/files/neg/bug3392.scala
@@ -0,0 +1,11 @@
+object Test {
+ case class A(a: Int) {
+ object Ex {
+ def unapply(i: Int): Option[Int] = Some(i)
+ }
+ }
+
+ A(42) match {
+ case x@A(x/*<-- refers to the pattern that includes this comment*/.Ex(42)) =>
+ }
+}