Skip to content

Commit aa954de

Browse files
authored
Merge pull request #12409 from dotty-staging/no-chained-conversion-suggestion
Don't chain conversions when looking for import suggestions
2 parents 66c5076 + e506f5c commit aa954de

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,15 @@ trait ImportSuggestions:
167167
allCandidates.map(_.implicitRef.underlyingRef.symbol).toSet
168168
}
169169

170+
def testContext(): Context =
171+
ctx.fresh.retractMode(Mode.ImplicitsEnabled).setExploreTyperState()
172+
170173
/** Test whether the head of a given instance matches the expected type `pt`,
171174
* ignoring any dependent implicit arguments.
172175
*/
173176
def shallowTest(ref: TermRef): Boolean =
174177
System.currentTimeMillis < deadLine
175-
&& inContext(ctx.fresh.setExploreTyperState()) {
178+
&& inContext(testContext()) {
176179
def test(pt: Type): Boolean = pt match
177180
case ViewProto(argType, OrType(rt1, rt2)) =>
178181
// Union types do not constrain results, since comparison with a union
@@ -209,7 +212,7 @@ trait ImportSuggestions:
209212
try
210213
timer.schedule(task, testOneImplicitTimeOut)
211214
typedImplicit(candidate, expectedType, argument, span)(
212-
using ctx.fresh.setExploreTyperState()).isSuccess
215+
using testContext()).isSuccess
213216
finally
214217
if task.cancel() then // timer task has not run yet
215218
assert(!ctx.run.isCancelled)

tests/neg/missing-implicit-3.check

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ longer explanation available when compiling with `-explain`
1919
| ^^^^^^^
2020
| value days is not a member of Int, but could be made available as an extension method.
2121
|
22-
| One of the following imports might fix the problem:
22+
| The following import might fix the problem:
2323
|
2424
| import concurrent.duration.DurationInt
25-
| import concurrent.duration.DurationLong
26-
| import concurrent.duration.DurationDouble
2725
|

0 commit comments

Comments
 (0)