File tree Expand file tree Collapse file tree 3 files changed +57
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -3150,7 +3150,10 @@ class Typer extends Namer
31503150 if ! app.isEmpty && ! nestedCtx.reporter.hasErrors then
31513151 nestedCtx.typerState.commit()
31523152 return app
3153- for err <- nestedCtx.reporter.allErrors.take(1 ) do
3153+ val errs = nestedCtx.reporter.allErrors
3154+ val remembered = // report AmbiguousReferences as priority, otherwise last error
3155+ (errs.filter(_.msg.isInstanceOf [AmbiguousReference ]) ++ errs).take(1 )
3156+ for err <- remembered do
31543157 rememberSearchFailure(qual,
31553158 SearchFailure (app.withType(FailedExtension (app, selectionProto, err.msg))))
31563159 catch case ex : TypeError => nestedFailure(ex)
Original file line number Diff line number Diff line change 1+ -- [E008] Not Found Error: tests/neg/i13558.scala:23:14 ----------------------------------------------------------------
2+ 23 | println(a.id) // error
3+ | ^^^^
4+ | value id is not a member of testcode.A.
5+ | An extension method was tried, but could not be fully constructed:
6+ |
7+ | testcode.ExtensionA.id(a) failed with
8+ |
9+ | Reference to id is ambiguous,
10+ | it is both imported by import testcode.ExtensionB._
11+ | and imported subsequently by import testcode.ExtensionA._
12+ -- [E008] Not Found Error: tests/neg/i13558.scala:29:14 ----------------------------------------------------------------
13+ 29 | println(a.id) // error
14+ | ^^^^
15+ | value id is not a member of testcode.A.
16+ | An extension method was tried, but could not be fully constructed:
17+ |
18+ | testcode.ExtensionB.id(a) failed with
19+ |
20+ | Reference to id is ambiguous,
21+ | it is both imported by import testcode.ExtensionA._
22+ | and imported subsequently by import testcode.ExtensionB._
Original file line number Diff line number Diff line change 1+ package testcode
2+
3+ class A
4+
5+ class B
6+
7+ object ExtensionA {
8+ extension (self : A ) {
9+ def id = " A"
10+ }
11+ }
12+ object ExtensionB {
13+ extension (self : B ) {
14+ def id = " B"
15+ }
16+ }
17+
18+ object Main {
19+ def main1 (args : Array [String ]): Unit = {
20+ import ExtensionB ._
21+ import ExtensionA ._
22+ val a = A ()
23+ println(a.id) // error
24+ }
25+ def main2 (args : Array [String ]): Unit = {
26+ import ExtensionA ._
27+ import ExtensionB ._
28+ val a = A ()
29+ println(a.id) // error
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments