diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-12-29 05:22:50 -0800 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-12-29 05:22:50 -0800 |
commit | 7091c70a9930f939c3e33537ceee210584daae51 (patch) | |
tree | 47f150795057631e3c3138074104636c2d57fff7 /src | |
parent | 26c27d831db5d68c4b65c0f1eb6d7286798814b5 (diff) | |
parent | 21c4db241e7e85d338c1e179373266689ce9590a (diff) | |
download | scala-7091c70a9930f939c3e33537ceee210584daae51.tar.gz scala-7091c70a9930f939c3e33537ceee210584daae51.tar.bz2 scala-7091c70a9930f939c3e33537ceee210584daae51.zip |
Merge pull request #1808 from scalamacros/topic/annotation-error
Moves annotationError outside typedAnnotation
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 13 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/AnnotationInfos.scala | 2 |
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 b5f456d1ae..4897529ca5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3355,14 +3355,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 @@ -3442,12 +3441,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 @@ -3492,7 +3491,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) { @@ -3544,14 +3543,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])` |