File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1034,11 +1034,23 @@ object Erasure {
1034
1034
else None
1035
1035
}
1036
1036
1037
- // TODO: Port from scalac
1038
- private object ThrownException {
1039
- def unapply (ann : Annotation ): Option [Type ] = None
1037
+ /** Extracts the type of the thrown exception from an AnnotationInfo.
1038
+ *
1039
+ * Supports both “old-style” `@throws(classOf[Exception])`
1040
+ * as well as “new-style” `@throws[Exception]("cause")` annotations.
1041
+ */
1042
+ object ThrownException {
1043
+ def unapply (ann : Annotation )(implicit ctx : Context ): Option [Type ] = {
1044
+ ann.tree match {
1045
+ case Apply (TypeApply (fun, List (tpe)), _) if tpe.isType && fun.symbol.owner == defn.ThrowsAnnot && fun.symbol.isConstructor =>
1046
+ Some (tpe.typeOpt)
1047
+ case _ =>
1048
+ None
1049
+ }
1050
+ }
1040
1051
}
1041
1052
1053
+
1042
1054
class UnknownSig extends Exception
1043
1055
1044
1056
private def needsJavaSig (tp : Type , throwsArgs : List [Type ])(implicit ctx : Context ): Boolean = ! ctx.settings.YnoGenericSig .value && {
You can’t perform that action at this time.
0 commit comments