Skip to content

Commit f4ce826

Browse files
committed
Retain HasDefaultParams flag on export.
Fixes #14020
1 parent c3f614b commit f4ce826

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ object Flags {
531531
val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | Enum
532532

533533
/** Flags retained in export forwarders */
534-
val RetainedExportFlags = Given | Implicit | Inline | Transparent
534+
val RetainedExportFlags = Given | Implicit | Inline | Transparent | HasDefaultParams | NoDefaultParams
535535

536536
/** Flags that apply only to classes */
537537
val ClassOnlyFlags = Sealed | Open | Abstract.toTypeFlags

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ class Namer { typer: Typer =>
11161116
(StableRealizable, ExprType(path.tpe.select(sym)))
11171117
else
11181118
(EmptyFlags, mbr.info.ensureMethodic)
1119+
sym.hasDefaultParams // ensure HasDefaultParams and NoDefaultParams flags are set
11191120
var mbrFlags = Exported | Method | Final | maybeStable | sym.flags & RetainedExportFlags
11201121
if sym.is(ExtensionMethod) then mbrFlags |= ExtensionMethod
11211122
val forwarderName = checkNoConflict(alias, isPrivate = false, span)

tests/run/i14020.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Hello you
2+
Hello John
3+
Hello you

tests/run/i14020.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class A:
2+
def greeting(name: String = "you") = s"Hello $name"
3+
4+
class B:
5+
val a = A()
6+
export a.*
7+
8+
@main def Test =
9+
val b = B()
10+
11+
println(b.a.greeting()) // works
12+
println(b.greeting("John")) // works
13+
println(b.greeting()) // nope !

0 commit comments

Comments
 (0)