Skip to content

Allow using lambdas as Expectation delegates #596

@janthoe

Description

@janthoe

Please provide the following information:

  • Version of JMockit that was used: 1.45

  • Description of the problem:

Due to type inference methodToInvoke.getReturnType() will return Object.class when using lambdas, resulting in an InvocationException where the delegate returns an Object that is an instance of the targetReturnType. ie:

java.lang.IllegalArgumentException: Value of type java.util.HashMap incompatible with return type java.util.Map of MyClassr#doSomething()
  • Check that:
  • The problem can be reproduced by JMockit project members.
    For that, include an example test (perhaps accompanied by a Maven/Gradle build script) which
    can be executed without changes and reproduces the failure.

  • The issue does not fall outside the scope of the project (for example, attempting to use JMockit
    APIs from Groovy or Scala code, or with an Android runtime).

  • The JDK where the problem occurs is a final release, not a development build.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions