|
5 | 5 | package play.api.libs.json
|
6 | 6 |
|
7 | 7 | import scala.annotation.tailrec
|
| 8 | +import scala.collection.mutable |
8 | 9 | import scala.reflect.macros.blackbox
|
9 | 10 |
|
10 | 11 | /**
|
@@ -555,25 +556,26 @@ class JsMacroImpl(val c: blackbox.Context) {
|
555 | 556 | val tpeSym = atag.tpe.typeSymbol.asClass
|
556 | 557 |
|
557 | 558 | @tailrec
|
558 |
| - def allSubclasses(path: List[Symbol], subclasses: Set[Type]): Set[Type] = path match { |
559 |
| - case (cls: ClassSymbol) :: tail if tpeSym != cls && cls.selfType.baseClasses.contains(tpeSym) => { |
560 |
| - if (cls.typeParams.nonEmpty) |
561 |
| - c.warning(c.enclosingPosition, s"cannot handle class ${cls.fullName}: type parameter not supported") |
562 |
| - val newSub = if (cls.typeParams.isEmpty) Set(cls.selfType) else Set.empty |
563 |
| - allSubclasses(tail, subclasses ++ newSub) |
564 |
| - } |
| 559 | + def allSubclasses(path: List[Symbol], subclasses: mutable.LinkedHashSet[Type]): mutable.LinkedHashSet[Type] = |
| 560 | + path match { |
| 561 | + case (cls: ClassSymbol) :: tail if tpeSym != cls && cls.selfType.baseClasses.contains(tpeSym) => { |
| 562 | + if (cls.typeParams.nonEmpty) |
| 563 | + c.warning(c.enclosingPosition, s"cannot handle class ${cls.fullName}: type parameter not supported") |
| 564 | + val newSub = if (cls.typeParams.isEmpty) Set(cls.selfType) else Set.empty |
| 565 | + allSubclasses(tail, subclasses ++ newSub) |
| 566 | + } |
565 | 567 |
|
566 |
| - case (o: ModuleSymbol) :: tail |
567 |
| - if o.companion == NoSymbol // not a companion object |
568 |
| - && o.typeSignature.baseClasses.contains(tpeSym) => |
569 |
| - allSubclasses(tail, subclasses ++ Set(o.typeSignature)) |
| 568 | + case (o: ModuleSymbol) :: tail |
| 569 | + if o.companion == NoSymbol // not a companion object |
| 570 | + && o.typeSignature.baseClasses.contains(tpeSym) => |
| 571 | + allSubclasses(tail, subclasses ++ Set(o.typeSignature)) |
570 | 572 |
|
571 |
| - case _ :: tail => allSubclasses(tail, subclasses) |
572 |
| - case _ => subclasses |
573 |
| - } |
| 573 | + case _ :: tail => allSubclasses(tail, subclasses) |
| 574 | + case _ => subclasses |
| 575 | + } |
574 | 576 |
|
575 | 577 | if (tpeSym.isSealed && tpeSym.isAbstract) {
|
576 |
| - Some(allSubclasses(tpeSym.owner.typeSignature.decls.sorted, Set.empty).toList) |
| 578 | + Some(allSubclasses(tpeSym.owner.typeSignature.decls.sorted, mutable.LinkedHashSet[Type]()).toList) |
577 | 579 | } else None
|
578 | 580 | }
|
579 | 581 |
|
|
0 commit comments