Skip to content

Commit 5e938dc

Browse files
committed
Check for @specialized(AnyRef)based on symbols
instead of `Name`s
1 parent 2e582a8 commit 5e938dc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/dotty/tools/dotc/transform/PreSpecializer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dotty.tools.dotc.core.{Flags, Definitions}
99
import dotty.tools.dotc.core.Symbols.Symbol
1010
import dotty.tools.dotc.core.Types.{TermRef, Type}
1111
import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, MiniPhaseTransform}
12+
import dotty.tools.dotc.core.Decorators._
1213

1314
/**
1415
* This phase retrieves all `@specialized` anotations before they are thrown away,
@@ -19,7 +20,7 @@ class PreSpecializer extends MiniPhaseTransform {
1920
override def phaseName: String = "prespecialize"
2021

2122
private final def primitiveCompanionToPrimitive(companion: Type)(implicit ctx: Context) = {
22-
if (companion.asInstanceOf[TermRef].name.toString == "AnyRef") { // Handles `@specialized(AnyRef)` cases
23+
if (companion.termSymbol eq ctx.requiredModule("scala.package").info.member("AnyRef".toTermName).symbol) { // Handles `@specialized(AnyRef)` cases
2324
defn.AnyRefType
2425
}
2526
else {
@@ -53,7 +54,7 @@ class PreSpecializer extends MiniPhaseTransform {
5354
}
5455

5556
if (allowedToSpecialize(sym)) {
56-
val annotation = sym.denot.getAnnotation(defn.specializedAnnot).getOrElse(Nil)
57+
val annotation = sym.denot.getAnnotation(defn.SpecializedAnnot).getOrElse(Nil)
5758
annotation match {
5859
case annot: Annotation =>
5960
val args = annot.arguments

0 commit comments

Comments
 (0)