groovy / groovy/groovy-eclipse
Fix type inferencing for withTraits expression
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Java
- Stars
- 681
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following:
trait Filtering {
StringBuilder append(String str) {
def subst = str.replace('o', '')
super.append(subst)
}
String toString() {
super.toString()
}
}
def sb = new StringBuilder().withTraits(Filtering)
sb.append('Groovy')
println sb.toString()
"sb" infers as Object, "append" shows as unknown (underlined) and "toString" infers to Object.toString(). Is it possible to infer that typeof(sb) is Filtering from the source?
Contributor guide
No contributing guide indexed for this repository
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 reproducing the withTraits example in the issue and inspect how Eclipse Groovy Development Tools infers the type of sb. Trace the handling of the withTraits expression and verify that sb, append, and toString resolve to the trait-aware type rather than Object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100