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

Invalid type error in nested pattern match with existentials

    Details

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

      Description

      class Base[T] {
        def set(t: T): Unit = ()
      }
      class Inter[T] extends Base[T]
      class Concrete extends Inter[List[String]]
       
      object Fail {
        val r: Base[_] = new Concrete
        r match {
          case i: Inter[_] =>
            i match {
              case c: Concrete =>
                c.set(Nil)
            }
        }
      }
      

      Result:

      Error:(16, 17) type mismatch;
       found   : scala.collection.immutable.Nil.type
       required: _1
                c.set(Nil)
                      ^
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ghik Roman Janusz
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: