From 4660ad7f2fee161ee96743fdbc8076c5ee7be3a4 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 22 Mar 2022 20:02:12 +0100 Subject: [PATCH] Prevent implicit conversion chaining Just like in tryInsertImplicitOnQualifier, we need to turn off implicit search when typing a selection after inserting an implicit conversion on the qualifier in tryExtensionOrConversion. Partially fixes #13900, see test case. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/neg/i13900.scala | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i13900.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index d092568fc060..0f847a9b6232 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3270,7 +3270,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer if isExtension then return found else checkImplicitConversionUseOK(found) - return typedSelect(tree, pt, found) + return withoutMode(Mode.ImplicitsEnabled)(typedSelect(tree, pt, found)) case failure: SearchFailure => if failure.isAmbiguous then return diff --git a/tests/neg/i13900.scala b/tests/neg/i13900.scala new file mode 100644 index 000000000000..175adf6e5d2c --- /dev/null +++ b/tests/neg/i13900.scala @@ -0,0 +1,9 @@ +opaque type Inlined[T] = T + +object Inlined: + + given fromValueWide[Wide]: Conversion[Wide, Inlined[Wide]] = ??? + + // TODO: This used to make the compiler run into an infinite loop. + // Now it fails instead but shouldn't, see discussion in https://github.com/lampepfl/dotty/issues/13900#issuecomment-1075580792 + def myMax: Int = 1 max 2 // error