@@ -250,11 +250,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
250
250
.refinedWith(tpnme.MirroredLabel , TypeAlias (ConstantType (Constant (label.toString))))
251
251
252
252
/** A path referencing the companion of class type `clsType` */
253
- private def companionPath (mirroredType : Type , cls : Symbol , pre : Type , span : Span )(using Context ) =
254
- val clsType =
255
- // ok to assume healPrefix will succeed because `cls` and `pre` derive from the same type.
256
- // TODO: will fail, e.g. for value alias to case object - we still need to support `scala.package.None.type`
257
- TypeOps .healPrefix(mirroredType.mirrorCompanionRef, pre).toOption.get
253
+ private def companionPath (mirroredType : Type , cls : Symbol , span : Span )(using Context ) =
254
+ val clsType = mirroredType.mirrorCompanionRef
258
255
val ref = pathFor(clsType)
259
256
assert(ref.symbol.is(Module ) && (cls.is(ModuleClass ) || (ref.symbol.companionClass == cls)))
260
257
ref.withSpan(span)
@@ -328,7 +325,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
328
325
if (genAnonyousMirror(cls))
329
326
// TODO: scan for problematic prefix
330
327
anonymousMirror(monoType, mirroredType, ExtendsProductMirror , pre, span)
331
- else companionPath(mirroredType, cls, pre, span)
328
+ else companionPath(mirroredType, cls, span)
332
329
withNoErrors(mirrorRef.cast(mirrorType))
333
330
end makeProductMirror
334
331
@@ -342,10 +339,6 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
342
339
i " $cls is not a generic product $reason"
343
340
end getError
344
341
345
- if pre == NoPrefix then
346
- report.error(i " $mirroredType is not a valid prod type, because it does not have a prefix " )
347
- else
348
- report.warning(i " prod mirror with $mirroredType: pre $pre" )
349
342
mirroredType match
350
343
case AndType (tp1, tp2) =>
351
344
orElse(productMirror(tp1, formal, span), productMirror(tp2, formal, span))
@@ -375,10 +368,6 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
375
368
val pre = TypeOps .extractPrefix(mirroredType) match
376
369
case pre if pre.exists => pre
377
370
case _ => return EmptyTreeNoError
378
- // if pre == NoPrefix then
379
- // report.error(i"$mirroredType is not a valid sum type, because it does not have a prefix")
380
- // else
381
- // report.warning(i"sum mirror with $mirroredType: pre $pre")
382
371
val cls = mirroredType.classSymbol
383
372
val useCompanion = cls.useCompanionAsSumMirror
384
373
val declScope = if useCompanion then cls.linkedClass else ctx.owner
@@ -456,7 +445,7 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
456
445
.refinedWith(tpnme.MirroredElemTypes , TypeAlias (elemsType))
457
446
.refinedWith(tpnme.MirroredElemLabels , TypeAlias (TypeOps .nestedPairs(elemLabels)))
458
447
val mirrorRef =
459
- if useCompanion then companionPath(mirroredType, cls, pre, span)
448
+ if useCompanion then companionPath(mirroredType, cls, span)
460
449
else anonymousMirror(monoType, mirroredType, ExtendsSumMirror , pre, span)
461
450
withNoErrors(mirrorRef.cast(mirrorType))
462
451
else if ! cls.isGenericSum(pre, if useCompanion then cls.linkedClass else ctx.owner) then
0 commit comments