Skip to content

Commit

Permalink
cache lookup of any2stringaddMethod
Browse files Browse the repository at this point in the history
`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!
  • Loading branch information
eed3si9n authored and lrytz committed Jun 4, 2018
1 parent 82a8b68 commit a9d5d38
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ trait Contexts { self: Analyzer =>
!({
// [eed3si9n] ideally I'd like to do this: val fd = settings.isScala214 && sym.isDeprecated
// but implicit caching currently does not report sym.isDeprecated correctly.
val fd = settings.isScala214 && (name ne null) && definitions.isPredefMemberNamed(sym, TermName("any2stringadd"))
val fd = settings.isScala214 && (sym == currentRun.runDefinitions.Predef_any2stringaddMethod)
if (settings.XlogImplicits && fd) echo(sym.pos, sym + " is not a valid implicit value because:\n" + "-Xsource:2.14 removes scala.Predef.any2stringadd")
fd
}) &&
Expand Down
1 change: 1 addition & 0 deletions src/reflect/scala/reflect/internal/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,7 @@ trait Definitions extends api.StandardDefinitions {
lazy val Predef_classOf = getMemberMethod(PredefModule, nme.classOf)
lazy val Predef_implicitly = getMemberMethod(PredefModule, nme.implicitly)
lazy val Predef_??? = DefinitionsClass.this.Predef_???
lazy val Predef_any2stringaddMethod = getMemberMethod(PredefModule, nme.any2stringadd).suchThat(_.isMethod)

lazy val arrayApplyMethod = getMemberMethod(ScalaRunTimeModule, nme.array_apply)
lazy val arrayUpdateMethod = getMemberMethod(ScalaRunTimeModule, nme.array_update)
Expand Down
3 changes: 2 additions & 1 deletion src/reflect/scala/reflect/internal/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ trait StdNames {
if (isConstructorName(name))
DEFAULT_GETTER_INIT_STRING + pos
else
name + DEFAULT_GETTER_STRING + pos
name.toString + DEFAULT_GETTER_STRING + pos
)
// Nominally, name from name$default$N, CONSTRUCTOR for <init>
def defaultGetterToMethod(name: Name): TermName = (
Expand Down Expand Up @@ -654,6 +654,7 @@ trait StdNames {
val accessor: NameType = "accessor"
val add_ : NameType = "add"
val annotation: NameType = "annotation"
val any2stringadd: NameType = "any2stringadd"
val anyHash: NameType = "anyHash"
val anyValClass: NameType = "anyValClass"
val apply: NameType = "apply"
Expand Down

0 comments on commit a9d5d38

Please sign in to comment.