Scala Programming Language
  1. Scala Programming Language
  2. SI-7441

spurious warning on implicit definition being not applicable

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      object Test {
        object Bar {
          def apply(xs: List[Any]): Int = 0
          def test = apply(1)
        } 
        implicit def foo = 1
      }
      

      produces:

       found   : Int(1)
       required: List[Any]
       Note: implicit method foo is not applicable here because it comes after the application point and it lacks an explicit result type
          def test = apply(1)
                           ^
      one error found
      

      which is annoying and confusing. Maybe before producing the addendum we could force the completer and really check which of the implicits could be useful in that position?
      Probably related to SI-5265.

        Issue Links

          Activity

          Show
          Paul Phillips added a comment - https://github.com/scala/scala/pull/2488
          Hide
          Hubert Plociniczak added a comment -
          Show
          Hubert Plociniczak added a comment - and related: https://github.com/scala/scala/pull/2547
          Hide
          Jason Zaugg added a comment -

          Reverted due to SI-7486. Reopening.

          We might be able to exclude implicits like:

          def a2b(a: A) = <expr>
          

          by approximating the type as A => ?. and seeing if that is applicable. But we can never force the return type.

          Show
          Jason Zaugg added a comment - Reverted due to SI-7486 . Reopening. We might be able to exclude implicits like: def a2b(a: A) = <expr> by approximating the type as A => ? . and seeing if that is applicable. But we can never force the return type.
          Hide
          Hubert Plociniczak added a comment -

          Ah, thanks. Sorry for the confusion.

          Show
          Hubert Plociniczak added a comment - Ah, thanks. Sorry for the confusion.
          Hide
          Jason Zaugg added a comment -

          I'm declaring this one unfixable. I think the best way forward would be to deprecated return type inference for implicits. That's currently not possible for implicit objects and classes, though.

          Show
          Jason Zaugg added a comment - I'm declaring this one unfixable. I think the best way forward would be to deprecated return type inference for implicits. That's currently not possible for implicit objects and classes, though.

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Hubert Plociniczak
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development