typetools / typetools/checker-framework
TypeUseLocation.RECEIVER is not applied to inner class constructor receivers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
@DefaultFor TypeUseLocation.RECEIVER is not applied to inner class constructor receivers. The inner class constructor receivers currently take on the default qualifier of the hierarchy, while all other methods of the inner class take on the default qualifier set by TypeUseLocation.RECEIVER. This seems inconsistent.
This is a problem encountered when creating a type hierarchy where the default type of the hierarchy is a subtype of the Top type, and the default type for receivers is set to Top. In Nullness checker, the default type for receivers is the default type of it's hierarchy instead of it's Top, thus cannot be used to reveal this issue.
I have prepared a test checker and test case with this special hierarchy as a pull request: https://github.com/typetools/checker-framework/pull/949
Error output:
tests/nontopdefault/NTDTest.java:26: error: [methodref.receiver.bound.invalid] @NTDTop NTDConstructorReceiverTest is not a valid receiver for @NTDMiddle InnerDefaultReceiver <init>(@NTDMiddle NTDConstructorReceiverTest this) in NTDConstructorReceiverTest.InnerDefaultReceiver; attempting to use an incompatible receiver type
Demand<InnerDefaultReceiver> constructorReference = InnerDefaultReceiver::new;
^
found : @NTDTop NTDConstructorReceiverTest
required: @NTDMiddle NTDConstructorReceiverTest
1 error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the test case in tests/nontopdefault/NTDTest.java and pull request 949, then trace how inner class constructor receivers receive defaults. Done means TypeUseLocation.RECEIVER supplies the receiver qualifier for inner class constructors consistently with other inner-class methods, and the reported test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100