Skip to content

Fix type inferencing for closure/lambda parameter(s) when SAM is not declared directly #1368

@eric-milles

Description

@eric-milles

Consider the following:

import java.util.function.Function

@FunctionalInterface
interface F extends Function<Number,String> {
}

class C {
  def m(F func) {
  }
  void test() {
    m { n ->
      n.intValue().toString()
    }
  }
}

SAM-type F does not directly declare its abstract method apply. Inferred type of "n" parameter is type parameter T when Number is expected.

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions