Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
Describe the bug
When defining an extension function with generic types, it is possible to annotate either a parameter type or a type parameter, but annotating both produces the above error. That is to say, @NotNull List<String> is fine, and List<@NotNull String> is fine, but @NotNull List<@NotNull String> causes the error.
It's coming from manifold's TypeNameParser.verifySuperOrExtends and appears to be caused by TypeNameParser not handling type annotations.
To Reproduce
Steps to reproduce the behavior:
Define an extension function with a parameter as described above.
Attempt to compile it.
Expected behavior
All valid Java types should be accepted.
Errors when parsing source code should include information about the source code that was not parsed.
Desktop (please complete the following information):
OS Type & Version: macOS 11.6
Java/JDK version: 11
IDE version (IntelliJ IDEA or Android Studio): IDEA Ultimate 2021.2
Manifold version: 2021.1.25
Manifold IntelliJ plugin version: 2021.2.25
Stack trace
java.lang.RuntimeException: expecting 'extends' or 'super'
at manifold.api.gen.TypeNameParser.verifySuperOrExtends(TypeNameParser.java:142)
at manifold.api.gen.TypeNameParser.parseType(TypeNameParser.java:73)
at manifold.api.gen.TypeNameParser.parseParamList(TypeNameParser.java:148)
at manifold.api.gen.TypeNameParser.parseType(TypeNameParser.java:104)
at manifold.api.gen.TypeNameParser.parse(TypeNameParser.java:43)
at manifold.api.gen.SrcType.<init>(SrcType.java:49)
at manifold.internal.javac.SrcClassUtil.makeSrcType(SrcClassUtil.java:355)
at manifold.internal.javac.SrcClassUtil.addMethod(SrcClassUtil.java:293)
at manifold.internal.javac.SrcClassUtil.makeSrcClass(SrcClassUtil.java:151)
at manifold.internal.javac.SrcClassUtil.makeStub(SrcClassUtil.java:81)
at manifold.internal.javac.SrcClassUtil.makeStub(SrcClassUtil.java:75)
at manifold.internal.javac.ClassSymbols.makeSrcClassStub(ClassSymbols.java:292)
at manifold.internal.javac.ClassSymbols.makeSrcClassStub(ClassSymbols.java:272)
at manifold.ext.ExtCodeGen.addExtensions(ExtCodeGen.java:120)
at manifold.ext.ExtCodeGen.make(ExtCodeGen.java:85)
at manifold.ext.ExtensionManifold.contribute(ExtensionManifold.java:252)
at manifold.ext.ExtensionManifold.contribute(ExtensionManifold.java:52)
at manifold.api.type.ResourceFileTypeManifold.contribute(ResourceFileTypeManifold.java:417)
at manifold.internal.host.SimpleModule.compoundProduce(SimpleModule.java:174)
at manifold.internal.host.SimpleModule.lambda$produceFile$0(SimpleModule.java:139)
at manifold.internal.javac.SourceSupplier.getSource(SourceSupplier.java:50)
at manifold.internal.javac.GeneratedJavaStubFileObject.lambda$new$0(GeneratedJavaStubFileObject.java:40)
at manifold.util.concurrent.LocklessLazyVar$1.init(LocklessLazyVar.java:91)
at manifold.util.concurrent.LocklessLazyVar.get(LocklessLazyVar.java:40)
at manifold.internal.javac.GeneratedJavaStubFileObject.getCharContent(GeneratedJavaStubFileObject.java:101)
at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedFileObject.getCharContent(ClientCodeWrapper.java:625)
... 122 more
Describe the bug When defining an extension function with generic types, it is possible to annotate either a parameter type or a type parameter, but annotating both produces the above error. That is to say,
@NotNull List<String>
is fine, andList<@NotNull String>
is fine, but@NotNull List<@NotNull String>
causes the error.It's coming from manifold's
TypeNameParser.verifySuperOrExtends
and appears to be caused by TypeNameParser not handling type annotations.To Reproduce Steps to reproduce the behavior:
Expected behavior
Desktop (please complete the following information):
Stack trace