diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 80377807dedc..508794fc8a7b 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -661,7 +661,7 @@ class ClassfileParser( val constr = ctx.newSymbol( owner = classRoot.symbol, name = nme.CONSTRUCTOR, - flags = Flags.Synthetic | Flags.JavaDefined, + flags = Flags.Synthetic | Flags.JavaDefined | Flags.Method, info = constrType ).entered for ((attr, i) <- attrs.zipWithIndex) diff --git a/tests/pending/neg/i5690.scala b/tests/pending/neg/i5690.scala new file mode 100644 index 000000000000..85723a848172 --- /dev/null +++ b/tests/pending/neg/i5690.scala @@ -0,0 +1,8 @@ +// instantiating java annotations should not be allowed +// (would fail at runtime with java.lang.InstantiationError) +// see tests/pos/i5690.scala +object AnnotInst{ + def main(a: Array[String]) = { + new java.lang.annotation.Inherited // error + } +} diff --git a/tests/pos/i5690.scala b/tests/pos/i5690.scala new file mode 100644 index 000000000000..25c81b72d0b6 --- /dev/null +++ b/tests/pos/i5690.scala @@ -0,0 +1,8 @@ +// TODO: this should be a compilation error +// program fails at runtime with java.lang.InstantiationError +// see tests/pending/neg/i5690.scala +object AnnotInst{ + def main(a: Array[String]) = { + new java.lang.annotation.Inherited + } +}