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

classOf doesn't work with ClassTags #5722

Closed
scabug opened this issue Apr 30, 2012 · 5 comments
Closed

classOf doesn't work with ClassTags #5722

scabug opened this issue Apr 30, 2012 · 5 comments

Comments

@scabug
Copy link

scabug commented Apr 30, 2012

scala> def foo[T: ClassTag] = println(classOf[T])
<console>:7: error: class type required but T found
       def foo[T: ClassTag] = println(classOf[T])
                                              ^
@scabug
Copy link
Author

scabug commented Apr 30, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5722?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0-M3

@scabug
Copy link
Author

scabug commented May 29, 2012

@adriaanm said:
classOf[C] should be a constant, basically have the same meaning as C.class in Java

@scabug
Copy link
Author

scabug commented Jun 28, 2013

@soc said (edited on Jun 28, 2013 6:07:09 PM UTC):
I'm not sure whether this can be called a bug or a missing feature, but I'd like to get this fixed in the long-term.

If you provide a tag for new Array[T], it works. I think it is reasonable to expect the same for classOf[T].

Maybe a future me is experienced enough to tackle this.

Mailing list: https://groups.google.com/d/topic/scala-internals/-IFwlFk6Btc/discussion

@scabug
Copy link
Author

scabug commented Nov 21, 2013

@retronym said:
That thread doesn't convince me that this should have been reopened. classOf has a very specific meaning in Scala as is does in Java, it is our class literal.

@scabug scabug closed this as completed Nov 21, 2013
@scabug
Copy link
Author

scabug commented Nov 21, 2013

@soc said:
Not trying to be nitpicky, but this reasoning is inconsistent with other things which also have a special meaning in Scala/Java. By that logic, we would need to throw out new Array[T], too, regardless of ClassTags in scope.

You can just assign it to me, if I have time I'll look into it again.

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