Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8232933

Javac inferred type does not conform to equality constraint

    Details

    • Type: Bug
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 11.0.4
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      A DESCRIPTION OF THE PROBLEM :
      In Java 11 when i try to compile code sometimes it compiles, sometimes it fails.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile couple times

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Success compilation
      ACTUAL -
      Error:(10, 58) java: incompatible types: inferred type does not conform to equality constraint(s)
          inferred: java.util.List<Main.A<?,?>>
          equality constraints(s): java.util.List<capture#1 of ? extends Main.A<?,?>>

      ---------- BEGIN SOURCE ----------
      import java.util.LinkedList;
      import java.util.List;
      import java.util.Map;
      import java.util.stream.Collectors;

      public class Main {

          public static void main(String[] args) {
              List<? extends A<?, ?>> a = new LinkedList<>();
              Map<String, List<A<?, ?>>> b = a.stream().collect(
                      Collectors.groupingBy(A::getval, Collectors.toList())
              );

              System.out.println("Hello World!");
          }

          class A<K, V> {
              String getval() {
                  return "sss";
              }
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : often


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: