Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression in extractors with existential-returning unapply/unapplySeq #8128

Closed
scabug opened this issue Jan 9, 2014 · 5 comments
Closed

Comments

@scabug
Copy link

scabug commented Jan 9, 2014

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 {
           ^
@scabug
Copy link
Author

scabug commented Jan 9, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8128?orig=1
Reporter: @retronym
Affected Versions: 2.11.0-M7

@scabug
Copy link
Author

scabug commented Jan 9, 2014

@retronym said (edited on Jan 9, 2014 8:57:40 AM UTC):
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

@scabug
Copy link
Author

scabug commented Jan 9, 2014

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

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

@scabug
Copy link
Author

scabug commented Jan 14, 2014

@adriaanm said:
scala/scala#3275

@scabug scabug closed this as completed Jan 14, 2014
@scabug
Copy link
Author

scabug commented Jan 14, 2014

@retronym said:
The residual issue is now tracked as #8149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants