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

some methods of Symbol don't work correctly unless the symbol is initialized #6277

Closed
scabug opened this issue Aug 23, 2012 · 13 comments
Closed

Comments

@scabug
Copy link

scabug commented Aug 23, 2012

It seems isSealed is not working at runtime. At least, it doesn't work for List:

Welcome to Scala version 2.11.0-20120808-025516-c0d5f0aadd (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import reflect.runtime.universe._
import reflect.runtime.universe._

scala> typeOf[List]
<console>:11: error: type List takes type parameters
              typeOf[List]
                     ^

scala> typeOf[List[_]]
res1: reflect.runtime.universe.Type = scala.List[_]

scala> res1.type
typeConstructor   typeSymbol        

scala> res1.typeSymbol
res2: reflect.runtime.universe.Symbol = class List

scala> res2.asClass
res3: reflect.runtime.universe.ClassSymbol = class List

scala> res3.isSealed
res4: Boolean = false

upd. This also plagues annotation-getting methods as described in #6428. In the interest of full disclosure, I should mention that privateWithin is also affected.

@scabug
Copy link
Author

scabug commented Aug 23, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6277?orig=1
Reporter: @dcsobral
Affected Versions: 2.10.0-M6, 2.10.0-M7, 2.10.0
Other Milestones: 2.10.0

@scabug
Copy link
Author

scabug commented Aug 23, 2012

@paulp said:
I don't know how to deliver this bit of news, other than to say that I hope you're impressed at the few things we do manage to fix in such a hostile environment. That we are on the verge of exporting this behavior into userland is not something I can bear to consider.

scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._

scala> val sym = typeOf[scala.collection.immutable.List[_]].typeSymbol.asClass
sym: reflect.runtime.universe.ClassSymbol = class List

scala> sym.isSealed
res0: Boolean = false

scala> { sym.typeSignature ; () }

scala> sym.isSealed
res2: Boolean = true

@scabug
Copy link
Author

scabug commented Aug 23, 2012

@dcsobral said:
And here was I saying Symbols were immutable at runtime (despite your presentation -- Eugene was very emphatic on them being immutable at runtime, when he reviewed my blog post saying otherwise).

Other than that, I've been impressed for a long time, and I think you understate the case when you say "few".

@scabug
Copy link
Author

scabug commented Aug 24, 2012

@odersky said:
I think this is important to fix before 2.10 RC1: Any flags tests need to make sure the symbol is fully loaded when called from reflection, and the flags method needs to do the same. However, in the compiler we must not change behavior. Maybe this means we need to find different names for the exposed flag testing methods.

@scabug
Copy link
Author

scabug commented Aug 24, 2012

@xeno-by said:
Okay I'm on it. Sorry for neglecting this issue yesterday - I'm in the middle of an exam prep. Also Daniel I'm sorry about misinforming you.

@scabug
Copy link
Author

scabug commented Aug 24, 2012

@xeno-by said:
@odersky. I suggest we mix the auto-initialization logic into runtime reflection Symbols in the same way we mix in SynchronizedSymbol. This way we'll also get rid of the ugliness of the annotation/getAnnotation dilemma.

@scabug
Copy link
Author

scabug commented Aug 28, 2012

@heathermiller said:
Scala core meeting consensus: go with Eugene's suggestion

@scabug
Copy link
Author

scabug commented Aug 28, 2012

@odersky said:
@xeno.by yes, I think this is the way to go. Can you do it?

@scabug
Copy link
Author

scabug commented Aug 28, 2012

@xeno-by said:
Sure, I will submit a pull request within a week.

@scabug
Copy link
Author

scabug commented Sep 6, 2012

@xeno-by said:
scala/scala#1264

@scabug
Copy link
Author

scabug commented Sep 20, 2012

@jsuereth said:
pull request was dropped.

@scabug
Copy link
Author

scabug commented Sep 22, 2012

@xeno-by said:
scala/scala#1380

@scabug
Copy link
Author

scabug commented Sep 26, 2012

@xeno-by said:
scala/scala@2fb507b

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