File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -273,7 +273,19 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
273
273
val cls = mirroredType.classSymbol
274
274
val useCompanion = cls.useCompanionAsSumMirror
275
275
276
- if (! mirroredType.termSymbol.isEnumCase && (cls.isGenericSum(if useCompanion then cls.linkedClass else ctx.owner))) then
276
+ val isDisjointed = mirroredType match {
277
+ case OrType (t1, t2) => TypeComparer .provablyDisjoint(t1, t2)
278
+ case _ => false
279
+ }
280
+
281
+ def isSumWithSingleton (t : Type ): Boolean = {
282
+ t match {
283
+ case OrType (t1, t2) => isSumWithSingleton(t1) || isSumWithSingleton(t2)
284
+ case _ => t.termSymbol.isEnumCase
285
+ }
286
+ }
287
+
288
+ if (! isDisjointed && ! isSumWithSingleton(mirroredType) && cls.isGenericSum(if useCompanion then cls.linkedClass else ctx.owner)) then
277
289
val elemLabels = cls.children.map(c => ConstantType (Constant (c.name.toString)))
278
290
279
291
def solve (sym : Symbol ): Type = sym match
Original file line number Diff line number Diff line change @@ -6,10 +6,23 @@ enum Color:
6
6
case Red , Green , Blue
7
7
end Color
8
8
9
+ enum Bar :
10
+ case A (i : Int )
11
+ case B (b : Boolean )
12
+ case C (s : String )
13
+
14
+ object Singletons {
15
+ object A
16
+ object B
17
+ }
18
+
9
19
object Test {
10
20
11
21
def main (args : Array [String ]): Unit = {
12
22
summon[Mirror .ProductOf [Color ]] // error
13
23
summon[Mirror .SumOf [Color .Red .type ]] // error
24
+ summon[Mirror .SumOf [Color .Red .type | Color .Green .type ]] // error
25
+ summon[Mirror .SumOf [Bar .A | Bar .B ]] // error
26
+ summon[Mirror .SumOf [Singletons .A .type | Singletons .B .type ]] // error
14
27
}
15
28
}
You can’t perform that action at this time.
0 commit comments