Skip to content

Commit d8ce240

Browse files
committed
Fix #10259: Don't complain about old style conversion for extension method
1 parent 1ab80f7 commit d8ce240

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,8 @@ trait Implicits:
792792
val inferred = inferImplicit(adjust(to), from, from.span)
793793

794794
inferred match {
795-
case SearchSuccess(_, ref, _) =>
796-
if isOldStyleFunctionConversion(ref.underlying) then
795+
case SearchSuccess(tree, ref, _)
796+
if isOldStyleFunctionConversion(ref.underlying) && !tree.isInstanceOf[Applications.ExtMethodApply] =>
797797
report.migrationWarning(
798798
i"The conversion ${ref} will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.",
799799
from

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CompilationTests {
3939
compileFilesInDir("tests/new", defaultOptions),
4040
compileFilesInDir("tests/pos-scala2", scala2CompatMode),
4141
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-Yerased-terms")),
42+
compileFilesInDir("tests/pos-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")),
4243
compileFilesInDir("tests/pos", defaultOptions),
4344
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
4445
compileFile(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait S[T] extends (T => T):
2+
def apply(x: T) = ???
3+
extension (x: T) def show: String
4+
5+
given S[Int] with
6+
extension (x: Int) def show = x.toString
7+
8+
val x = 10.show

0 commit comments

Comments
 (0)