Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ class Definitions {
RootRef(() => ScalaPackageVal.termRef)

private val PredefImportFns: RootRef =
RootRef(() => ScalaPredefModule.termRef, isPredef=true)
RootRef(() => ScalaPredefModule.termRef)

@tu private lazy val YimportsImportFns: List[RootRef] = ctx.settings.Yimports.value.map { name =>
val denot =
Expand Down
5 changes: 1 addition & 4 deletions compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ import scala.compiletime.uninitialized

object ImportInfo {

case class RootRef(refFn: () => TermRef, isPredef: Boolean = false)
case class RootRef(refFn: () => TermRef)

/** The import info for a root import */
def rootImport(ref: RootRef)(using Context): ImportInfo =
var selectors =
untpd.ImportSelector(untpd.Ident(nme.WILDCARD)) // import all normal members...
:: untpd.ImportSelector(untpd.Ident(nme.EMPTY)) // ... and also all given members
:: Nil
if ref.isPredef then // do not import any2stringadd
selectors = untpd.ImportSelector(untpd.Ident(nme.any2stringadd), untpd.Ident(nme.WILDCARD))
:: selectors

def sym(using Context) =
val expr = tpd.Ident(ref.refFn()) // refFn must be called in the context of ImportInfo.sym
Expand Down
4 changes: 3 additions & 1 deletion library/src/scala/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,11 @@ object Predef extends LowPriorityImplicits {
@(deprecated @companionMethod)("Implicit injection of + is deprecated. Convert to String to call +", "2.13.0")
@(deprecated @companionClass)("Implicit injection of + is deprecated. Convert to String to call +", "2.13.0") // for Scaladoc
// scala/bug#8229 retaining the pre 2.11 name for source compatibility in shadowing this implicit
implicit final class any2stringadd[A](private val self: A) extends AnyVal {
private[scala] final class any2stringadd[A](private val self: A) extends AnyVal {
def +(other: String): String = String.valueOf(self) + other
}
@deprecated
private[scala] def any2stringadd[A](self: A): any2stringadd[A] = new any2stringadd[A](self)

/** @group char-sequence-wrappers */
final class SeqCharSequence(sequenceOfChars: scala.collection.IndexedSeq[Char]) extends CharSequence {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i7137.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ object App {
val any: Any = 3
val str: String = any + "a" // error
val str2: String = any2stringadd(any) + "a" // error
val str3: String = Predef.any2stringadd(any) + "a"
val str3: String = Predef.any2stringadd(any) + "a" // error
}
Loading