Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13588 from dotty-staging/fix-13558
Prioritize ambiguous errors in extension method search
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- [E008] Not Found Error: tests/neg/i13558.scala:23:14 ---------------------------------------------------------------- | ||
23 | println(a.id) // error | ||
| ^^^^ | ||
| value id is not a member of testcode.A. | ||
| An extension method was tried, but could not be fully constructed: | ||
| | ||
| testcode.ExtensionA.id(a) failed with | ||
| | ||
| Reference to id is ambiguous, | ||
| it is both imported by import testcode.ExtensionB._ | ||
| and imported subsequently by import testcode.ExtensionA._ | ||
-- [E008] Not Found Error: tests/neg/i13558.scala:29:14 ---------------------------------------------------------------- | ||
29 | println(a.id) // error | ||
| ^^^^ | ||
| value id is not a member of testcode.A. | ||
| An extension method was tried, but could not be fully constructed: | ||
| | ||
| testcode.ExtensionB.id(a) failed with | ||
| | ||
| Reference to id is ambiguous, | ||
| it is both imported by import testcode.ExtensionA._ | ||
| and imported subsequently by import testcode.ExtensionB._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package testcode | ||
|
||
class A | ||
|
||
class B | ||
|
||
object ExtensionA { | ||
extension (self: A) { | ||
def id = "A" | ||
} | ||
} | ||
object ExtensionB { | ||
extension (self: B) { | ||
def id = "B" | ||
} | ||
} | ||
|
||
object Main { | ||
def main1(args: Array[String]): Unit = { | ||
import ExtensionB._ | ||
import ExtensionA._ | ||
val a = A() | ||
println(a.id) // error | ||
} | ||
def main2(args: Array[String]): Unit = { | ||
import ExtensionA._ | ||
import ExtensionB._ | ||
val a = A() | ||
println(a.id) // error | ||
} | ||
} |