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
Can't summon an ArrayTag for a type alias of an Array type #5769
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5769?orig=1 |
@retronym said: |
@xeno-by said: |
@retronym said: |
@xeno-by said: |
@retronym said: |
@retronym said: |
@paulp said: Just to throw some cold water on this: you should not be inspecting typeSymbols directly, that's what leads to all these aliasing bugs; you should definitely be scared to call rawInfo; and when did dealias turn up on Symbol... |
@retronym said: Would |
@retronym said: https://groups.google.com/d/msg/scala-internals/pWNR_Eho4HQ/fn_mMhtmiEgJ |
@paulp said: Here are some things about type aliases. scala> class Foo { type AI = Array[Int] }
defined class Foo
scala> val ai = typeMember(intp.types("Foo"), "AI")
ai: $r.intp.global.Symbol = type AI
scala> ai.info
res0: $r.intp.global.Type = Array[Int]
scala> ai.tpe
res1: $r.intp.global.Type = Foo.this.AI
scala> ai.tpe.typeSymbol
res2: $r.intp.global.Symbol = class Array
scala> ai.tpe.typeSymbolDirect
res3: $r.intp.global.Symbol = type AI
scala> ai.info.typeSymbol
res4: $r.intp.global.Symbol = class Array
scala> ai.info.typeSymbolDirect
res5: $r.intp.global.Symbol = class Array
scala> ai.dealias
res7: $r.intp.global.Symbol = class Array
scala> ai.typeParams
res8: List[$r.intp.global.Symbol] = List()
scala> res7.typeParams
res9: List[$r.intp.global.Symbol] = List(type T) |
@paulp said: |
@paulp said: if (tpe.typeSymbol == ArrayClass) {
val componentTpe = tpe.typeArguments(0) typeSymbol normalizes, but typeArguments doesn't. So it seems to be an Array, but then you take the type arguments from the type alias, and there aren't any. |
@paulp said: |
@xeno-by said: |
@paulp said: |
@paulp said: So if you have type AI = Array[Int] and you call reify with the typeSymbol for AI, then it reifies Array's type constructor. I can't see how that can be right. |
@xeno-by said: (correctness argument) If an underlying type contains spliceable stuff, we need to ensure that we reify spliced version of that type, not just an alias. |
@xeno-by said: |
@xeno-by said: scala> import scala.reflect.mirror._
import scala.reflect.mirror._
scala> type AI = Array[Int]
defined type alias AI
scala> reify{ val x: AI = null }
res0: reflect.mirror.Expr[Unit] =
Expr[Unit]({
val x: Array = null;
()
})
scala> reify { val x: Array[Int] = null }
res1: reflect.mirror.Expr[Unit] =
Expr[Unit]({
val x: Array[Int] = null;
()
}) |
@paulp said: Types are converted to underlying types. That doesn't mean you can do it with bare symbols. |
@paulp said: |
Original report:
http://stackoverflow.com/questions/10488007/toarray-in-scala-2-10-milestone
By contrast, this works:
The text was updated successfully, but these errors were encountered: