Uploaded image for project: 'Clover'
  1. Clover
  2. CLOV-1399

Java 1.8 compilation fails when lambda is passed to a generic argument

XMLWordPrintable

      The following piece of code fails to be instrumented

      public class Fails<N> {
      
          public final <S extends N> Iterable<S> depthFirstTraversal(Class<S> type) {
              return (Iterable<S>) depthFirstTraversal(e -> type.isInstance(e));
          }
      
          public final Iterable<N> depthFirstTraversal(Predicate<? super N> predicate) {
              return null;
          }
      }
      

      Javac gives the following error message:

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project cake-util: Compilation failure: Compilation failure:
      [ERROR] /Users/kasperni/workspace/CAKE/cake-util/cake-util/target/clover/src-instrumented/org/cakeframework/internal/util/tree/Fails.java:[27,67] reference to depthFirstTraversal is ambiguous
      [ERROR] both method <S>depthFirstTraversal(java.lang.Class<S>) in org.cakeframework.internal.util.tree.Fails and method depthFirstTraversal(java.util.function.Predicate<? super N>) in org.cakeframework.internal.util.tree.Fails match
      [ERROR] /Users/kasperni/workspace/CAKE/cake-util/cake-util/target/clover/src-instrumented/org/cakeframework/internal/util/tree/Fails.java:[27,86] incompatible types: cannot infer type-variable(s) I,T
      [ERROR] (argument mismatch; java.lang.Class is not a functional interface)
      [ERROR] -> [Help 1]

              mparfianowicz Marek Parfianowicz
              4d85d3f9-8aa3-417a-bb6f-61e186be8e94 Deleted Account (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: