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

Covariant tparam appearing multiple times receives wrong inferred type in patmat RHS #8962

Closed
scabug opened this issue Nov 5, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Nov 5, 2014

In the following code, which compiles successfully in 2.11.2 but not in 2.11.4, the definitions run2 and run3 fail to compile with the type errors that follow.

package test.nestedcov

sealed abstract class Outer[+A]
case class Let[+A](expr: Outer[Inner[A]]) extends Outer[A]

sealed abstract class Inner[+A]

sealed abstract class Outer2[+A, +B]
case class Let2[+A](expr: Outer2[Inner2[A], A]) extends Outer2[A, A]

sealed abstract class Inner2[+A]

sealed abstract class Outer3[+A, +B]
case class Let3[+A](expr: Outer3[A, A]) extends Outer3[A, A]

object NestedCov {
  def run[A](nc: Outer[A]) = nc match {
    case Let(expr) =>
      expr : Outer[Inner[A]]
  }

  def run2[A](nc: Outer2[A, A]) = nc match {
    case Let2(expr) =>
      expr : Outer2[Inner2[A], A]
  }

  def run3[A](nc: Outer3[A, A]) = nc match {
    case Let3(expr) =>
      expr : Outer3[A, A]
  }
}

Failing with

NestedCov.scala:22: error during expansion of this match (this is a scalac bug).
The underlying error was: type mismatch;
 found   : test.nestedcov.Outer2[test.nestedcov.Inner2[A with A],A with A]
 required: test.nestedcov.Outer2[test.nestedcov.Inner2[?A3 with ?A2],?A3 with ?A2] where type ?A2 <: A (this is a GADT skolem), type ?A3 <: A (this is a GADT skolem)
  def run2[A](nc: Outer2[A, A]) = nc match {
                                     ^
NestedCov.scala:27: error during expansion of this match (this is a scalac bug).
The underlying error was: type mismatch;
 found   : test.nestedcov.Outer3[A with A,A with A]
 required: test.nestedcov.Outer3[?A5 with ?A4,?A5 with ?A4] where type ?A4 <: A (this is a GADT skolem), type ?A5 <: A (this is a GADT skolem)
  def run3[A](nc: Outer3[A, A]) = nc match {
                                     ^
two errors found
@scabug
Copy link
Author

scabug commented Nov 5, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8962?orig=1
Reporter: Stephen Compall (s11001001)
Affected Versions: 2.11.4

@scabug
Copy link
Author

scabug commented Nov 5, 2014

Stephen Compall (s11001001) said:
This was discovered while compiling expressions like these, analogous to the ascriptions of expr above, in matches on LetR and similar classes, analogous to Let2 above, in the Scala Ermine implementation.

@scabug
Copy link
Author

scabug commented Nov 6, 2014

@retronym said:
Seems to have regressed in the refactoring of error reporting: scala/scala@258d95c

%  scalac-hash 258d95c7b1528a84514a6a609a356be840322e9b~1 -Ytyper-debug sandbox/test.scala 2>&1 | tee sandbox/good.log
%  scalac-hash 258d95c7b1528a84514a6a609a356be840322e9b -Ytyper-debug sandbox/test.scala 2>&1 | tee sandbox/bad.log
%  diff -U100 sandbox/{good,bad}.log | gist --filename=SI-8962-typer-log.diff

https://gist.github.com/retronym/3ccbe7e0791447d272a6

@scabug
Copy link
Author

scabug commented Nov 6, 2014

@retronym said:
I've pinpointed the regression, and have a fix in the works: https://github.com/retronym/scala/tree/ticket/8962.

Thanks for the bug report! If you wish, you could submit ermine-core-scala to our community build so that it would be automatically part of our regression tests. https://github.com/scala/community-builds/pulls

@scabug
Copy link
Author

scabug commented Nov 6, 2014

@retronym said:
scala/scala#4094

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