Skip to content

Don't chain conversions when looking for import suggestions #12409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,15 @@ trait ImportSuggestions:
allCandidates.map(_.implicitRef.underlyingRef.symbol).toSet
}

def testContext(): Context =
ctx.fresh.retractMode(Mode.ImplicitsEnabled).setExploreTyperState()

/** Test whether the head of a given instance matches the expected type `pt`,
* ignoring any dependent implicit arguments.
*/
def shallowTest(ref: TermRef): Boolean =
System.currentTimeMillis < deadLine
&& inContext(ctx.fresh.setExploreTyperState()) {
&& inContext(testContext()) {
def test(pt: Type): Boolean = pt match
case ViewProto(argType, OrType(rt1, rt2)) =>
// Union types do not constrain results, since comparison with a union
Expand Down Expand Up @@ -209,7 +212,7 @@ trait ImportSuggestions:
try
timer.schedule(task, testOneImplicitTimeOut)
typedImplicit(candidate, expectedType, argument, span)(
using ctx.fresh.setExploreTyperState()).isSuccess
using testContext()).isSuccess
finally
if task.cancel() then // timer task has not run yet
assert(!ctx.run.isCancelled)
Expand Down
4 changes: 1 addition & 3 deletions tests/neg/missing-implicit-3.check
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ longer explanation available when compiling with `-explain`
| ^^^^^^^
| value days is not a member of Int, but could be made available as an extension method.
|
| One of the following imports might fix the problem:
| The following import might fix the problem:
|
| import concurrent.duration.DurationInt
| import concurrent.duration.DurationLong
| import concurrent.duration.DurationDouble
|