scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

2.12 Regression: covariant type alias can't be used as type ctor param #10168

Closed scabug closed 7 years ago

scabug commented 7 years ago

The attached file compiles fine with 2.11.8 but results in 4 errors using 2.12.0 and 2.12.1:

[error] /home/golly/crap/bug212/Blah.scala:8: covariant type Id occurs in invariant position in supertype Blah.X[Blah.WithIdTypeAlias.Id] of object Y1
[error]     object Y1 extends X[Id]   // FAILURE
[error]            ^
[error] /home/golly/crap/bug212/Blah.scala:9: covariant type Id occurs in invariant position in type => Blah.X[Blah.WithIdTypeAlias.Id] of value Y2
[error]     val Y2 = new X[Id]        // FAILURE
[error]         ^
[error] /home/golly/crap/bug212/Blah.scala:10: covariant type Id occurs in invariant position in type => Blah.X[Blah.WithIdTypeAlias.Id] of method Y3
[error]     def Y3 = new X[Id]        // FAILURE
[error]         ^
[error] /home/golly/crap/bug212/Blah.scala:13: covariant type Id occurs in invariant position in type => Blah.X[Blah.WithIdTypeAlias.Id] of method EX
[error]     def EX: X[Id] = new X[Id] // FAILURE
[error]         ^
[error] four errors found

WithIdClass is a copy-paste of WithIdTypeAlias with only the Id definition changed. When Id is a class and not a type alias, it compiles without error in 2.12.x.

scabug commented 7 years ago

Imported From: https://issues.scala-lang.org/browse/SI-10168?orig=1 Reporter: David Barri (japgolly) Affected Versions: 2.12.0, 2.12.1 See #10140 Attachments:

scabug commented 7 years ago

David Barri (japgolly) said: Hello. This regression prevents me from releasing the upcoming redesign of scalajs-react for Scala 2.12. I'd really, really like to get it fixed in 2.12.2. Is there anything I can do to help that happen?

scabug commented 7 years ago

@SethTisue said: this is a duplicate of #10140, isn't it?

scabug commented 7 years ago

David Barri (japgolly) said: Oh well spotted, I missed that. Yes it is!

It also provides a simple workaround by moving the type alias out into its own class/trait. Fantastic! Urgency *= 0.1. Thank you.

I'll close this now.