Skip to content
Permalink
Browse files

Fix for aliasing bug in reifier.

Closes SI-5769.
  • Loading branch information
paulp committed May 8, 2012
1 parent e982596 commit 8e88e5b214ab365a268ab6bd6e53c4aa657ec5d0
Showing with 18 additions and 9 deletions.
  1. +10 −9 src/compiler/scala/reflect/reify/package.scala
  2. +8 −0 test/files/pos/t5769.scala
@@ -43,15 +43,16 @@ package object reify {
case (_, success) if !success.isEmpty =>
gen.mkMethodCall(arrayElementClassMethod, List(success))
case _ =>
if (tpe.typeSymbol == ArrayClass) {
val componentTpe = tpe.typeArguments(0)
val componentErasure = reifyErasure(global)(typer0, componentTpe, concrete)
gen.mkMethodCall(arrayClassMethod, List(componentErasure))
} else {
if (tpe.isSpliceable && concrete) throw new ReificationError(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
var erasure = tpe.erasure
if (tpe.typeSymbol.isDerivedValueClass && global.phase.id < global.currentRun.erasurePhase.id) erasure = tpe
gen.mkNullaryCall(Predef_classOf, List(erasure))
tpe.normalize match {

This comment has been minimized.

Copy link
@xeno-by

xeno-by May 8, 2012

Member

Why normalize, but not dealias. Does it make any difference in this case?

This comment has been minimized.

Copy link
@paulp

paulp May 8, 2012

Author Contributor

It won't make any difference here I don't think; I call normalize habitually. Dealias is probably better.

case TypeRef(_, ArrayClass, componentTpe :: Nil) =>
val componentErasure = reifyErasure(global)(typer0, componentTpe, concrete)
gen.mkMethodCall(arrayClassMethod, List(componentErasure))
case _ =>
if (tpe.isSpliceable && concrete)
throw new ReificationError(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
var erasure = tpe.erasure
if (tpe.typeSymbol.isDerivedValueClass && global.phase.id < global.currentRun.erasurePhase.id) erasure = tpe
gen.mkNullaryCall(Predef_classOf, List(erasure))
}
}
}
@@ -0,0 +1,8 @@
// a.scala

class A {
type AI = Array[Int]

def f1 = arrayTag[Array[Int]]
def f2 = arrayTag[AI]
}

0 comments on commit 8e88e5b

Please sign in to comment.
You can’t perform that action at this time.