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

ClassTag of an existential value class type creates wrong array #8260

Closed
scabug opened this issue Feb 11, 2014 · 2 comments
Closed

ClassTag of an existential value class type creates wrong array #8260

scabug opened this issue Feb 11, 2014 · 2 comments
Milestone

Comments

@scabug
Copy link

scabug commented Feb 11, 2014

Consider the following:

import scala.reflect._
class Param[T](val x: String) extends AnyVal
val x = classTag[Param[_]].newArray(10)
x(0) = new Param[Int]("foo")
// java.lang.ClassCastException: Param cannot be cast to java.lang.String

This shouldn't throw a ClassCastException. The issue is caused by the fact that classTag[Param\[_]] gives a ClassTag of String.

Strangely, the test run/valueclasses-classtag-existential does specifically check for this behavior.

Note that classTag[Param[X]] where X is some class, gives a ClassTag of Param (tested in run/valueclasses-classtag-generic). So this happens only with existential types.

@scabug
Copy link
Author

scabug commented Feb 11, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8260?orig=1
Reporter: @gzm0
Affected Versions: 2.10.2, 2.11.0-M7
See #7375

@scabug
Copy link
Author

scabug commented Feb 11, 2014

@retronym said:
See also: #7375

@SethTisue SethTisue modified the milestones: 2.12.19, 2.12.5 Jul 19, 2023
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