From 9654d5149166464987b7f8aa6c6d2cae8cbb3ae6 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 6 May 2011 16:34:10 +0000 Subject: Tightened a condition to avoid a self-referenti... Tightened a condition to avoid a self-referential pattern variable crash. Closes #3392, no review. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 1 + test/files/neg/bug3392.check | 4 ++++ test/files/neg/bug3392.scala | 11 +++++++++++ 3 files changed, 16 insertions(+) create mode 100644 test/files/neg/bug3392.check create mode 100644 test/files/neg/bug3392.scala 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)) => + } +} -- cgit v1.2.3