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

Weird lazy val type inference in anonymous function

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1
    • Fix Version/s: None
    • Component/s: Type Inference
    • Labels:
    • Environment:

      2.9.1

      Description

      In the following, return type is inferred as (=> a).
      Is this the right behavior?

      class LazyValVsFunctionType[a]  {
          val f: a => a = x => {
              lazy val _x: a = throw new java.lang.Error("todo")
              _x // error: type mismatch
      /*
      [error]  found   : a => => a
      [error]  required: a => a
      [error]     val f: a => a = x => {
      [error]                       ^
      [error] one error found
      */
              // _x: a // ok
          }
      }
      

        Activity

        Hide
        Commit Message Bot added a comment -

        (extempore in r25916) Clean result of function type.

        NullaryMethodType was escaping. Closes SI-5099, review by moors.

        Show
        Commit Message Bot added a comment - (extempore in r25916 ) Clean result of function type. NullaryMethodType was escaping. Closes SI-5099 , review by moors.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Shunsuke Sogame
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development