Skip to content
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

GROOVY-8283: field hides getter of super class (not interface) #1767

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

eric-milles
Copy link
Member

@eric-milles eric-milles commented Aug 19, 2022

For the dynamic side of 8283, field can be selected in MetaClassImpl. If access method is declared by an interface, the interface method is the one indexed so must be considered pervasive in the type hierarchy (cannot be safely hidden). Not sure if this kind of name hiding should be extended to inner classes; hopefully the commit is enough of a first step to determine if this protocol should be changed or left alone.

@blackdrag @paulk-asert

TODO:

  • STC selection of field vs setter (verify what StaticTypeCheckingVisitor does vs MetaClassImpl)
  • static compiler classgen -- I think it currently selects the method

https://issues.apache.org/jira/browse/GROOVY-8283

@asfgit asfgit force-pushed the GROOVY-8283 branch 2 times, most recently from fb192a5 to 8324f8b Compare April 28, 2024 01:59
@eric-milles
Copy link
Member Author

@blackdrag @paulk-asert If I refresh the branch, do you think this is viable? The test case should illustrate the new hiding behavior.

@asfgit asfgit force-pushed the GROOVY-8283 branch 2 times, most recently from fe14c7f to ec44e38 Compare October 29, 2024 14:40
@eric-milles
Copy link
Member Author

For circumstances that go through ScriptBytecodeAdapter, the sender class is not propagated to MetaClassImpl. Access checks give different results, since the sender is re-mapped to the object.

            package p
            class A {}
            class B {}
            class C {
                boolean setter
                protected A foo = new A()
                A getFooA() { return this.@foo }
                void setFoo(A a) { setter = true; this.@foo = a }
            }
            class D extends C {
                protected B foo = new B() // hides A#foo; should hide A#setFoo in subclasses
                B getFooB() { return this.@foo }
            }
import p.*
            class E extends D {}
            def e = new E()
            e.foo = null // not the field from this perspective
            assert e.setter // fails

@apache apache deleted a comment from codecov-commenter Dec 9, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.

Project coverage is 68.8289%. Comparing base (da495fa) to head (8452e8a).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/main/java/groovy/lang/MetaClassImpl.java 80.0000% 1 Missing and 3 partials ⚠️
...ovy/classgen/asm/sc/StaticTypesCallSiteWriter.java 60.0000% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #1767        +/-   ##
==================================================
+ Coverage     68.8221%   68.8289%   +0.0068%     
- Complexity      29437      29460        +23     
==================================================
  Files            1420       1420                
  Lines          113141     113156        +15     
  Branches        19543      19552         +9     
==================================================
+ Hits            77866      77884        +18     
+ Misses          28735      28731         -4     
- Partials         6540       6541         +1     
Files with missing lines Coverage Δ
...codehaus/groovy/runtime/ScriptBytecodeAdapter.java 69.9266% <100.0000%> (ø)
...roovy/transform/stc/StaticTypeCheckingVisitor.java 87.7228% <100.0000%> (+0.0422%) ⬆️
...ovy/classgen/asm/sc/StaticTypesCallSiteWriter.java 73.8683% <60.0000%> (-0.1442%) ⬇️
src/main/java/groovy/lang/MetaClassImpl.java 77.7839% <80.0000%> (-0.0369%) ⬇️

... and 5 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants