Skip to content

Fix #8368: Don't generate forwarders for excluded exports #8393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,8 @@ class Namer { typer: Typer =>
if sel.isWildcard then
addWildcardForwarders(seen, sel.span)
else
addForwardersNamed(sel.name, sel.rename, sel.span)
if sel.rename != nme.WILDCARD then
addForwardersNamed(sel.name, sel.rename, sel.span)
addForwarders(sels1, sel.name :: seen)
case _ =>

Expand Down
6 changes: 1 addition & 5 deletions tests/neg/exports.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
| ^^^^^^^^^^^^^^
| no eligible member scanAll at this.scanUnit
| this.scanUnit.scanAll cannot be exported because it is not accessible
-- Error: tests/neg/exports.scala:23:27 --------------------------------------------------------------------------------
23 | export printUnit.{stat => _, _} // error: double definition // error: double definition
| ^^^^^^^^^
| no eligible member stat at this.printUnit
-- Error: tests/neg/exports.scala:25:21 --------------------------------------------------------------------------------
25 | export printUnit.bitmap // error: no eligible member
| ^
| non-private method bitmap in class Copier refers to private value printUnit
| in its type signature => Copier.this.printUnit.bitmap.type
-- [E120] Duplicate Symbol Error: tests/neg/exports.scala:23:33 --------------------------------------------------------
23 | export printUnit.{stat => _, _} // error: double definition // error: double definition
23 | export printUnit.{stat => _, _} // error: double definition
| ^
| Double definition:
| def status: => List[String] in class Copier at line 28 and
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/exports.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

export scanUnit.scanIt // error: no eligible member
export scanUnit.{scanAll => foo} // error: no eligible member
export printUnit.{stat => _, _} // error: double definition // error: double definition
export printUnit.{stat => _, _} // error: double definition
export scanUnit._ // error: double definition
export printUnit.bitmap // error: no eligible member
export printUnit.status // error: double definition
Expand Down
11 changes: 11 additions & 0 deletions tests/neg/i8368.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trait Foo {
def a = 1
def b = 1
def c = 1
}

class Bar(foo: Foo) {
export foo.{a => _, b => _, _}
val x1 = a // error
val x2 = b // error
}
10 changes: 10 additions & 0 deletions tests/pos/i8368.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
trait Foo {
def a = 1
def b = 1
def c = 1
}

class Bar(foo: Foo) {
export foo.{a => _, b => _, _}
val x1 = c
}