-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify ambiguous reference error message
- Loading branch information
Showing
6 changed files
with
91 additions
and
25 deletions.
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
-- [E049] Reference Error: tests/neg/ambiref.scala:8:14 ---------------------------------------------------------------- | ||
8 | println(x) // error | ||
| ^ | ||
| Reference to x is ambiguous, | ||
| it is both defined in object Test | ||
| Reference to x is ambiguous. | ||
| It is both defined in object Test | ||
| and inherited subsequently in class D | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E049] Reference Error: tests/neg/ambiref.scala:10:14 --------------------------------------------------------------- | ||
10 | println(x) // error | ||
| ^ | ||
| Reference to x is ambiguous, | ||
| it is both defined in object Test | ||
| Reference to x is ambiguous. | ||
| It is both defined in object Test | ||
| and inherited subsequently in anonymous class test1.C {...} | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E049] Reference Error: tests/neg/ambiref.scala:17:14 --------------------------------------------------------------- | ||
17 | println(y) // error | ||
| ^ | ||
| Reference to y is ambiguous, | ||
| it is both defined in method c | ||
| Reference to y is ambiguous. | ||
| It is both defined in method c | ||
| and inherited subsequently in anonymous class D {...} | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E049] Reference Error: tests/neg/ambiref.scala:25:16 --------------------------------------------------------------- | ||
25 | println(y) // error | ||
| ^ | ||
| Reference to y is ambiguous, | ||
| it is both defined in method c | ||
| Reference to y is ambiguous. | ||
| It is both defined in method c | ||
| and inherited subsequently in class E | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,45 @@ | ||
-- [E049] Reference Error: tests/neg/i12682.scala:6:12 ----------------------------------------------------------------- | ||
6 | val x = m(1) // error | ||
| ^ | ||
| Reference to m is ambiguous. | ||
| It is both defined in object C | ||
| and inherited subsequently in object T | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| The identifier m is ambiguous because a binding of lower precedence | ||
| in an inner scope cannot shadow a binding with higher precedence in | ||
| an outer scope. | ||
| | ||
| The precedence of the different kinds of bindings, from highest to lowest, is: | ||
| - Definitions in an enclosing scope | ||
| - Inherited definitions and top-level definitions in packages | ||
| - Names introduced by imports | ||
| - Named imports take precedence over wildcard imports | ||
| - Definitions from packages in other files | ||
| Note: | ||
| - When importing, you can avoid naming conflicts by renaming: | ||
| import scala.{m => mTick} | ||
--------------------------------------------------------------------------------------------------------------------- | ||
-- [E049] Reference Error: tests/neg/i12682.scala:13:10 ---------------------------------------------------------------- | ||
13 | def d = m(42) // error | ||
| ^ | ||
| Reference to m is ambiguous. | ||
| It is both imported by import X._ | ||
| and imported subsequently by import Y._ | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| The identifier m is ambiguous because two bindings of equal precedence | ||
| were introduced in the same scope. | ||
| | ||
| The precedence of the different kinds of bindings, from highest to lowest, is: | ||
| - Definitions in an enclosing scope | ||
| - Inherited definitions and top-level definitions in packages | ||
| - Names introduced by imports | ||
| - Named imports take precedence over wildcard imports | ||
| - Definitions from packages in other files | ||
| Note: | ||
| - When importing, you can avoid naming conflicts by renaming: | ||
| import scala.{m => mTick} | ||
-------------------------------------------------------------------------------------------------------------------- |
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,13 @@ | ||
// scalac: -explain | ||
|
||
object C: | ||
def m(x: Int) = 1 | ||
object T extends K: | ||
val x = m(1) // error | ||
class K: | ||
def m(i: Int) = 2 | ||
object X extends K | ||
object Y extends K | ||
object D: | ||
import X.*, Y.* | ||
def d = m(42) // error |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
-- [E049] Reference Error: tests/neg/i9803.scala:15:10 ----------------------------------------------------------------- | ||
15 | println(f421()) // error | ||
| ^^^^ | ||
| Reference to f421 is ambiguous, | ||
| it is both imported by name by import bugs.shadowing.x.f421 | ||
| Reference to f421 is ambiguous. | ||
| It is both imported by name by import bugs.shadowing.x.f421 | ||
| and imported by name subsequently by import bugs.shadowing.y.f421 | ||
| | ||
| longer explanation available when compiling with `-explain` |