aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala11
-rw-r--r--src/dotty/tools/dotc/typer/Mode.scala6
2 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
}