Skip to content

Fix type inferencing for bounded generics as method return type #825

@eric-milles

Description

@eric-milles

Consider the following:

def i = (0..10).getFrom() // "T getFrom()" from "interface Range<T extends Comparable>"

The type of "i" is displayed as Comparable<Integer> when it should be just Integer.

abstract class Abstract<T extends Abstract<T>> {
  T withStuff(value) {
    // ...
    return (T) this
  }
}

class Concrete extends Abstract<Concrete> {
  Concrete withThing(value) {
    // ...
    return this
  }
}

def x,y
new Concrete().withStuff(x).withThing(y)

"withThing" is showing as unknown (underlined) because the return type of "withStuff" is inferred as T, not Concrete.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions