Skip to content

Commit

Permalink
Fix value case classes in class-based REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Mar 30, 2020
1 parent 240ca5e commit 4ed31f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ trait TypeDiagnostics {
)
def isSyntheticWarnable(sym: Symbol) = {
def rescindPrivateConstructorDefault: Boolean =
cond(nme.splitDefaultGetterName(sym.name)) {
case (nme.CONSTRUCTOR, _) => true
cond(nme.defaultGetterToMethod(sym.name)) {
case nme.CONSTRUCTOR => true
}
sym.isDefaultGetter && !rescindPrivateConstructorDefault
}
Expand Down
9 changes: 9 additions & 0 deletions test/files/run/repl-class-based-value-class.check
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ object S
scala> val z = new S.T.Meter(3)
val z: S.T.Meter = S$T$Meter@XXXXXXXX

scala> case class Foo(x: Int) extends AnyVal
class Foo

scala> val a = Foo(1)
val a: Foo = Foo(1)

scala> val b = new Foo(1)
val b: Foo = Foo(1)

scala> :quit
3 changes: 3 additions & 0 deletions test/files/run/repl-class-based-value-class.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ object Test extends ReplTest with Hashless {
|val y = new T.Meter(2)
|object S { object T { class Meter(val value: Int) extends AnyVal } }
|val z = new S.T.Meter(3)
|case class Foo(x: Int) extends AnyVal
|val a = Foo(1)
|val b = new Foo(1)
|""".stripMargin
}

0 comments on commit 4ed31f4

Please sign in to comment.