summaryrefslogtreecommitdiff
path: root/test/files/neg/t5578.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-05-01 19:08:41 -0700
committerPaul Phillips <paulp@improving.org>2012-05-01 19:52:09 -0700
commitae5ff6628bb74c16d871a2ada0664cdd5d2399a5 (patch)
tree6819665c0030d5305d55c9b2e4141eea8e8f2458 /test/files/neg/t5578.scala
parent15e05a400be378b012903411179f2a4114f890ef (diff)
downloadscala-ae5ff6628bb74c16d871a2ada0664cdd5d2399a5.tar.gz
scala-ae5ff6628bb74c16d871a2ada0664cdd5d2399a5.tar.bz2
scala-ae5ff6628bb74c16d871a2ada0664cdd5d2399a5.zip
Fixes #SI-5578.
ResetAttrs shouldn't be side-effecting on the original tree, since it can lead to NPEs in erroneous trees (or maybe even for valid ones?). Review by @odersky (Patch by plocinic, applied without his complicity by extempore)
Diffstat (limited to 'test/files/neg/t5578.scala')
-rw-r--r--test/files/neg/t5578.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/files/neg/t5578.scala b/test/files/neg/t5578.scala
new file mode 100644
index 0000000000..ce72f32d53
--- /dev/null
+++ b/test/files/neg/t5578.scala
@@ -0,0 +1,39 @@
+trait Base {
+ type Rep[T]
+}
+
+trait Expressions {
+ // constants/symbols (atomic)
+ abstract class Exp[T]
+ // ...
+ case class Sym[T](n: Int) extends Exp[T]
+
+ // operations (composite, defined in subtraits)
+ abstract class Def[T]
+
+ // additional members for managing encountered definitions
+ def findOrCreateDefinition[T](rhs: Def[T]): Sym[T]
+ implicit def toExp[T:Manifest](d: Def[T]): Exp[T] = findOrCreateDefinition(d)
+}
+
+trait BaseExp extends Base with Expressions {
+ type Rep[T] = Exp[T]
+
+ def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] = null // stub
+}
+
+trait NumericOps extends Base {
+ def plus[T](x: Rep[T], y: Rep[T]): Rep[T]
+}
+
+trait NumericOpsExp extends BaseExp {
+ case class Plus[T:Numeric](x: Rep[T], y: Rep[T])
+ extends Def[T]
+
+ def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y)
+
+ // Possible solutions:
+// def plus[T: Numeric: Manifest](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x, y)
+// def plus[T](x: Rep[T], y: Rep[T])(implicit num: Numeric[T], man: Manifest[T]): Rep[T] = Plus(x,y)
+
+}