summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala18
-rw-r--r--test/files/neg/t5578.check4
-rw-r--r--test/files/neg/t5578.scala39
3 files changed, 53 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 2bd1ba3fea..34b37073fd 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -321,13 +321,14 @@ trait Trees extends reflect.internal.Trees { self: Global =>
super.transform {
tree match {
case tpt: TypeTree =>
- if (tpt.original != null) {
+ if (tpt.original != null)
transform(tpt.original)
- } else {
- if (tpt.tpe != null && (tpt.wasEmpty || (tpt.tpe exists (tp => locals contains tp.typeSymbol))))
- tpt.tpe = null
- tree
+ else if (tpt.tpe != null && (tpt.wasEmpty || (tpt.tpe exists (tp => locals contains tp.typeSymbol)))) {
+ val dupl = tpt.duplicate
+ dupl.tpe = null
+ dupl
}
+ else tree
case TypeApply(fn, args) if args map transform exists (_.isEmpty) =>
transform(fn)
case This(_) if tree.symbol != null && tree.symbol.isPackageClass =>
@@ -335,10 +336,11 @@ trait Trees extends reflect.internal.Trees { self: Global =>
case EmptyTree =>
tree
case _ =>
+ val dupl = tree.duplicate
if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol)) && !(keepLabels && tree.symbol.isLabel))
- tree.symbol = NoSymbol
- tree.tpe = null
- tree
+ dupl.symbol = NoSymbol
+ dupl.tpe = null
+ dupl
}
}
}
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)
+
+}