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

Standard inheritance pattern with specialization yields compiler crash #4790

Open
scabug opened this issue Jul 11, 2011 · 3 comments
Open

Standard inheritance pattern with specialization yields compiler crash #4790

scabug opened this issue Jul 11, 2011 · 3 comments

Comments

@scabug
Copy link

scabug commented Jul 11, 2011

This code crashes the compiler (after complaining that Sp must be a trait):

package spectest {
  class Sp[@specialized A, B](val a: A, val b: B) { }
  class Fsp[@specialized A, B](a: A, b: B) extends Sp(a,b) {
    def ab = (a,b)
  }
}

Error message from r25234 is:

SpecTest.scala:3: warning: class Sp must be a trait. Specialized version of class Fsp will inherit generic spectest.Sp[Unit,B]
  class Fsp[@specialized A, B](a: A, b: B) extends Sp(a,b) {
        ^
error: java.lang.AssertionError: assertion failed: List(value a, value a)
	at scala.reflect.internal.Symbols$Symbol.suchThat(Symbols.scala:1154)
	at scala.reflect.internal.Types$class.rebind(Types.scala:2679)
	at scala.reflect.internal.Types$class.singleType(Types.scala:2704)
	at scala.reflect.internal.SymbolTable.singleType(SymbolTable.scala:11)
	at scala.tools.nsc.typechecker.Typers$Typer.stabilizeFun(Typers.scala:592)
	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:3359)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4107)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4274)
	at scala.tools.nsc.typechecker.Duplicators$BodyDuplicator.typed(Duplicators.scala:310)

...
@scabug
Copy link
Author

scabug commented Jul 11, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4790?orig=1
Reporter: @Ichoran
Affected Versions: 2.8.1, 2.9.0, 2.9.1, 2.11.0-M8

@scabug
Copy link
Author

scabug commented May 12, 2012

@retronym said:
No doubt obvious to the reporter, but for the record: You can pick different names for the constructor paramaters to work around this.

scala> class Fsp[@specialized A, B](aa: A, bb: B) extends Sp(aa,bb) { def foo = (aa, bb) }
<console>:8: warning: class Sp must be a trait. Specialized version of class Fsp will inherit generic Sp[Boolean,B]
       class Fsp[@specialized A, B](aa: A, bb: B) extends Sp(aa,bb) { def foo = (aa, bb) }
             ^

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

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

1 participant