File tree 2 files changed +23
-4
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -333,11 +333,13 @@ object Implicits:
333
333
def filter (xs : List [Candidate ], remove : List [Candidate ]) =
334
334
val shadowed = remove.map(_.ref.implicitName).toSet
335
335
xs.filterConserve(cand => ! shadowed.contains(cand.ref.implicitName))
336
+
337
+ val outer = outerImplicits.uncheckedNN
336
338
def isWildcardImport (using Context ) = ctx.importInfo.nn.isWildcardImport
337
- if (irefCtx.scope eq irefCtx.outer.scope) && (
338
- isImport && ! outerImplicits.nn.isImport
339
- || isWildcardImport && ! isWildcardImport( using outerImplicits.nn.irefCtx)
340
- ) then
339
+ def preferDefinitions = isImport && ! outer.isImport
340
+ def preferNamedImport = isWildcardImport && ! isWildcardImport( using outer.irefCtx)
341
+
342
+ if level == outer.level && (preferDefinitions || preferNamedImport ) then
341
343
// special cases: definitions beat imports, and named imports beat
342
344
// wildcard imports, provided both are in contexts with same scope
343
345
filter(ownEligible, outerEligible) ::: outerEligible
Original file line number Diff line number Diff line change
1
+ // A minimised reproduction of how an initial change to combineEligibles broke Typer#findRef
2
+ case class Foo (n : Int )
3
+
4
+ class Test :
5
+ import this .toString
6
+
7
+ val foo1 = Foo (1 )
8
+ val foo2 = Foo (2 )
9
+
10
+ def foo (using Foo ): Foo =
11
+ import this .*
12
+ def bar (using Foo ): Foo = summon[Foo ]
13
+ bar(using foo2)
14
+
15
+ object Test extends Test :
16
+ def main (args : Array [String ]): Unit =
17
+ assert(foo(using foo1) eq foo2)
You can’t perform that action at this time.
0 commit comments