diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-06 22:39:22 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-06 22:39:22 +0000 |
commit | 7806112e43776fc812c93ec9cabd5cbd1953c4a6 (patch) | |
tree | 5f0c7a92546b0bdff8a4bbf149f481a50c149817 | |
parent | 1113f7ddca4f1814396e0de9f586c300b135f157 (diff) | |
download | scala-7806112e43776fc812c93ec9cabd5cbd1953c4a6.tar.gz scala-7806112e43776fc812c93ec9cabd5cbd1953c4a6.tar.bz2 scala-7806112e43776fc812c93ec9cabd5cbd1953c4a6.zip |
Don't transform patterns during superaccessors:...
Don't transform patterns during superaccessors: the matcher can't deal
with funny trees. Closes #4062, review by dragos.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 4 | ||||
-rw-r--r-- | test/files/run/bug4062.check | 2 | ||||
-rw-r--r-- | test/files/run/bug4062.scala | 16 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index c1a44dba93..5d19d469b5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -144,6 +144,10 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT else tree try tree match { + // Don't transform patterns or strange trees will reach the matcher (ticket #4062) + case CaseDef(pat, guard, body) => + treeCopy.CaseDef(tree, pat, transform(guard), transform(body)) + case ClassDef(_, _, _, _) => checkCompanionNameClashes(sym) val decls = sym.info.decls diff --git a/test/files/run/bug4062.check b/test/files/run/bug4062.check new file mode 100644 index 0000000000..1d474d5255 --- /dev/null +++ b/test/files/run/bug4062.check @@ -0,0 +1,2 @@ +false +true diff --git a/test/files/run/bug4062.scala b/test/files/run/bug4062.scala new file mode 100644 index 0000000000..f5478e7593 --- /dev/null +++ b/test/files/run/bug4062.scala @@ -0,0 +1,16 @@ +class A(val f : String) + +class B(f: String) extends A(f) { + def foo(x: String) = x match { + case `f` => true + case _ => false + } +} + +object Test { + def main(args: Array[String]): Unit = { + val b = new B("abc") + println(b foo "bippy") + println(b foo "abc") + } +} |