summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-12-13 02:31:54 +0100
committerEugene Burmako <xeno.by@gmail.com>2012-12-25 00:36:06 +0100
commit21c4db241e7e85d338c1e179373266689ce9590a (patch)
tree818e32d40dde4bc56e420a272f7dd4c89b47786d /src
parentd2a7aa4ba1c048e52affb0eb2b9167a18dc29c83 (diff)
downloadscala-21c4db241e7e85d338c1e179373266689ce9590a.tar.gz
scala-21c4db241e7e85d338c1e179373266689ce9590a.tar.bz2
scala-21c4db241e7e85d338c1e179373266689ce9590a.zip
Moves annotationError outside typedAnnotation
This refactoring allows everyone from the compiler, e.g. the macro engine which expands annotation-emitting macros, to produce annotation errors.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationInfos.scala2
2 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 4fd65c18d1..453dfd2f35 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3359,14 +3359,13 @@ trait Typers extends Modes with Adaptations with Tags {
* @param annClass the expected annotation class
*/
def typedAnnotation(ann: Tree, mode: Int = EXPRmode, selfsym: Symbol = NoSymbol, annClass: Symbol = AnnotationClass, requireJava: Boolean = false): AnnotationInfo = {
- lazy val annotationError = AnnotationInfo(ErrorType, Nil, Nil)
var hasError: Boolean = false
val pending = ListBuffer[AbsTypeError]()
def reportAnnotationError(err: AbsTypeError) = {
pending += err
hasError = true
- annotationError
+ ErroneousAnnotation
}
/** Calling constfold right here is necessary because some trees (negated
@@ -3446,12 +3445,12 @@ trait Typers extends Modes with Adaptations with Tags {
extract(ann, List())
}
- val res = if (fun.isErroneous) annotationError
+ val res = if (fun.isErroneous) ErroneousAnnotation
else {
val typedFun @ Select(New(tpt), _) = typed(fun, forFunMode(mode), WildcardType)
val annType = tpt.tpe
- if (typedFun.isErroneous) annotationError
+ if (typedFun.isErroneous) ErroneousAnnotation
else if (annType.typeSymbol isNonBottomSubClass ClassfileAnnotationClass) {
// annotation to be saved as java classfile annotation
val isJava = typedFun.symbol.owner.isJavaDefined
@@ -3496,7 +3495,7 @@ trait Typers extends Modes with Adaptations with Tags {
reportAnnotationError(AnnotationMissingArgError(ann, annType, sym))
}
- if (hasError) annotationError
+ if (hasError) ErroneousAnnotation
else AnnotationInfo(annType, List(), nvPairs map {p => (p._1, p._2.get)}).setOriginal(Apply(typedFun, args).setPos(ann.pos))
}
} else if (requireJava) {
@@ -3548,14 +3547,14 @@ trait Typers extends Modes with Adaptations with Tags {
if (annType.typeSymbol == DeprecatedAttr && argss.flatten.size < 2)
unit.deprecationWarning(ann.pos, "@deprecated now takes two arguments; see the scaladoc.")
- if ((typedAnn.tpe == null) || typedAnn.tpe.isErroneous) annotationError
+ if ((typedAnn.tpe == null) || typedAnn.tpe.isErroneous) ErroneousAnnotation
else annInfo(typedAnn)
}
}
if (hasError) {
pending.foreach(ErrorUtils.issueTypeError)
- annotationError
+ ErroneousAnnotation
} else res
}
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
index cfa4bdf44c..7a972c3f1a 100644
--- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
@@ -326,6 +326,8 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable =>
object UnmappableAnnotation extends CompleteAnnotationInfo(NoType, Nil, Nil)
+ object ErroneousAnnotation extends CompleteAnnotationInfo(ErrorType, Nil, Nil)
+
/** Extracts symbol of thrown exception from AnnotationInfo.
*
* Supports both “old-style” `@throws(classOf[Exception])`