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:
91
91
* It must satisfy the following conditions:
92
92
* - it has at least one child class or object
93
93
* - 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
95
95
* - all of its children are generic products or singletons
96
96
*/
97
97
def whyNotGenericSum (using Context ): String =
98
98
if (! self.is(Sealed ))
99
99
s " it is not a sealed ${self.kindString}"
100
100
else {
101
101
val children = self.children
102
- val companion = self.linkedClass
103
102
def problem (child : Symbol ) = {
104
103
105
104
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)
107
106
108
107
if (child == self) " it has anonymous or inaccessible subclasses"
109
108
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 {
7
7
case _ : T => ()
8
8
}
9
9
10
- sealed trait Base1
10
+ sealed trait Base1 // Base1 MUST NOT have a companion here!
11
11
case class Foo () extends Base1
12
12
case object Bar extends Base1
13
13
case class Qux (i : Int ) extends Base1
Original file line number Diff line number Diff line change 4
4
case class A (x : Int , y : Int ) extends T
5
5
case object B extends T
6
6
7
- sealed trait U
7
+ sealed trait U // U MUST NOT have a companion here!
8
8
case class C () extends U
9
9
10
10
object Test extends App {
You can’t perform that action at this time.
0 commit comments