Skip to content

Commit a0f1755

Browse files
som-snyttlrytz
authored andcommitted
Use plain words for duplicate selector
1 parent 4fdc885 commit a0f1755

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,9 +2825,11 @@ self =>
28252825
if (!h.isMask)
28262826
t.find(_.rename == h.rename).foreach { duplicate =>
28272827
val msg =
2828-
if (h.isRename || duplicate.isRename) s"${h.rename} is an ambiguous name on import"
2828+
if (h.isRename || duplicate.isRename)
2829+
if (h.name == duplicate.name) s"${h.name} is renamed twice to ${h.rename}"
2830+
else s"${h.rename} is an ambiguous name on import"
28292831
else s"${h.rename} is imported twice"
2830-
syntaxError(h.renamePos, msg)
2832+
syntaxError(duplicate.renamePos, msg)
28312833
}
28322834
h :: checkSelectors(t)
28332835
}

test/files/neg/t12813.check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
t12813.scala:5: error: a is imported twice
22
import O.{a, a} // error
3-
^
4-
t12813.scala:8: error: b is an ambiguous name on import
3+
^
4+
t12813.scala:8: error: a is renamed twice to b
55
import O.{a => b, a => b} // error
6-
^
6+
^
77
t12813.scala:10: error: b is an ambiguous name on import
88
import O.{a => b, toString => b} // error
9-
^
9+
^
1010
t12813.scala:11: error: toString is an ambiguous name on import
1111
import O.{a => toString, toString} // error
12-
^
12+
^
1313
t12813.scala:12: error: toString is an ambiguous name on import
1414
import O.{toString, a => toString} // error
15-
^
15+
^
1616
5 errors

test/files/neg/t12813b.check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
t12813b.scala:5: error: a is imported twice
22
import O.{a, a} // error
3-
^
4-
t12813b.scala:8: error: b is an ambiguous name on import
3+
^
4+
t12813b.scala:8: error: a is renamed twice to b
55
import O.{a => b, a => b} // error
6-
^
6+
^
77
t12813b.scala:10: error: b is an ambiguous name on import
88
import O.{a => b, toString => b} // error
9-
^
9+
^
1010
t12813b.scala:11: error: toString is an ambiguous name on import
1111
import O.{a => toString, toString} // error
12-
^
12+
^
1313
t12813b.scala:12: error: toString is an ambiguous name on import
1414
import O.{toString, a => toString} // error
15-
^
15+
^
1616
t12813b.scala:14: error: wildcard import must be in last position
1717
import O.{given, a, _} // error 3
1818
^

test/files/neg/t12813c.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
t12813c.scala:6: error: abcdefghij is an ambiguous name on import
1+
t12813c.scala:6: error: a is renamed twice to abcdefghij
22
import O.{a => abcdefghij, a => abcdefghij}
3-
^
3+
^
44
1 error

0 commit comments

Comments
 (0)