File tree 3 files changed +57
-1
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -3163,7 +3163,10 @@ class Typer extends Namer
3163
3163
if ! app.isEmpty && ! nestedCtx.reporter.hasErrors then
3164
3164
nestedCtx.typerState.commit()
3165
3165
return app
3166
- for err <- nestedCtx.reporter.allErrors.take(1 ) do
3166
+ val errs = nestedCtx.reporter.allErrors
3167
+ val remembered = // report AmbiguousReferences as priority, otherwise last error
3168
+ (errs.filter(_.msg.isInstanceOf [AmbiguousReference ]) ++ errs).take(1 )
3169
+ for err <- remembered do
3167
3170
rememberSearchFailure(qual,
3168
3171
SearchFailure (app.withType(FailedExtension (app, selectionProto, err.msg))))
3169
3172
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