Skip to content

Commit 4cccf41

Browse files
oderskymilessabin
authored andcommitted
Revert "Always generate companion objects for sealed classes"
This reverts commit b6f63b1. It turns out that always generating companions for sealed classes breaks existing code. An example is pos/i2300.scala.
1 parent 88cec9f commit 4cccf41

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ object desugar {
682682
}
683683
companionDefs(companionParent, applyMeths ::: unapplyMeth :: companionMembers)
684684
}
685-
else if (companionMembers.nonEmpty || companionDerived.nonEmpty || isEnum || mods.is(Sealed))
685+
else if (companionMembers.nonEmpty || companionDerived.nonEmpty || isEnum)
686686
companionDefs(anyRef, companionMembers)
687687
else if (isValueClass) {
688688
impl.constr.vparamss match {

tests/run/ordinal-innerclass.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ object Test extends App {
3333
}
3434
}
3535

36-
sealed trait T1
36+
trait T1
3737
case class A1() extends T1
3838
}

0 commit comments

Comments
 (0)