GROOVY-9292: Compilation error when accessing a protected(via thisObject, owner and delegate)/package-private super class field from inside a closure#1048
GROOVY-9292: Compilation error when accessing a protected(via thisObject, owner and delegate)/package-private super class field from inside a closure#1048daniellansun wants to merge 3 commits intoapache:masterfrom daniellansun:GROOVY-9288-REWORK
thisObject, owner and delegate)/package-private super class field from inside a closure#1048Conversation
|
Can you reframe the remaining problems as a new ticket? The original GROOVY-9288 issue should be fixed in my estimation. Also, you have test cases disabled with a boolean switch. Can you use @ignore or @NotYetImplemented to disable them? And do you expect those test cases to work? It was unclear if they indicate a different problem or unsolved part of the current issue. |
|
Even if the fix for GROOVY-7996 was rolled back, protected field can not be accessed via |
thisObject, owner and delegate)/package-private super class field from inside a closure
…ject`, `owner` and `delegate`)/package-private super class field from inside a closure
|
Here is another take on your change that checks protected and package-private access for the closure's enclosing type. if (field != null && !field.isPublic()
&& objectExpression instanceof VariableExpression
&& typeCheckingContext.getEnclosingClosure() != null
&& (
(field.isProtected() && typeCheckingContext.getEnclosingClassNode().isDerivedFrom(current))
||
(!field.isPrivate() && Objects.equals(typeCheckingContext.getEnclosingClassNode().getPackageName(), current.getPackageName()))
)
) {
switch (objectExpression.getText()) {
case "it":
case "owner":
case "delegate":
case "thisObject":
pexp.putNodeMetaData(DYNAMIC_RESOLUTION, Boolean.TRUE);
}
}I'm still not too keen on dynamic properties. But at least this should stop conversion of forbidden access to missing property. What does not match up is that explicit-this and implicit-this don't produce compiler errors, but instead result in missing property exceptions. I'm just not sure if we know enough to proceed on a change... |
|
@eric-milles Let's make it work, then work better, at last work perfectly ;-) Replaced with #1050 |
|
@eric-milles BTW, I will add your tweak in PR #1050 with your commit info reserved |
|
@eric-milles After your patch applied, the following tests fails, so I will keep the original PR as it is for now: |
|
@eric-milles parts of your patch is applied: ae0bc9f |

No description provided.