Skip to content

Commit 96a8af9

Browse files
committed
revert add enumLabel to Mirror
1 parent faa69ac commit 96a8af9

File tree

4 files changed

+0
-133
lines changed

4 files changed

+0
-133
lines changed

compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -513,34 +513,6 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
513513
Match(param, cases)
514514
}
515515

516-
/** For an enum T:
517-
*
518-
* def enumLabel(x: MirroredMonoType) = x.enumLabel
519-
*
520-
* For sealed trait with children of normalized types C_1, ..., C_n:
521-
*
522-
* def enumLabel(x: MirroredMonoType) = x match {
523-
* case _: C_1 => "C_1"
524-
* ...
525-
* case _: C_n => "C_n"
526-
* }
527-
*
528-
* Here, the normalized type of a class C is C[?, ...., ?] with
529-
* a wildcard for each type parameter. The normalized type of an object
530-
* O is O.type.
531-
*/
532-
def enumLabelBody(cls: Symbol, param: Tree)(using Context): Tree =
533-
if (cls.is(Enum)) param.select(nme.enumLabel).ensureApplied
534-
else {
535-
val cases =
536-
for ((child, idx) <- cls.children.zipWithIndex) yield {
537-
val patType = if (child.isTerm) child.termRef else child.rawTypeRef
538-
val pat = Typed(untpd.Ident(nme.WILDCARD).withType(patType), TypeTree(patType))
539-
CaseDef(pat, EmptyTree, Literal(Constant(child.name.toString)))
540-
}
541-
Match(param, cases)
542-
}
543-
544516
/** - If `impl` is the companion of a generic sum, add `deriving.Mirror.Sum` parent
545517
* and `MirroredMonoType` and `ordinal` members.
546518
* - If `impl` is the companion of a generic product, add `deriving.Mirror.Product` parent
@@ -592,8 +564,6 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
592564
addParent(defn.Mirror_SumClass.typeRef)
593565
addMethod(nme.ordinal, MethodType(monoType.typeRef :: Nil, defn.IntType), cls,
594566
ordinalBody(_, _))
595-
addMethod(nme.enumLabel, MethodType(monoType.typeRef :: Nil, defn.StringType), cls,
596-
enumLabelBody(_, _))
597567
}
598568

599569
if (clazz.is(Module)) {

library/src-bootstrapped/scala/deriving.scala

Lines changed: 0 additions & 76 deletions
This file was deleted.

tests/run/enum-mirror-sumOf.scala

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)