-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Canonical
, @Immutable
and @TupleConstructor
not properly supported
#421
Comments
When you open a source in the editor, that source has transforms applied to it. However, source types that are referred to are only processed through the compiler phase conversion. Any transform that is applied after conversion will not be visible. This includes traits as well.
I have tried some experiments to move the referred to source types to the canonicalization phase, but there were many problems encountered. There is a partial solution implemented in GroovyCompilationUnitDeclaration.applyEarlyTransforms that adds constructors and methods. But since the source type is only at phase conversion, not much type information is available, so it is very difficult to support transforms like TupleConstructor.
|
This is the same underlying issue that is causing #175 |
There is also a bit of dead code in Scope.getMethod that accounts for this issue in some cases. It has been disabled for a long time now. // GROOVY add -- give it one more chance as the ast transform may have introduced it
// Is this the right approach? Requires AST transforms running before this is done.
if (methodBinding == null) {
methodBinding = oneLastLook(currentType, selector, argumentTypes, invocationSite);
}
// FIXASC (M3) currently inactive; this enables getSingleton()
// FIXASC (M3) make this switchable as it is too damn powerful
public MethodBinding oneLastLook(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
if (false) {
MethodBinding[] extraMethods = receiverType.getAnyExtraMethods(selector, argumentTypes);
if (extraMethods != null && extraMethods.length > 0) {
return extraMethods[0];
}
}
return null;
} |
eric-milles
changed the title
@TupleConstructor and @Canonical not properly supported
Oct 8, 2022
@Canonical
, @Immutable
and @TupleConstructor
not properly supported
eric-milles
added a commit
that referenced
this issue
Oct 8, 2022
eric-milles
added a commit
that referenced
this issue
Oct 14, 2022
eric-milles
added a commit
that referenced
this issue
Oct 19, 2022
eric-milles
added a commit
that referenced
this issue
Oct 20, 2022
eric-milles
added a commit
that referenced
this issue
Oct 24, 2022
eric-milles
added a commit
that referenced
this issue
Oct 24, 2022
eric-milles
added a commit
that referenced
this issue
Nov 16, 2022
eric-milles
added a commit
that referenced
this issue
Dec 27, 2022
eric-milles
added a commit
that referenced
this issue
Dec 28, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider this example:
and the following Java class:
The editor shows a compilation error on the constructor call, but not on the Project Explorer. If you run this code, it works fine at runtime, so there seems to be some discrepancy between what the compiler does and what the parser says.
The same applies if you replace
@TupleConstructor
with@Canonical
.However, with
@Immutable
all works fine instead!The text was updated successfully, but these errors were encountered: