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

explicit declaration of return type with compound type parameter fails

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      From StackOverflow: http://stackoverflow.com/questions/17559687/compile-time-constraints-on-the-order-of-function-composition-in-scala

      Compilation fails for a method that explicitly declares a return a type with a compound type parameter, but succeeds and infers the same type when the return type is not explicitly declared:

      scala> trait Foo[A] { def bar[B](b: B): Foo[A with B] }
      defined trait Foo
       
      scala> def baz[A](foo: Foo[A]) = foo bar 1
      baz: [A](foo: Foo[A])Foo[A with Int]
       
      scala> def baz[A](foo: Foo[A]): Foo[A with Int] = foo bar 1
      <console>:8: error: type mismatch;
       found   : Int(1)
       required: Nothing
             def baz[A](foo: Foo[A]): Foo[A with Int] = foo bar 1
                                                                ^
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            bethard
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development