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

require explicit result type for implicit conversions?

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Specification
    • Labels:
      None

      Description

      Martin wrote on the scala-user list, "In general it's a good idea always to write a result type for an implicit method. Maybe the language should require it."

      I've been bitten myself a couple times by problems that went away once I added a result type to an implicit so I thought I'd open a ticket on this.

        Issue Links

          Activity

          Hide
          mcdirmid added a comment -

          We should disallow type annotations on implicit defs to prevent vicious implicit recursive applications. Actually, I follow this rule in my own code when possible, its saved me more than a few times.

          Show
          mcdirmid added a comment - We should disallow type annotations on implicit defs to prevent vicious implicit recursive applications. Actually, I follow this rule in my own code when possible, its saved me more than a few times.
          Hide
          Gilles Dubochet added a comment -

          Sean, can you please elaborate on your contribution a little?

          Show
          Gilles Dubochet added a comment - Sean, can you please elaborate on your contribution a little?
          Hide
          Martin Odersky added a comment -

          I have implemented a slightly more permissive rule: An implicit conversion without explicit result type is visible only in the text following its own definition. That way, we avoid the cyclic reference errors. I close for now, to see how this works. If we still have issues we migth come back to this.

          Show
          Martin Odersky added a comment - I have implemented a slightly more permissive rule: An implicit conversion without explicit result type is visible only in the text following its own definition. That way, we avoid the cyclic reference errors. I close for now, to see how this works. If we still have issues we migth come back to this.
          Hide
          Martin Odersky added a comment -

          Milestone next_bugfix deleted

          Show
          Martin Odersky added a comment - Milestone next_bugfix deleted
          Hide
          Paul Phillips added a comment -

          See also SI-2206. Explanatory error message fixed so it will print in r21706.

          Show
          Paul Phillips added a comment - See also SI-2206 . Explanatory error message fixed so it will print in r21706.

            People

            • Assignee:
              mcdirmid
              Reporter:
              Seth Tisue
              TracCC:
              Paul Phillips
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development