diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 11 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Mode.scala | 6 | ||||
-rw-r--r-- | tests/run/array-addition.check (renamed from tests/pending/run/array-addition.check) | 0 | ||||
-rw-r--r-- | tests/run/array-addition.scala (renamed from tests/pending/run/array-addition.scala) | 0 |
4 files changed, 14 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index be76553be..a3ddca5d9 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -384,7 +384,9 @@ trait Implicits { self: Typer => && (ctx.mode is Mode.ImplicitsEnabled) && from.isInstanceOf[ValueType] && ( from.isValueSubType(to) - || inferView(dummyTreeOfType(from), to)(ctx.fresh.setExploreTyperState).isInstanceOf[SearchSuccess] + || inferView(dummyTreeOfType(from), to) + (ctx.fresh.addMode(Mode.ImplicitExploration).setExploreTyperState) + .isInstanceOf[SearchSuccess] ) ) @@ -515,8 +517,11 @@ trait Implicits { self: Typer => case fail: SearchFailure => rankImplicits(pending1, acc) case best: SearchSuccess => - val newPending = pending1 filter (isAsGood(_, best.ref)(nestedContext.setExploreTyperState)) - rankImplicits(newPending, best :: acc) + if (ctx.mode.is(Mode.ImplicitExploration)) best :: Nil + else { + val newPending = pending1 filter (isAsGood(_, best.ref)(nestedContext.setExploreTyperState)) + rankImplicits(newPending, best :: acc) + } } case nil => acc } diff --git a/src/dotty/tools/dotc/typer/Mode.scala b/src/dotty/tools/dotc/typer/Mode.scala index e84ef2784..31766adc6 100644 --- a/src/dotty/tools/dotc/typer/Mode.scala +++ b/src/dotty/tools/dotc/typer/Mode.scala @@ -73,5 +73,11 @@ object Mode { */ val ImplicitShadowing = newMode(11, "ImplicitShadowing") + /** We are currently in a `viewExists` check. In that case, ambiguous + * implicits checks are disabled and we succeed with teh first implicit + * found. + */ + val ImplicitExploration = newMode(12, "ImplicitExploration") + val PatternOrType = Pattern | Type } diff --git a/tests/pending/run/array-addition.check b/tests/run/array-addition.check index 7bfbd9c71..7bfbd9c71 100644 --- a/tests/pending/run/array-addition.check +++ b/tests/run/array-addition.check diff --git a/tests/pending/run/array-addition.scala b/tests/run/array-addition.scala index 8def48e85..8def48e85 100644 --- a/tests/pending/run/array-addition.scala +++ b/tests/run/array-addition.scala |