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

ClassManifest.typeArguments returns empty list on array manifests #3758

Closed
scabug opened this issue Aug 13, 2010 · 3 comments
Closed

ClassManifest.typeArguments returns empty list on array manifests #3758

scabug opened this issue Aug 13, 2010 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Aug 13, 2010

I was told on the mailing list this is a bug so I'll just copy and paste from there (see below). I was using Scala 2.8.0 Final.


I was hoping to retrieve the manifest of an array's element type like so:

scala> manifest[Array[Double]].typeArguments

This returns an empty list. Looking at the Manifest.arrayManifest method, I see that it is implemented as

override def arrayManifest: Manifest[Array[T]] =
    Manifest.classType[Array[T]](arrayClass[T](erasure))

This explains why the above retuns Nil but it looks like implementing it as

  override def arrayManifest: Manifest[Array[T]] =
    Manifest.classType[Array[T]](arrayClass[T](erasure), this)

would solve the problem.

@scabug
Copy link
Author

scabug commented Aug 13, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3758?orig=1
Reporter: Stefan Weber (weberste)

@scabug
Copy link
Author

scabug commented Aug 15, 2010

@paulp said:
After looking at it I'm not sure it's a bug, or at least not sure it's not intentional. I would agree it's undesirable, and one ought to be able to retrieve type arguments without having to special case arrays. The reasoning for the current approach would be that with Arrays the type argument is "built in" to the top level manifest, so you don't actually have type arguments: i.e. Array[Int] has a first-class runtime representation, unlike List[Int]. Code like this is what shows us the author was well aware there were no type args on arrays:

protected def argString = 
  if (typeArguments.nonEmpty) typeArguments.mkString("[", ", ", "]")
  else if (erasure.isArray) "["+ClassManifest.fromClass(erasure.getComponentType)+"]"
  else ""  

So I won't touch this pending feedback. (The suggested patch does have the intended effect.)

@scabug
Copy link
Author

scabug commented Jan 7, 2012

@paulp said:
27d19715af

@scabug scabug closed this as completed Jan 7, 2012
@scabug scabug added the critical label Apr 7, 2017
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants