You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This approach works, but I don't want to duplicate the doSomethingAndReturnYourself method in class MyClass2. When I remove the method and add the @Self annotation to MyClass1, I encounter the following error: @Self is not allowed here, use it on method and field declarations.
Additionally, the error message is not very helpful as it lacks context. It took me a long time to figure out the root cause of the issue, and I had to add extra debug output in the Manifold project and compile it myself to track it down.
publicinterfaceMyIntf {
@SelfMyIntfdoSomethingAndReturnYourself();
}
publicclassMyClass1implementsMyIntf {
@Overridepublic@SelfMyClass1doSomethingAndReturnYourself(){
// do something ...returnthis;
}
}
publicclassMyClass2extendsMyClass1 {
// also inherits doSomethingAndReturnYourself method, but should now return MyClass2// --> ERROR
}
The same error occurs both when building in IntelliJ or using Maven.
When disabling the isSelfInMethodDeclOrFieldDecl check in the visitAnnotation( JCTree.JCAnnotation tree ) method in class ExtensionTransformer.java, it seems to compile fine.
Desktop (please complete the following information):
OS Type & Version: Windows 10 22H2
Java/JDK version: openjdk 23.0.1
IDE version (IntelliJ IDEA or Android Studio): IntelliJ IDEA 2024.3
Describe the bug
There appears to be a bug with the
@Self
return type when used with extended classes. Consider the following example:This approach works, but I don't want to duplicate the
doSomethingAndReturnYourself
method in classMyClass2
. When I remove the method and add the@Self
annotation toMyClass1
, I encounter the following error:@Self is not allowed here, use it on method and field declarations
.Additionally, the error message is not very helpful as it lacks context. It took me a long time to figure out the root cause of the issue, and I had to add extra debug output in the Manifold project and compile it myself to track it down.
The same error occurs both when building in IntelliJ or using Maven.
When disabling the
isSelfInMethodDeclOrFieldDecl
check in thevisitAnnotation( JCTree.JCAnnotation tree )
method in classExtensionTransformer.java
, it seems to compile fine.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: