Skip to content

Commit 26170ec

Browse files
committed
Refine override exclude criterion for export forwarders
Fixes #17588
1 parent 2e19304 commit 26170ec

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,10 @@ class Namer { typer: Typer =>
11221122
No("is already an extension method, cannot be exported into another one")
11231123
else if targets.contains(alias) then
11241124
No(i"clashes with another export in the same export clause")
1125-
else if sym.is(Override) then
1125+
else if sym.is(Override) || sym.is(JavaDefined) then
1126+
// The tests above are used to avoid futile searches of `allOverriddenSymbols`.
1127+
// Scala defined symbols can override concrete symbols only if declared override.
1128+
// For Java defined symbols, this does not hold, so we have to search anyway.
11261129
sym.allOverriddenSymbols.find(
11271130
other => cls.derivesFrom(other.owner) && !other.is(Deferred)
11281131
) match

tests/pos/i17588.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class StringBox(inner: String):
2+
export inner.*

0 commit comments

Comments
 (0)