Skip to content

Commit 20def54

Browse files
committed
Adapt printing of imports to new scheme
1 parent 62aa47a commit 20def54

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,13 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
340340

341341
def selectorText(sel: untpd.ImportSelector): Text =
342342
val id: Text =
343-
if sel.isGiven then keywordText("given") else toText(sel.imported.name)
343+
if sel.isGiven then keywordText("given")
344+
else sel.imported.name match
345+
case nme.WILDCARD => "*"
346+
case nme.raw.STAR => "`*`"
347+
case name => toText(name)
344348
val rename: Text =
345-
if sel.renamed.isEmpty then "" else Str(" => ") ~ toText(sel.renamed)
349+
if sel.renamed.isEmpty then "" else Str(" as ") ~ toText(sel.renamed)
346350
val bound: Text =
347351
if sel.bound.isEmpty then ""
348352
else if sel.isGiven then Str(" ") ~ toText(sel.bound)

tests/neg/renaming-imports.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
object a:
2+
def * = 1
3+
def other = 2
4+
15
def test =
26
object foo:
37
var x = 0
48
import foo as f // error
59
f.x
610

11+
import a.`*`
12+
println(*) // ok
13+
println(other) // error
14+
end test

0 commit comments

Comments
 (0)