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

regression in extractors with existential-returning unapply/unapplySeq

    Details

      Description

      cat test/files/pos/patmat-existential.scala
      object G {
        def unapply(m: Any): Option[_] = Some("")
      }
      
      object H {
        def unapplySeq(m: Any): Option[Seq[_]] = None
      }
      
      object Test {
        (0: Any) match {
          case G(v) => v
          case H(v) => v
          case _ =>
        }
      }
      

      The two patterns above result in:

      qbin/scalac test/files/pos/patmat-existential.scala
      test/files/pos/patmat-existential.scala:10: error: error during expansion of this match (this is a scalac bug).
      The underlying error was: type mismatch;
       found   : _$2(in value <local Test>) where type _$2(in value <local Test>)
       required: _$2(in method unapplySeq)
        (0: Any) match {
                 ^
      one error found
      pr/3275 /code/scala qbin/scalac test/files/pos/patmat-existential.scala
      test/files/pos/patmat-existential.scala:10: error: error during expansion of this match (this is a scalac bug).
      The underlying error was: type mismatch;
       found   : _$1(in value <local Test>) where type _$1(in value <local Test>)
       required: _$1(in method unapply)
        (0: Any) match {
                 ^
      

        Issue Links

          Activity

          Hide
          Jason Zaugg added a comment - - edited

          The regression boils down to:

          scala> class F[_]
          defined class F
          
          scala> val tp = typeOf[Some[F[X]] forSome { type X }]
          warning: there were 1 feature warning(s); re-run with -feature for details
          tp: $r.intp.global.Type = scala.this.Some[F[X]] forSome { type X }
          
          scala> tp.baseType(typeOf[Option[_]].typeSymbol).typeArgs.head
          res10: $r.intp.global.Type = F[X] forSome { type X }
          
          scala> tp.memberType(tp.member(nme.get)).finalResultType
          res11: $r.intp.global.Type = F[X]
          

          The last line is what happens now in `resultOfMatchingMethod`.

          This is support ticket #3045

          Show
          Jason Zaugg added a comment - - edited The regression boils down to: scala> class F[_] defined class F scala> val tp = typeOf[Some[F[X]] forSome { type X }] warning: there were 1 feature warning(s); re-run with -feature for details tp: $r.intp.global.Type = scala.this.Some[F[X]] forSome { type X } scala> tp.baseType(typeOf[Option[_]].typeSymbol).typeArgs.head res10: $r.intp.global.Type = F[X] forSome { type X } scala> tp.memberType(tp.member(nme.get)).finalResultType res11: $r.intp.global.Type = F[X] The last line is what happens now in `resultOfMatchingMethod`. This is support ticket #3045
          Hide
          Jason Zaugg added a comment -

          This fixed the regression, but existentials in name-based extractors will still cause problems.

          https://github.com/paulp/scala/pull/13

          Show
          Jason Zaugg added a comment - This fixed the regression, but existentials in name-based extractors will still cause problems. https://github.com/paulp/scala/pull/13
          Show
          Adriaan Moors added a comment - https://github.com/scala/scala/pull/3275
          Hide
          Jason Zaugg added a comment -

          The residual issue is now tracked as SI-8149

          Show
          Jason Zaugg added a comment - The residual issue is now tracked as SI-8149

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Jason Zaugg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development