Skip to content

Commit c69da49

Browse files
Merge pull request #12865 from romanowski/repl/do-not-print-default-methods
Do not print accessors for default params in repl
2 parents 0e472bf + 5f03d20 commit c69da49

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import dotty.tools.dotc.core.Denotations.Denotation
1111
import dotty.tools.dotc.core.Flags._
1212
import dotty.tools.dotc.core.Mode
1313
import dotty.tools.dotc.core.NameKinds.SimpleNameKind
14+
import dotty.tools.dotc.core.NameKinds.DefaultGetterName
1415
import dotty.tools.dotc.core.NameOps._
1516
import dotty.tools.dotc.core.Names.Name
1617
import dotty.tools.dotc.core.StdNames._
@@ -307,6 +308,7 @@ class ReplDriver(settings: Array[String],
307308
.membersBasedOnFlags(required = Method, excluded = Accessor | ParamAccessor | Synthetic | Private)
308309
.filterNot { denot =>
309310
defn.topClasses.contains(denot.symbol.owner) || denot.symbol.isConstructor
311+
|| denot.symbol.name.is(DefaultGetterName)
310312
}
311313

312314
val vals =

compiler/test/dotty/tools/repl/ReplCompilerTests.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ class ReplCompilerTests extends ReplTest {
8585
assertEquals("x: Int = 10", storedOutput().trim)
8686
}
8787

88+
@Test def defaultParamter = fromInitialState { implicit state =>
89+
run("def foo(a: Int = 1): 1 = 1")
90+
assertEquals("def foo(a: Int): 1", storedOutput().trim)
91+
}
92+
8893
@Test def i8677 = fromInitialState { implicit state =>
8994
run {
9095
"""|sealed trait T1

0 commit comments

Comments
 (0)