Skip to content

Improve flow typing support for methods with closure parameters #523

@eric-milles

Description

@eric-milles

Methods like with have a return type that depends on the passed Closure's return type. Because the method must be visited before the arguments to collect @ClosureParams and @DelegatesTo information, the passed closure expression is not visited in time to determine the return type.

Consider the following:

Matcher[] meth() {
}
def arr = with {
  return meth()
}
arr.length
arr[0].group(0)
arr[0].matches()

In this example, the type of arr is dependent on the return type of the closure expression. length, group, and matches are currently highlighted as unknown.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions