diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-11-06 23:43:44 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-11-08 23:14:11 +0100 |
commit | 48ee29aa26e4e5358cb1de7890565095420177b4 (patch) | |
tree | 9b8dce70434cafafe7fc1c4afbcad7231e071ce8 /src | |
parent | 6902da3168c02448387edc000dedfe97ef5f7cd9 (diff) | |
download | scala-48ee29aa26e4e5358cb1de7890565095420177b4.tar.gz scala-48ee29aa26e4e5358cb1de7890565095420177b4.tar.bz2 scala-48ee29aa26e4e5358cb1de7890565095420177b4.zip |
Refine @compileTimeOnly
- Don't default the message, and show it exclusively.
- Fix cut-and-pasto in the @since tag
- Be tolerant if the annotaion class is missing, as seems to
have been the case compiling the continuations plugin.
- s/\t/ / in the test file to show the errors are positioned
correctly.
- Use defensive getOrElse
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 9 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/compileTimeOnly.scala | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 726c8d3b24..ee7805cb3d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1377,8 +1377,13 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } private def checkCompileTimeOnly(sym: Symbol, pos: Position) = { - if (sym.isCompileTimeOnly) - unit.error(pos, s"reference to ${sym.fullLocationString} should not survive typechecking: ${sym.compileTimeOnlyMessage.get}") + if (sym.isCompileTimeOnly) { + def defaultMsg = + s"""|Reference to ${sym.fullLocationString} should not have survived past type checking, + |it should have been processed and eliminated during expansion of an enclosing macro.""".stripMargin + // The getOrElse part should never happen, it's just here as a backstop. + unit.error(pos, sym.compileTimeOnlyMessage getOrElse defaultMsg) + } } private def lessAccessible(otherSym: Symbol, memberSym: Symbol): Boolean = ( diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 4c7694c319..2a7b55cb5a 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -944,7 +944,7 @@ trait Definitions extends api.StandardDefinitions { lazy val BeanPropertyAttr = requiredClass[scala.beans.BeanProperty] lazy val BooleanBeanPropertyAttr = requiredClass[scala.beans.BooleanBeanProperty] lazy val CloneableAttr = requiredClass[scala.annotation.cloneable] - lazy val CompileTimeOnlyAttr = requiredClass[scala.reflect.macros.compileTimeOnly] + lazy val CompileTimeOnlyAttr = getClassIfDefined("scala.reflect.macros.compileTimeOnly") lazy val DeprecatedAttr = requiredClass[scala.deprecated] lazy val DeprecatedNameAttr = requiredClass[scala.deprecatedName] lazy val DeprecatedInheritanceAttr = requiredClass[scala.deprecatedInheritance] diff --git a/src/reflect/scala/reflect/macros/compileTimeOnly.scala b/src/reflect/scala/reflect/macros/compileTimeOnly.scala index 4018e7db71..5a3a352a53 100644 --- a/src/reflect/scala/reflect/macros/compileTimeOnly.scala +++ b/src/reflect/scala/reflect/macros/compileTimeOnly.scala @@ -10,7 +10,7 @@ import scala.annotation.meta._ * * @param message the error message to print during compilation if a reference remains * after type checking - * @since 2.10.0 + * @since 2.10.1 */ @getter @setter @beanGetter @beanSetter -final class compileTimeOnly(message: String = "") extends scala.annotation.StaticAnnotation +final class compileTimeOnly(message: String) extends scala.annotation.StaticAnnotation |