-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate toString only for synthetic companions of case classes (#16890)
Don't generate a toString method if the companion is explicitly given. This matches Scala 2's behavior. Fixes #16879
- Loading branch information
Showing
3 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
trait Companion: | ||
final override def toString: String = "Companion" | ||
|
||
case class Example(value: Int) | ||
object Example extends Companion | ||
|
||
case class C() | ||
object C: | ||
override def toString = "CC" | ||
|
||
case class D() | ||
|
||
@main def Test = | ||
assert(Example.toString == "Companion") | ||
assert(C.toString == "CC") | ||
assert(D.toString == "D") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters