diff options
author | Paul Phillips <paulp@improving.org> | 2012-05-01 19:08:41 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-05-01 19:52:09 -0700 |
commit | ae5ff6628bb74c16d871a2ada0664cdd5d2399a5 (patch) | |
tree | 6819665c0030d5305d55c9b2e4141eea8e8f2458 /test/files | |
parent | 15e05a400be378b012903411179f2a4114f890ef (diff) | |
download | scala-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')
-rw-r--r-- | test/files/neg/t5578.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5578.scala | 39 |
2 files changed, 43 insertions, 0 deletions
diff --git a/test/files/neg/t5578.check b/test/files/neg/t5578.check new file mode 100644 index 0000000000..d803adb223 --- /dev/null +++ b/test/files/neg/t5578.check @@ -0,0 +1,4 @@ +t5578.scala:33: error: No Manifest available for T. + def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y) + ^ +one error found 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) + +} |