summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-08 20:10:53 +0000
committerPaul Phillips <paulp@improving.org>2010-11-08 20:10:53 +0000
commit71f765bc4f9ef4599855a7550dd79347c4c578ba (patch)
treeefdb2bdf4c5bf26fe794da6bb67a33c4e76b4d76
parent942bf86c7bb28c7d9aeae82204ae060ae330d9b6 (diff)
downloadscala-71f765bc4f9ef4599855a7550dd79347c4c578ba.tar.gz
scala-71f765bc4f9ef4599855a7550dd79347c4c578ba.tar.bz2
scala-71f765bc4f9ef4599855a7550dd79347c4c578ba.zip
Fixed crasher with @elidable on parameterized m...
Fixed crasher with @elidable on parameterized methods. Closes #3981, no review.
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala17
-rw-r--r--test/files/pos/elidable-tparams.scala10
2 files changed, 19 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 63f4c05def..45fbf7b708 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -467,10 +467,13 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
*/
def elideIntoUnit(tree: Tree): Tree = Literal(()) setPos tree.pos setType UnitClass.tpe
def isElidable(tree: Tree) = {
- val sym = tree.symbol
+ val sym = treeInfo.methPart(tree).symbol
// XXX settings.noassertions.value temporarily retained to avoid
// breakage until a reasonable interface is settled upon.
- sym != null && sym.elisionLevel.exists(x => x < settings.elidebelow.value || settings.noassertions.value)
+ sym != null && sym.elisionLevel.exists(x => x < settings.elidebelow.value || settings.noassertions.value) && {
+ log("Eliding call from " + tree.symbol.owner + " to " + sym + " based on its elision threshold of " + sym.elisionLevel.get)
+ true
+ }
}
// ------ The tree transformers --------------------------------------------------------
@@ -516,7 +519,8 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
t
}
- tree match {
+ if (isElidable(tree)) elideIntoUnit(tree)
+ else tree match {
case DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
withNeedLift(false) {
if (tree.symbol.isClassConstructor) {
@@ -577,9 +581,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
treeCopy.UnApply(tree, fn1, args1)
case Apply(fn, args) =>
- if (isElidable(fn))
- elideIntoUnit(tree)
- else if (fn.symbol == Object_synchronized && shouldBeLiftedAnyway(args.head))
+ if (fn.symbol == Object_synchronized && shouldBeLiftedAnyway(args.head))
transform(treeCopy.Apply(tree, fn, List(liftTree(args.head))))
else
withNeedLift(true) {
@@ -637,8 +639,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
atPos(tree.pos)(Apply(tree, Nil) setType tree.tpe.resultType)
}
- if (isElidable(tree)) elideIntoUnit(tree) // was not seen in mainTransform
- else if (needsParens) repair
+ if (needsParens) repair
else if (tree.isType) TypeTree(tree.tpe) setPos tree.pos
else tree
}
diff --git a/test/files/pos/elidable-tparams.scala b/test/files/pos/elidable-tparams.scala
new file mode 100644
index 0000000000..456c472c4e
--- /dev/null
+++ b/test/files/pos/elidable-tparams.scala
@@ -0,0 +1,10 @@
+import annotation._
+import elidable._
+
+class ElidableCrashTest {
+ trait My
+
+ @elidable(ALL) def foo[a >: My <: My]: scala.Unit = ()
+
+ foo[My] // crash
+} \ No newline at end of file