Skip to content

Don't print modifiers in the REPL #5293

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 1 commit into from
Oct 19, 2018
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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,16 @@ class PlainPrinter(_ctx: Context) extends Printer {
else ""
}

/** String representation of symbol's definition key word */
/** String representation of symbol's definition keyword */
protected def keyString(sym: Symbol): String = {
val flags = sym.flagsUNSAFE
if (flags is JavaTrait) "interface"
else if (flags is Trait) "trait"
else if (flags is Module) "object"
else if (sym.isClass) "class"
else if (sym.isType) "type"
else if (flags is Mutable) "var"
else if (flags is Package) "package"
else if (flags is Module) "object"
else if (sym is Method) "def"
else if (sym.isTerm && (!(flags is Param))) "val"
else ""
Expand Down
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
super.toText(sym)
}

/** String representation of symbol's kind. */
override def kindString(sym: Symbol): String = {
val flags = sym.flagsUNSAFE
if (flags is Package) "package"
Expand All @@ -789,16 +790,13 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
else super.kindString(sym)
}

/** String representation of symbol's definition keyword */
override protected def keyString(sym: Symbol): String = {
val flags = sym.flagsUNSAFE
if (sym.isType && sym.owner.isTerm) ""
else if (sym.isPackageObject) "package object"
else if (flags.is(Module) && flags.is(Case)) "case object"
else if (sym.isClass && flags.is(Case)) "case class"
else if (flags is Module) "object"
else if (sym.isTerm && !flags.is(Param) && flags.is(Implicit) && (sym is Method)) "implicit def"
else if (sym.isTerm && !flags.is(Param) && flags.is(Implicit)) "implicit val"
else if (sym.isTerm && !flags.is(Param) && flags.is(Erased)) "erased val"
else super.keyString(sym)
}

Expand Down
23 changes: 23 additions & 0 deletions compiler/test-resources/type-printer/definitions
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
scala> class A
// defined class A

scala> case class B()
// defined case class B

scala> object C
// defined object C

scala> case object D
// defined case object D

scala> case object D
// defined case object D

scala> trait E
// defined trait E

scala> implicit def x: Int = 1
def x: Int

scala> erased def y: Int = 1
def y: Int