File tree Expand file tree Collapse file tree 5 files changed +37
-5
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 5 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -91,19 +91,18 @@ object SymUtils:
9191 * It must satisfy the following conditions:
9292 * - it has at least one child class or object
9393 * - none of its children are anonymous classes
94- * - all of its children are addressable through a path from its companion object
94+ * - all of its children are addressable through a path from the parent class
9595 * - all of its children are generic products or singletons
9696 */
9797 def whyNotGenericSum (using Context ): String =
9898 if (! self.is(Sealed ))
9999 s " it is not a sealed ${self.kindString}"
100100 else {
101101 val children = self.children
102- val companion = self.linkedClass
103102 def problem (child : Symbol ) = {
104103
105104 def isAccessible (sym : Symbol ): Boolean =
106- companion .isContainedIn(sym) || sym.is(Module ) && isAccessible(sym.owner)
105+ self .isContainedIn(sym) || sym.is(Module ) && isAccessible(sym.owner)
107106
108107 if (child == self) " it has anonymous or inaccessible subclasses"
109108 else if (! isAccessible(child.owner)) i " its child $child is not accessible "
Original file line number Diff line number Diff line change 1+ sealed trait Parent
2+
3+ trait Wrapper {
4+
5+ case class Foo (x : Int , y : Int , s : String ) extends Parent
6+ case class Bar (x : Int , y : Int ) extends Parent
7+
8+ println(summon[deriving.Mirror .Of [Parent ]]) // error
9+ }
Original file line number Diff line number Diff line change 1+ class Test {
2+
3+ sealed trait Parent
4+ case class Foo (x : Int , y : Int , s : String ) extends Parent
5+ case class Bar (x : Int , y : Int ) extends Parent
6+
7+ println(summon[deriving.Mirror .Of [Parent ]])
8+ }
9+
10+ object Test2 {
11+
12+ case class Foo (x : Int , y : Int , s : String ) extends i.Parent
13+ case class Bar (x : Int , y : Int ) extends i.Parent
14+
15+ val i = Inner ()
16+
17+ class Inner {
18+
19+ sealed trait Parent
20+
21+ println(summon[deriving.Mirror .Of [Parent ]])
22+ }
23+
24+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ object Test extends App {
77 case _ : T => ()
88 }
99
10- sealed trait Base1
10+ sealed trait Base1 // Base1 MUST NOT have a companion here!
1111 case class Foo () extends Base1
1212 case object Bar extends Base1
1313 case class Qux (i : Int ) extends Base1
Original file line number Diff line number Diff line change 44case class A (x : Int , y : Int ) extends T
55case object B extends T
66
7- sealed trait U
7+ sealed trait U // U MUST NOT have a companion here!
88case class C () extends U
99
1010object Test extends App {
You can’t perform that action at this time.
0 commit comments