Skip to content

Commit 363996c

Browse files
committed
Retain and expand new rule help, add more words
1 parent f189615 commit 363996c

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,21 +1334,24 @@ class AmbiguousReference(name: Name, newPrec: BindingPrec, prevPrec: BindingPrec
13341334

13351335
def explain(using Context) =
13361336
val precedent =
1337-
if newPrec == prevPrec then """two bindings of equal precedence
1337+
if newPrec == prevPrec then """two name bindings of equal precedence
13381338
|were introduced in the same scope.""".stripMargin
1339-
else """a binding of lower precedence
1339+
else """a name binding of lower precedence
13401340
|in an inner scope cannot shadow a binding with higher precedence in
13411341
|an outer scope.""".stripMargin
13421342

13431343
i"""|The identifier $name is ambiguous because $precedent
13441344
|
1345-
|The precedence of the different kinds of bindings, from highest to lowest, is:
1345+
|The precedence of the different kinds of name bindings, from highest to lowest, is:
13461346
| - Definitions in an enclosing scope
13471347
| - Inherited definitions and top-level definitions in packages
1348-
| - Names introduced by imports
1349-
| - Named imports take precedence over wildcard imports
1348+
| - Names introduced by import of a specific name
1349+
| - Names introduced by wildcard import
13501350
| - Definitions from packages in other files
13511351
|Note:
1352+
| - As a rule, definitions take precedence over imports.
1353+
| - Definitions in an enclosing scope take precedence over inherited definitions,
1354+
| which can result in ambiguities in nested classes.
13521355
| - When importing, you can avoid naming conflicts by renaming:
13531356
| ${hl("import")} scala.{$name => ${name.show}Tick}
13541357
|"""

tests/neg/i12682.check

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
|---------------------------------------------------------------------------------------------------------------------
88
| Explanation (enabled by `-explain`)
99
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10-
| The identifier m is ambiguous because a binding of lower precedence
10+
| The identifier m is ambiguous because a name binding of lower precedence
1111
| in an inner scope cannot shadow a binding with higher precedence in
1212
| an outer scope.
1313
|
14-
| The precedence of the different kinds of bindings, from highest to lowest, is:
14+
| The precedence of the different kinds of name bindings, from highest to lowest, is:
1515
| - Definitions in an enclosing scope
1616
| - Inherited definitions and top-level definitions in packages
17-
| - Names introduced by imports
18-
| - Named imports take precedence over wildcard imports
17+
| - Names introduced by import of a specific name
18+
| - Names introduced by wildcard import
1919
| - Definitions from packages in other files
2020
| Note:
21+
| - As a rule, definitions take precedence over imports.
22+
| - Definitions in an enclosing scope take precedence over inherited definitions,
23+
| which can result in ambiguities in nested classes.
2124
| - When importing, you can avoid naming conflicts by renaming:
2225
| import scala.{m => mTick}
2326
---------------------------------------------------------------------------------------------------------------------
@@ -30,16 +33,19 @@
3033
|--------------------------------------------------------------------------------------------------------------------
3134
| Explanation (enabled by `-explain`)
3235
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33-
| The identifier m is ambiguous because two bindings of equal precedence
36+
| The identifier m is ambiguous because two name bindings of equal precedence
3437
| were introduced in the same scope.
3538
|
36-
| The precedence of the different kinds of bindings, from highest to lowest, is:
39+
| The precedence of the different kinds of name bindings, from highest to lowest, is:
3740
| - Definitions in an enclosing scope
3841
| - Inherited definitions and top-level definitions in packages
39-
| - Names introduced by imports
40-
| - Named imports take precedence over wildcard imports
42+
| - Names introduced by import of a specific name
43+
| - Names introduced by wildcard import
4144
| - Definitions from packages in other files
4245
| Note:
46+
| - As a rule, definitions take precedence over imports.
47+
| - Definitions in an enclosing scope take precedence over inherited definitions,
48+
| which can result in ambiguities in nested classes.
4349
| - When importing, you can avoid naming conflicts by renaming:
4450
| import scala.{m => mTick}
4551
--------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)