Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5585

uniform inference for expression and valdef when existentials are involved

    Details

      Description

      class Result[+A]
       
      case class Success[A](x: A) extends Result[A]
       
      class Apply[A]
       
      object Apply {
        def apply[A](f: Int => Result[A]): Apply[A] = new Apply[A]
      }
       
      object TestUnit {
        def goo : Apply[Option[Int]] = Apply { i =>
          /* val p = */i match {
            case 1 => Success(Some(1))
            case _ => Success(None)
          }
          //p
        }
      }
      

      This code compiles wуll. However with uncommented it fails. I checked all generics under the clojure are inferred in the same way. So I can't explain this different behavior.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                moors Adriaan Moors
                Reporter:
                alefas Alexander
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated: