Skip to content

Commit c647d6b

Browse files
committed
cache lookup of any2stringaddMethod
`any2stringadd` is an implicit class, and the implicit class creates a factory method `def any2stringadd[A](a: A)` and since it's a SIP-15 value class there's a companion named `any2stringadd` too!
1 parent cee2d4e commit c647d6b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ trait Contexts { self: Analyzer =>
856856
!({
857857
// [eed3si9n] ideally I'd like to do this: val fd = settings.isScala214 && sym.isDeprecated
858858
// but implicit caching currently does not report sym.isDeprecated correctly.
859-
val fd = settings.isScala214 && (name ne null) && definitions.isPredefMemberNamed(sym, TermName("any2stringadd"))
859+
val fd = settings.isScala214 && (sym == currentRun.runDefinitions.Predef_any2stringaddMethod)
860860
if (settings.XlogImplicits && fd) echo(sym.pos, sym + " is not a valid implicit value because:\n" + "-Xsource:2.14 removes scala.Predef.any2stringadd")
861861
fd
862862
}) &&

src/reflect/scala/reflect/internal/Definitions.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ trait Definitions extends api.StandardDefinitions {
15041504
lazy val Predef_classOf = getMemberMethod(PredefModule, nme.classOf)
15051505
lazy val Predef_implicitly = getMemberMethod(PredefModule, nme.implicitly)
15061506
lazy val Predef_??? = DefinitionsClass.this.Predef_???
1507+
lazy val Predef_any2stringaddMethod = PredefModule.info.decl(nme.any2stringadd.toTermName).suchThat(_.isMethod)
15071508

15081509
lazy val arrayApplyMethod = getMemberMethod(ScalaRunTimeModule, nme.array_apply)
15091510
lazy val arrayUpdateMethod = getMemberMethod(ScalaRunTimeModule, nme.array_update)

src/reflect/scala/reflect/internal/StdNames.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ trait StdNames {
491491
if (isConstructorName(name))
492492
DEFAULT_GETTER_INIT_STRING + pos
493493
else
494-
name + DEFAULT_GETTER_STRING + pos
494+
name.toString + DEFAULT_GETTER_STRING + pos
495495
)
496496
// Nominally, name from name$default$N, CONSTRUCTOR for <init>
497497
def defaultGetterToMethod(name: Name): TermName = (
@@ -654,6 +654,7 @@ trait StdNames {
654654
val accessor: NameType = "accessor"
655655
val add_ : NameType = "add"
656656
val annotation: NameType = "annotation"
657+
val any2stringadd: NameType = "any2stringadd"
657658
val anyHash: NameType = "anyHash"
658659
val anyValClass: NameType = "anyValClass"
659660
val apply: NameType = "apply"

0 commit comments

Comments
 (0)