Skip to content

Commit f056508

Browse files
author
Som Snytt
committed
any2stringadd is ineligible under -Xsource:3-cross
1 parent 08060e8 commit f056508

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,9 @@ trait Implicits extends splain.SplainData {
10401040

10411041
private def isIneligible(info: ImplicitInfo) = (
10421042
info.isCyclicOrErroneous
1043-
|| isView && ((info.sym eq Predef_conforms) || (info.sym eq SubType_refl)) // as implicit conversions, Predef.$conforms and <:<.refl are no-op, so exclude them
1043+
|| isView && ((info.sym eq Predef_conforms) || (info.sym eq SubType_refl) ||
1044+
currentRun.sourceFeatures.any2StringAdd && (info.sym eq currentRun.runDefinitions.Predef_any2stringaddMethod)
1045+
) // as implicit conversions, Predef.$conforms and <:<.refl are no-op, so exclude them
10441046
|| (!context.macrosEnabled && info.sym.isTermMacro)
10451047
)
10461048

test/files/run/t13004.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
t13004.scala:12: applied implicit conversion from Money to ?{def + : ?} = implicit def MoneySyntax(self: Money): Money.MoneySyntax
2+
Money(3.14) + Money(1.7)
3+
^
4+
Money(4.84)

test/files/run/t13004.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//> using options -Xsource:3 -Xsource-features:any2stringadd -Vimplicit-conversions
2+
3+
case class Money(value: Double)
4+
object Money {
5+
implicit class MoneySyntax(private val self: Money) extends AnyVal {
6+
def +(other: Money): Money = Money(self.value + other.value)
7+
}
8+
}
9+
10+
object Test extends App {
11+
println {
12+
Money(3.14) + Money(1.7)
13+
}
14+
}

0 commit comments

Comments
 (0)