diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 4 | ||||
-rw-r--r-- | src/library/scala/annotation/elidable.scala | 39 | ||||
-rw-r--r-- | test/files/pos/elidable-tparams.scala | 2 | ||||
-rw-r--r-- | test/files/run/elidable-noflags.check | 7 | ||||
-rw-r--r-- | test/files/run/elidable-noflags.scala | 22 |
5 files changed, 59 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index f9d0d4034c..44bd03d14f 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -46,8 +46,8 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings { val sourcedir = StringSetting ("-Xsourcedir", "directory", "(Requires -target:msil) Mirror source folder structure in output directory.", ".").dependsOn(target, "msil") val checkInit = BooleanSetting ("-Xcheckinit", "Wrap field accessors to throw an exception on uninitialized access.") val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions or assumptions.") - val elidebelow = IntSetting ("-Xelide-below", "Generate calls to @elidable-marked methods only if method priority is greater than argument.", - elidable.ASSERTION, None, elidable.byName.get(_)) + val elidebelow = IntSetting ("-Xelide-below", "Calls to @elidable methods are omitted if method priority is lower than argument", + elidable.MINIMUM, None, elidable.byName get _) val noForwarders = BooleanSetting ("-Xno-forwarders", "Do not generate static forwarders in mirror classes.") val future = BooleanSetting ("-Xfuture", "Turn on future language features.") val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot.", "") diff --git a/src/library/scala/annotation/elidable.scala b/src/library/scala/annotation/elidable.scala index 1767e044fe..ef8c20b43b 100644 --- a/src/library/scala/annotation/elidable.scala +++ b/src/library/scala/annotation/elidable.scala @@ -39,22 +39,34 @@ final class elidable(final val level: Int) extends annotation.StaticAnnotation { * @since 2.8 */ object elidable { - final val ALL = Int.MinValue // Level.ALL.intValue() - final val FINEST = 300 // Level.FINEST.intValue() - final val FINER = 400 // Level.FINER.intValue() - final val FINE = 500 // Level.FINE.intValue() - final val CONFIG = 700 // Level.CONFIG.intValue() - final val INFO = 800 // Level.INFO.intValue() - final val WARNING = 900 // Level.WARNING.intValue() - final val SEVERE = 1000 // Level.SEVERE.intValue() - final val OFF = Int.MaxValue // Level.OFF.intValue() + /** The levels ALLĀ and OFF are confusing in this context because the + * sentiment being expressed when using the annotation is at cross purposes + * with the one being expressed via -Xelide-below. This confusion reaches + * its zenith at level OFF, where the annotation means "never elide this method" + * but -Xelide-below OFF is how you would say "elide everything possible." + * + * With no simple remedy at hand, the issue is now at least documented, + * and aliases MAXIMUM and MINIMUM are offered. + */ + final val ALL = Int.MinValue // Level.ALL.intValue() + final val FINEST = 300 // Level.FINEST.intValue() + final val FINER = 400 // Level.FINER.intValue() + final val FINE = 500 // Level.FINE.intValue() + final val CONFIG = 700 // Level.CONFIG.intValue() + final val INFO = 800 // Level.INFO.intValue() + final val WARNING = 900 // Level.WARNING.intValue() + final val SEVERE = 1000 // Level.SEVERE.intValue() + final val OFF = Int.MaxValue // Level.OFF.intValue() - // and since we had to do that anyway, we can add a few of our own + // a couple aliases for the confusing ALL and OFF + final val MAXIMUM = OFF + final val MINIMUM = ALL + + // and we can add a few of our own final val ASSERTION = 2000 // we should make this more granular // for command line parsing so we can use names or ints val byName: Map[String, Int] = Map( - "ALL" -> ALL, "FINEST" -> FINEST, "FINER" -> FINER, "FINE" -> FINE, @@ -62,7 +74,10 @@ object elidable { "INFO" -> INFO, "WARNING" -> WARNING, "SEVERE" -> SEVERE, + "ASSERTION" -> ASSERTION, + "ALL" -> ALL, "OFF" -> OFF, - "ASSERTION" -> ASSERTION + "MAXIMUM" -> MAXIMUM, + "MINIMUM" -> MINIMUM ) } diff --git a/test/files/pos/elidable-tparams.scala b/test/files/pos/elidable-tparams.scala index 456c472c4e..23b1cba615 100644 --- a/test/files/pos/elidable-tparams.scala +++ b/test/files/pos/elidable-tparams.scala @@ -4,7 +4,7 @@ import elidable._ class ElidableCrashTest { trait My - @elidable(ALL) def foo[a >: My <: My]: scala.Unit = () + @elidable(MINIMUM) def foo[a >: My <: My]: scala.Unit = () foo[My] // crash }
\ No newline at end of file diff --git a/test/files/run/elidable-noflags.check b/test/files/run/elidable-noflags.check new file mode 100644 index 0000000000..23be9ab4ef --- /dev/null +++ b/test/files/run/elidable-noflags.check @@ -0,0 +1,7 @@ +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +Good for me, I was not elided. +ESPECIALLY good for me, I was not elided. diff --git a/test/files/run/elidable-noflags.scala b/test/files/run/elidable-noflags.scala new file mode 100644 index 0000000000..1b9c5118bb --- /dev/null +++ b/test/files/run/elidable-noflags.scala @@ -0,0 +1,22 @@ +import annotation._ +import elidable._ + +object Test { + @elidable(FINEST) def f1() = println("Good for me, I was not elided.") + @elidable(INFO) def f2() = println("Good for me, I was not elided.") + @elidable(SEVERE) def f3() = println("Good for me, I was not elided.") + @elidable(INFO) def f4() = println("Good for me, I was not elided.") + @elidable(100000) def f5() = println("Good for me, I was not elided.") + @elidable(OFF) def f6() = println("Good for me, I was not elided.") + @elidable(ALL) def f7() = println("ESPECIALLY good for me, I was not elided.") + + def main(args: Array[String]): Unit = { + f1() + f2() + f3() + f4() + f5() + f6() + f7() + } +} |