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 @@ -1035,11 +1035,23 @@ object Erasure {
1035
1035
else None
1036
1036
}
1037
1037
1038
- // TODO: Port from scalac
1039
- private object ThrownException {
1040
- def unapply (ann : Annotation ): Option [Type ] = None
1038
+ /** Extracts the type of the thrown exception from an AnnotationInfo.
1039
+ *
1040
+ * Supports both “old-style” `@throws(classOf[Exception])`
1041
+ * as well as “new-style” `@throws[Exception]("cause")` annotations.
1042
+ */
1043
+ object ThrownException {
1044
+ def unapply (ann : Annotation )(implicit ctx : Context ): Option [Type ] = {
1045
+ ann.tree match {
1046
+ case Apply (TypeApply (fun, List (tpe)), _) if tpe.isType && fun.symbol.owner == defn.ThrowsAnnot && fun.symbol.isConstructor =>
1047
+ Some (tpe.typeOpt)
1048
+ case _ =>
1049
+ None
1050
+ }
1051
+ }
1041
1052
}
1042
1053
1054
+
1043
1055
class UnknownSig extends Exception
1044
1056
1045
1057
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