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

method cannot be applied to types in conjunction with generics

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      21:53 $ java --version
      openjdk 17.0.10 2024-01-16
      OpenJDK Runtime Environment (build 17.0.10+7-suse-117.11-x8664)
      OpenJDK 64-Bit Server VM (build 17.0.10+7-suse-117.11-x8664, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      Trying to compile the following:
      ```
         public BigINumber<?,?> asIntervalExact() {
             assert base() == 2 || base() == 10;
            // return (base() == 10)
            // ? asIntervalExact(BigDecimalFloat .ZERO)
            // : asIntervalExact(BigDual .ZERO);
            return asIntervalExact((base() == 10) ? BigDecimalFloat .ZERO : BigDual .ZERO);
          }

          private <N extends BigFloat<N>> BigINumber<?,N> asIntervalExact(N minZero) {
      ...
      }
      ```

      results in

      ```
      method asIntervalExact in class eu.simuline.arithmetics.left2rightA.MMultiplexer cannot be applied to given types;
      [ERROR] required: N
      [ERROR] found: (base() ==[...].ZERO
      [ERROR] reason: inference variable N has incompatible bounds
      [ERROR] equality constraints: eu.simuline.arithmetics.dual.BigDecimalFloat,eu.simuline.arithmetics.dual.BigDual
      [ERROR] lower bounds: eu.simuline.arithmetics.dual.BigDual,eu.simuline.arithmetics.dual.BigDecimalFloat
      ```

      but if I try the commented out version, all compiles as a charm.
      I think, there should be no difference.
      Maybe this can be considered a suggestion for enhancement or a bug report.


      REGRESSION : Last worked in version 17.0.10

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a class with the given snipped and try to compile

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect compilation without an error
      ACTUAL -
      compilation error as described above.

      ---------- BEGIN SOURCE ----------
      see above.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Workaround is simple: just use the variant commented out.

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: