File tree 2 files changed +15
-1
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,10 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
274
274
val useCompanion = cls.useCompanionAsSumMirror
275
275
276
276
def acceptable (tp : Type ): Boolean = tp match
277
+ case tp : TermRef => false
278
+ case tp : TypeProxy => acceptable(tp.underlying)
277
279
case OrType (tp1, tp2) => acceptable(tp1) && acceptable(tp2)
278
- case _ => ! tp.termSymbol.isEnumCase && (tp. classSymbol eq cls)
280
+ case _ => tp.classSymbol eq cls
279
281
280
282
if acceptable(mirroredType) && cls.isGenericSum(if useCompanion then cls.linkedClass else ctx.owner) then
281
283
val elemLabels = cls.children.map(c => ConstantType (Constant (c.name.toString)))
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ object Singletons {
16
16
object B
17
17
}
18
18
19
+ type SumOfK1 [F [_]] = Mirror .Sum { type MirroredType [T ] = F [T ] }
20
+
21
+ class refined extends scala.annotation.RefiningAnnotation
22
+
19
23
object Test {
20
24
21
25
def main (args : Array [String ]): Unit = {
@@ -24,5 +28,13 @@ object Test {
24
28
summon[Mirror .SumOf [Color .Red .type | Color .Green .type ]] // error
25
29
summon[Mirror .SumOf [Bar .A | Bar .B ]] // error
26
30
summon[Mirror .SumOf [Singletons .A .type | Singletons .B .type ]] // error
31
+ summon[SumOfK1 [[X ] =>> Bar ]]
32
+ summon[SumOfK1 [[X ] =>> Bar .A | Bar .B ]] // error
33
+ summon[SumOfK1 [[X ] =>> (Bar .A | Bar .B ) @ refined]] // error
34
+ object opaques {
35
+ opaque type Query [X ] = (Bar .A | Bar .B ) @ refined
36
+ }
37
+ summon[SumOfK1 [opaques.Query ]] // error
38
+ summon[SumOfK1 [[X ] =>> (Bar .A @ refined) | Bar .B ]] // error
27
39
}
28
40
}
You can’t perform that action at this time.
0 commit comments