summaryrefslogtreecommitdiff
path: root/test/files/run/t7096.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2013-02-08 00:05:55 +0100
committerLukas Rytz <lukas.rytz@epfl.ch>2013-02-08 09:33:16 +0100
commit5258b63740c9fb1be3c531e1dc1399fb0dc55569 (patch)
tree81c7aa0096e14512805187b319c07f6d5866d5f4 /test/files/run/t7096.scala
parent0dd02d92a363ee13b13eb4536c938d24bb5dd98d (diff)
downloadscala-5258b63740c9fb1be3c531e1dc1399fb0dc55569.tar.gz
scala-5258b63740c9fb1be3c531e1dc1399fb0dc55569.tar.bz2
scala-5258b63740c9fb1be3c531e1dc1399fb0dc55569.zip
SI-7096 SubstSymMap copies trees before modifying their symbols
I removed some strange code in a06d31f6a2 and replaced it by something incorrect: SubstSymMap should never have side-effects: otherwise, calling 'tpe1 <: tpe2' for instance would modify the symbols in annotations of tpe2. SubstSymMap now always creates new trees before changing them.
Diffstat (limited to 'test/files/run/t7096.scala')
-rw-r--r--test/files/run/t7096.scala36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala
new file mode 100644
index 0000000000..e9c0323c2e
--- /dev/null
+++ b/test/files/run/t7096.scala
@@ -0,0 +1,36 @@
+import scala.tools.partest._
+import scala.tools.nsc._
+
+object Test extends CompilerTest {
+ import global._
+ import definitions._
+
+ override def code = """
+package ano
+
+class ann(x: Any) extends annotation.TypeConstraint
+
+abstract class Base {
+ def foo(x: String): String @ann(x.trim())
+}
+
+class Sub extends Base {
+ def foo(x: String): String @ann(x.trim()) = x
+}
+ """
+
+ object syms extends SymsInPackage("ano")
+ import syms._
+
+ def check(source: String, unit: global.CompilationUnit) {
+ afterTyper {
+ terms.filter(_.name.toString == "foo").foreach(sym => {
+ val xParam = sym.tpe.paramss.flatten.head
+ val annot = sym.tpe.finalResultType.annotations.head
+ val xRefs = annot.args.head.filter(t => t.symbol == xParam)
+ println(s"testing symbol ${sym.ownerChain}, param $xParam, xRefs $xRefs")
+ assert(xRefs.length == 1, xRefs)
+ })
+ }
+ }
+}