summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-22 20:34:25 -0800
committerPaul Phillips <paulp@improving.org>2012-02-22 21:41:26 -0800
commit98cf4014a3a14dbc348a464584133d90719bdbb8 (patch)
treeadd010ac2c7ab3e5899e2f19b47dcaa278a3734b
parent06384c052ec31db4bd094b949bed0f3cb3fb644b (diff)
downloadscala-98cf4014a3a14dbc348a464584133d90719bdbb8.tar.gz
scala-98cf4014a3a14dbc348a464584133d90719bdbb8.tar.bz2
scala-98cf4014a3a14dbc348a464584133d90719bdbb8.zip
One last nudge for elidable.
A method with return type Nothing elides into a call to ??? . It's the role ??? was born for.
-rw-r--r--src/compiler/scala/reflect/internal/Definitions.scala1
-rw-r--r--src/compiler/scala/reflect/internal/StdNames.scala2
-rw-r--r--src/compiler/scala/reflect/internal/TreeGen.scala5
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala2
-rw-r--r--test/files/neg/elide-to-nothing.check4
-rw-r--r--test/files/neg/elide-to-nothing.flags1
-rw-r--r--test/files/neg/elide-to-nothing.scala31
7 files changed, 8 insertions, 38 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala
index d043230e48..ce5bb3d1c4 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/compiler/scala/reflect/internal/Definitions.scala
@@ -274,6 +274,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
def Predef_identity = getMember(PredefModule, nme.identity)
def Predef_conforms = getMember(PredefModule, nme.conforms)
def Predef_wrapRefArray = getMember(PredefModule, nme.wrapRefArray)
+ def Predef_??? = getMember(PredefModule, nme.???)
/** Is `sym` a member of Predef with the given name?
* Note: DON't replace this by sym == Predef_conforms/etc, as Predef_conforms is a `def`
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala
index f61fe7a457..a78e0cc939 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/compiler/scala/reflect/internal/StdNames.scala
@@ -260,6 +260,8 @@ trait StdNames extends NameManglers { self: SymbolTable =>
case _ => newTermName("x$" + i)
}
+ val ??? = encode("???")
+
val wrapRefArray: NameType = "wrapRefArray"
val wrapByteArray: NameType = "wrapByteArray"
val wrapShortArray: NameType = "wrapShortArray"
diff --git a/src/compiler/scala/reflect/internal/TreeGen.scala b/src/compiler/scala/reflect/internal/TreeGen.scala
index cc882ad5ed..8c2a067d4d 100644
--- a/src/compiler/scala/reflect/internal/TreeGen.scala
+++ b/src/compiler/scala/reflect/internal/TreeGen.scala
@@ -250,7 +250,10 @@ abstract class TreeGen {
* var x: T = _
* which is appropriate to the given Type.
*/
- def mkZero(tp: Type): Tree = Literal(mkConstantZero(tp)) setType tp
+ def mkZero(tp: Type): Tree = tp.typeSymbol match {
+ case NothingClass => mkMethodCall(Predef_???, Nil) setType NothingClass.tpe
+ case _ => Literal(mkConstantZero(tp)) setType tp
+ }
def mkConstantZero(tp: Type): Constant = tp.typeSymbol match {
case UnitClass => Constant(())
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 69bf006036..6a7fcc98c3 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -508,7 +508,7 @@ abstract class UnCurry extends InfoTransform
// TODO - settings.noassertions.value temporarily retained to avoid
// breakage until a reasonable interface is settled upon.
if ((sym ne null) && (sym.elisionLevel.exists (_ < settings.elidebelow.value || settings.noassertions.value)))
- super.transform(replaceElidableTree(tree))
+ replaceElidableTree(tree)
else tree match {
case dd @ DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
if (dd.symbol hasAnnotation VarargsClass) saveRepeatedParams(dd)
diff --git a/test/files/neg/elide-to-nothing.check b/test/files/neg/elide-to-nothing.check
deleted file mode 100644
index 3ef05aac9a..0000000000
--- a/test/files/neg/elide-to-nothing.check
+++ /dev/null
@@ -1,4 +0,0 @@
-elide-to-nothing.scala:14: error: Cannot elide where Nothing is required.
- val b: Nothing = unimplemented()
- ^
-one error found
diff --git a/test/files/neg/elide-to-nothing.flags b/test/files/neg/elide-to-nothing.flags
deleted file mode 100644
index 59a512e547..0000000000
--- a/test/files/neg/elide-to-nothing.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xelide-below 500
diff --git a/test/files/neg/elide-to-nothing.scala b/test/files/neg/elide-to-nothing.scala
deleted file mode 100644
index 5008e8bc1d..0000000000
--- a/test/files/neg/elide-to-nothing.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-
-/** Test which should fail compilation */
-class ElysianFailed {
-
- import ElysianField._
-
- // fine
- val a: Int = myInt
-
- // fine
- unimplemented()
-
- // not fine
- val b: Nothing = unimplemented()
-
-}
-
-object ElysianField {
-
- import annotation.elidable
-
- @elidable(100) def unimplemented(): Nothing = throw new UnsupportedOperationException
-
- @elidable(100) def myInt: Int = 17
-
-}
-
-
-
-
-