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

Improve error message when lambda is missing a return value

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE REQUEST :
      Currently if a user provides a lambda that does not have a return value when one is expected gets this kind of error message:

        required: java.util.function.Function<? super java.util.List<Key, Value>,? extends U>
        found: (currencyP[...]}); }
        reason: cannot infer type-variable(s) U
          (argument mismatch; bad return type in lambda expression
            missing return value)

      You are essentially burying the lead. Please don't make users read through multiple lines of ugly Generics code when they don't have to.

      The error message should read something along the lines of:

      Expected a return value but none was found.
      required : X
      found: Y
      reason: Z

      JUSTIFICATION :
      Improve readability, ease of debugging


            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: