diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-10-26 15:47:54 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-10-26 17:16:07 +0100 |
commit | 4a5a800d4606d917289dc14c35f2035e83f58953 (patch) | |
tree | 1ed0ae3e948fc6de0f3bd451ae85e5dbdaacc7d5 /src/reflect | |
parent | 462dc9af886391c9c31cb6949b15e69b0cab55ef (diff) | |
download | scala-4a5a800d4606d917289dc14c35f2035e83f58953.tar.gz scala-4a5a800d4606d917289dc14c35f2035e83f58953.tar.bz2 scala-4a5a800d4606d917289dc14c35f2035e83f58953.zip |
SI-9535 correct bytecode and generic signatures for @throws[TypeParam]
For @throws[E] where E is not a class type, GenASM incorrectly writes
the non-class type to the classfile. GenBCode used to crash before
this commit. Now GenBCode correctly emits the erased type (like
javac) and adds a generic signature.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/AnnotationInfos.scala | 16 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 2 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index b923541b56..207a66e360 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -30,12 +30,6 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => def staticAnnotations = annotations filter (_.isStatic) - /** Symbols of any @throws annotations on this symbol. - */ - def throwsAnnotations(): List[Symbol] = annotations collect { - case ThrownException(exc) => exc - } - def addThrowsAnnotation(throwableSym: Symbol): Self = { val throwableTpe = if (throwableSym.isMonomorphicType) throwableSym.tpe else { debuglog(s"Encountered polymorphic exception `${throwableSym.fullName}` while parsing class file.") @@ -406,24 +400,24 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => class ErroneousAnnotation() extends CompleteAnnotationInfo(ErrorType, Nil, Nil) - /** Extracts symbol of thrown exception from AnnotationInfo. + /** Extracts the type of the thrown exception from an AnnotationInfo. * * Supports both “old-style” `@throws(classOf[Exception])` * as well as “new-stye” `@throws[Exception]("cause")` annotations. */ object ThrownException { - def unapply(ann: AnnotationInfo): Option[Symbol] = { + def unapply(ann: AnnotationInfo): Option[Type] = { ann match { case AnnotationInfo(tpe, _, _) if tpe.typeSymbol != ThrowsClass => None // old-style: @throws(classOf[Exception]) (which is throws[T](classOf[Exception])) case AnnotationInfo(_, List(Literal(Constant(tpe: Type))), _) => - Some(tpe.typeSymbol) + Some(tpe) // new-style: @throws[Exception], @throws[Exception]("cause") case AnnotationInfo(TypeRef(_, _, arg :: _), _, _) => - Some(arg.typeSymbol) + Some(arg) case AnnotationInfo(TypeRef(_, _, Nil), _, _) => - Some(ThrowableClass) + Some(ThrowableTpe) } } } diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index c3b2a8da08..ce93841567 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -2964,7 +2964,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => loop(info) } - override def exceptions = annotations flatMap ThrownException.unapply + override def exceptions = for (ThrownException(tp) <- annotations) yield tp.typeSymbol } implicit val MethodSymbolTag = ClassTag[MethodSymbol](classOf[MethodSymbol]) |