Skip to content

Do not print accessors for default params in repl #12865

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
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
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import dotty.tools.dotc.core.Denotations.Denotation
import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.Mode
import dotty.tools.dotc.core.NameKinds.SimpleNameKind
import dotty.tools.dotc.core.NameKinds.DefaultGetterName
import dotty.tools.dotc.core.NameOps._
import dotty.tools.dotc.core.Names.Name
import dotty.tools.dotc.core.StdNames._
Expand Down Expand Up @@ -307,6 +308,7 @@ class ReplDriver(settings: Array[String],
.membersBasedOnFlags(required = Method, excluded = Accessor | ParamAccessor | Synthetic | Private)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected the exclusion of Synthetic to be enough to avoid default getters, so I think the real issue is that they're not always marked Synthetic, it looks like currently they're only Synthetic if the method they correspond to is also Synthetic, but it should be unconditional: https://github.com/lampepfl/dotty/blob/af3703bc4c489506afb2461e1f7cea72984ea1a0/compiler/src/dotty/tools/dotc/ast/Desugar.scala#L302

.filterNot { denot =>
defn.topClasses.contains(denot.symbol.owner) || denot.symbol.isConstructor
|| denot.symbol.name.is(DefaultGetterName)
}

val vals =
Expand Down
5 changes: 5 additions & 0 deletions compiler/test/dotty/tools/repl/ReplCompilerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class ReplCompilerTests extends ReplTest {
assertEquals("x: Int = 10", storedOutput().trim)
}

@Test def defaultParamter = fromInitialState { implicit state =>
run("def foo(a: Int = 1): 1 = 1")
assertEquals("def foo(a: Int): 1", storedOutput().trim)
}

@Test def i8677 = fromInitialState { implicit state =>
run {
"""|sealed trait T1
Expand Down