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

Specialized classes can't inherit from specialized classes #8405

Open
scabug opened this issue Mar 12, 2014 · 4 comments
Open

Specialized classes can't inherit from specialized classes #8405

scabug opened this issue Mar 12, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Mar 12, 2014

Elephant in the room. Nobody says anything about it, it's not even on the tracker:

$ cat C.scala
class C[@specialized T](t: T)
class D[@specialized T](t: T) extends C[T](t)
 
$ scalac C.scala
C.scala:2: warning: class C must be a trait. Specialized version of class D will inherit generic C[Boolean]
class D[@specialized T](t: T) extends C[T](t)
^
one warning found
 
$ cat D.scala
object Test extends App {
val x=new D(3)
println(x.getClass)
println(x.getClass.getSuperclass)
println(x.getClass.getSuperclass.getSuperclass)
}
 
$ scalac D.scala
$ scala Test
class D$mcI$sp
class D
class C

It will probably be closed with "Won't Fix", as it's a conscious decision in specialization. Still it's good to have a bug to refer to.

@scabug
Copy link
Author

scabug commented Mar 12, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8405?orig=1
Reporter: @VladUreche
Affected Versions: 2.11.0-RC1

@scabug
Copy link
Author

scabug commented Mar 12, 2014

@adriaanm said:
It would be nice to generate a warning/error.

@scabug
Copy link
Author

scabug commented Mar 13, 2014

@VladUreche said:
It does generate a warning, although it's hard to make sense of it without understanding the transformation:

C.scala:2: warning: class C must be a trait. Specialized version of class D will inherit generic C[Boolean]
class D[@specialized T](t: T) extends C[T](t)
^
one warning found

@scabug
Copy link
Author

scabug commented Jan 3, 2017

Jakub Liska (lisak) said:
I don't get this, what is the consequence of doing that as to primitive value boxing?

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