Skip to content

Commit 9e357d0

Browse files
oderskyolsdavis
authored andcommitted
Retain HasDefaultParams flag on export.
Fixes scala#14020
1 parent 3bbaf42 commit 9e357d0

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
@@ -1142,6 +1142,7 @@ class Namer { typer: Typer =>
11421142
(StableRealizable, ExprType(path.tpe.select(sym)))
11431143
else
11441144
(EmptyFlags, mbr.info.ensureMethodic)
1145+
sym.hasDefaultParams // ensure HasDefaultParams and NoDefaultParams flags are set
11451146
var mbrFlags = Exported | Method | Final | maybeStable | sym.flags & RetainedExportFlags
11461147
if sym.is(ExtensionMethod) then mbrFlags |= ExtensionMethod
11471148
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)