diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 49b91a37c43f..aad4f127e9f3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -905,8 +905,9 @@ class Typer extends Namer * of annotation defined as `@interface Annot { int[] value() }` * We assume that calling `typedNamedArg` in context of Java implies that we are dealing * with annotation contructor, as named arguments are not allowed anywhere else in Java. + * Under explicit nulls, the pt could be nullable. We need to strip `Null` type first. */ - val arg1 = pt match { + val arg1 = pt.stripNull match { case AppliedType(a, typ :: Nil) if ctx.isJava && a.isRef(defn.ArrayClass) => tryAlternatively { typed(tree.arg, pt) } { val elemTp = untpd.TypedSplice(TypeTree(typ)) diff --git a/tests/explicit-nulls/pos/annotaions-args/JAnnots.java b/tests/explicit-nulls/pos/annotaions-args/JAnnots.java new file mode 100644 index 000000000000..4c7a31a333bb --- /dev/null +++ b/tests/explicit-nulls/pos/annotaions-args/JAnnots.java @@ -0,0 +1,7 @@ +public class JAnnots { + @SuppressWarnings("unused") + public void f1() {} + + @SuppressWarnings({"unused"}) + public void f2() {} +} diff --git a/tests/explicit-nulls/pos/annotaions-args/SAnnots.scala b/tests/explicit-nulls/pos/annotaions-args/SAnnots.scala new file mode 100644 index 000000000000..2e6ef7a9bb41 --- /dev/null +++ b/tests/explicit-nulls/pos/annotaions-args/SAnnots.scala @@ -0,0 +1,4 @@ +class SAnnots { + @SuppressWarnings(Array("unused")) + def f() = {} +} \ No newline at end of file