@@ -600,134 +600,6 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
600
600
def While_copy (original : Tree )(cond : Term , body : Term )(implicit ctx : Context ): While =
601
601
tpd.cpy.WhileDo (original)(cond, body)
602
602
603
- //
604
- // CASES
605
- //
606
-
607
- type CaseDef = tpd.CaseDef
608
-
609
- def CaseDef_pattern (self : CaseDef )(implicit ctx : Context ): Pattern = self.pat
610
- def CaseDef_guard (self : CaseDef )(implicit ctx : Context ): Option [Term ] = optional(self.guard)
611
- def CaseDef_rhs (self : CaseDef )(implicit ctx : Context ): Term = self.body
612
-
613
- def CaseDef_module_apply (pattern : Pattern , guard : Option [Term ], body : Term )(implicit ctx : Context ): CaseDef =
614
- tpd.CaseDef (pattern, guard.getOrElse(tpd.EmptyTree ), body)
615
-
616
- def CaseDef_module_copy (original : CaseDef )(pattern : Pattern , guard : Option [Term ], body : Term )(implicit ctx : Context ): CaseDef =
617
- tpd.cpy.CaseDef (original)(pattern, guard.getOrElse(tpd.EmptyTree ), body)
618
-
619
- type TypeCaseDef = tpd.CaseDef
620
-
621
- def TypeCaseDef_pattern (self : TypeCaseDef )(implicit ctx : Context ): TypeTree = self.pat
622
- def TypeCaseDef_rhs (self : TypeCaseDef )(implicit ctx : Context ): TypeTree = self.body
623
-
624
- def TypeCaseDef_module_apply (pattern : TypeTree , body : TypeTree )(implicit ctx : Context ): TypeCaseDef =
625
- tpd.CaseDef (pattern, tpd.EmptyTree , body)
626
-
627
- def TypeCaseDef_module_copy (original : TypeCaseDef )(pattern : TypeTree , body : TypeTree )(implicit ctx : Context ): TypeCaseDef =
628
- tpd.cpy.CaseDef (original)(pattern, tpd.EmptyTree , body)
629
-
630
- //
631
- // PATTERNS
632
- //
633
-
634
- type Pattern = tpd.Tree
635
-
636
- def Pattern_pos (self : Pattern )(implicit ctx : Context ): Position = self.sourcePos
637
- def Pattern_tpe (self : Pattern )(implicit ctx : Context ): Type = self.tpe.stripTypeVar
638
- def Pattern_symbol (self : Pattern )(implicit ctx : Context ): Symbol = self.symbol
639
-
640
- type Value = tpd.Tree
641
-
642
- def matchPattern_Value (pattern : Pattern ): Option [Value ] = pattern match {
643
- case lit : tpd.Literal => Some (lit)
644
- case ref : tpd.RefTree if ref.isTerm => Some (ref)
645
- case ths : tpd.This => Some (ths)
646
- case _ => None
647
- }
648
-
649
- def Pattern_Value_value (self : Value )(implicit ctx : Context ): Term = self
650
-
651
- def Pattern_Value_module_apply (term : Term )(implicit ctx : Context ): Value = term match {
652
- case lit : tpd.Literal => lit
653
- case ref : tpd.RefTree if ref.isTerm => ref
654
- case ths : tpd.This => ths
655
- }
656
- def Pattern_Value_module_copy (original : Value )(term : Term )(implicit ctx : Context ): Value = term match {
657
- case lit : tpd.Literal => tpd.cpy.Literal (original)(lit.const)
658
- case ref : tpd.RefTree if ref.isTerm => tpd.cpy.Ref (original.asInstanceOf [tpd.RefTree ])(ref.name)
659
- case ths : tpd.This => tpd.cpy.This (original)(ths.qual)
660
- }
661
-
662
- type Bind = tpd.Bind
663
-
664
- def matchPattern_Bind (x : Pattern )(implicit ctx : Context ): Option [Bind ] = x match {
665
- case x : tpd.Bind if x.name.isTermName => Some (x)
666
- case _ => None
667
- }
668
-
669
- def Pattern_Bind_name (self : Bind )(implicit ctx : Context ): String = self.name.toString
670
-
671
- def Pattern_Bind_pattern (self : Bind )(implicit ctx : Context ): Pattern = self.body
672
-
673
- def Pattern_Bind_module_copy (original : Bind )(name : String , pattern : Pattern )(implicit ctx : Context ): Bind =
674
- withDefaultPos(ctx => tpd.cpy.Bind (original)(name.toTermName, pattern)(ctx))
675
-
676
- type Unapply = tpd.UnApply
677
-
678
- def matchPattern_Unapply (pattern : Pattern )(implicit ctx : Context ): Option [Unapply ] = pattern match {
679
- case pattern @ Trees .UnApply (_, _, _) => Some (pattern)
680
- case Trees .Typed (pattern @ Trees .UnApply (_, _, _), _) => Some (pattern)
681
- case _ => None
682
- }
683
-
684
- def Pattern_Unapply_fun (self : Unapply )(implicit ctx : Context ): Term = self.fun
685
- def Pattern_Unapply_implicits (self : Unapply )(implicit ctx : Context ): List [Term ] = self.implicits
686
- def Pattern_Unapply_patterns (self : Unapply )(implicit ctx : Context ): List [Pattern ] = effectivePatterns(self.patterns)
687
-
688
- def Pattern_Unapply_module_copy (original : Unapply )(fun : Term , implicits : List [Term ], patterns : List [Pattern ])(implicit ctx : Context ): Unapply =
689
- withDefaultPos(ctx => tpd.cpy.UnApply (original)(fun, implicits, patterns)(ctx))
690
-
691
- private def effectivePatterns (patterns : List [Pattern ]): List [Pattern ] = patterns match {
692
- case patterns0 :+ Trees .SeqLiteral (elems, _) => patterns0 ::: elems
693
- case _ => patterns
694
- }
695
-
696
- type Alternatives = tpd.Alternative
697
-
698
- def matchPattern_Alternatives (pattern : Pattern )(implicit ctx : Context ): Option [Alternatives ] = pattern match {
699
- case pattern : tpd.Alternative => Some (pattern)
700
- case _ => None
701
- }
702
-
703
- def Pattern_Alternatives_patterns (self : Alternatives )(implicit ctx : Context ): List [Pattern ] = self.trees
704
-
705
- def Pattern_Alternatives_module_apply (patterns : List [Pattern ])(implicit ctx : Context ): Alternatives =
706
- withDefaultPos(ctx => tpd.Alternative (patterns)(ctx))
707
-
708
- def Pattern_Alternatives_module_copy (original : Alternatives )(patterns : List [Pattern ])(implicit ctx : Context ): Alternatives =
709
- tpd.cpy.Alternative (original)(patterns)
710
-
711
- type TypeTest = tpd.Typed
712
-
713
- def matchPattern_TypeTest (pattern : Pattern )(implicit ctx : Context ): Option [TypeTest ] = pattern match {
714
- case Trees .Typed (_ : tpd.UnApply , _) => None
715
- case pattern : tpd.Typed => Some (pattern)
716
- case _ => None
717
- }
718
-
719
- def Pattern_TypeTest_tpt (self : TypeTest )(implicit ctx : Context ): TypeTree = self.tpt
720
-
721
- def Pattern_TypeTest_module_apply (tpt : TypeTree )(implicit ctx : Context ): TypeTest =
722
- withDefaultPos(ctx => tpd.Typed (untpd.Ident (nme.WILDCARD )(ctx.source).withType(tpt.tpe)(ctx), tpt)(ctx))
723
-
724
- def Pattern_TypeTest_module_copy (original : TypeTest )(tpt : TypeTree )(implicit ctx : Context ): TypeTest =
725
- tpd.cpy.Typed (original)(untpd.Ident (nme.WILDCARD ).withSpan(original.span).withType(tpt.tpe), tpt)
726
-
727
- //
728
- // TYPE TREES
729
- //
730
-
731
603
type TypeOrBoundsTree = tpd.Tree
732
604
733
605
def TypeOrBoundsTree_tpe (self : TypeOrBoundsTree )(implicit ctx : Context ): Type = self.tpe.stripTypeVar
@@ -962,6 +834,130 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
962
834
case _ => None
963
835
}
964
836
837
+ //
838
+ // CASES
839
+ //
840
+
841
+ type CaseDef = tpd.CaseDef
842
+
843
+ def CaseDef_pattern (self : CaseDef )(implicit ctx : Context ): Pattern = self.pat
844
+ def CaseDef_guard (self : CaseDef )(implicit ctx : Context ): Option [Term ] = optional(self.guard)
845
+ def CaseDef_rhs (self : CaseDef )(implicit ctx : Context ): Term = self.body
846
+
847
+ def CaseDef_module_apply (pattern : Pattern , guard : Option [Term ], body : Term )(implicit ctx : Context ): CaseDef =
848
+ tpd.CaseDef (pattern, guard.getOrElse(tpd.EmptyTree ), body)
849
+
850
+ def CaseDef_module_copy (original : CaseDef )(pattern : Pattern , guard : Option [Term ], body : Term )(implicit ctx : Context ): CaseDef =
851
+ tpd.cpy.CaseDef (original)(pattern, guard.getOrElse(tpd.EmptyTree ), body)
852
+
853
+ type TypeCaseDef = tpd.CaseDef
854
+
855
+ def TypeCaseDef_pattern (self : TypeCaseDef )(implicit ctx : Context ): TypeTree = self.pat
856
+ def TypeCaseDef_rhs (self : TypeCaseDef )(implicit ctx : Context ): TypeTree = self.body
857
+
858
+ def TypeCaseDef_module_apply (pattern : TypeTree , body : TypeTree )(implicit ctx : Context ): TypeCaseDef =
859
+ tpd.CaseDef (pattern, tpd.EmptyTree , body)
860
+
861
+ def TypeCaseDef_module_copy (original : TypeCaseDef )(pattern : TypeTree , body : TypeTree )(implicit ctx : Context ): TypeCaseDef =
862
+ tpd.cpy.CaseDef (original)(pattern, tpd.EmptyTree , body)
863
+
864
+ //
865
+ // PATTERNS
866
+ //
867
+
868
+ type Pattern = tpd.Tree
869
+
870
+ def Pattern_pos (self : Pattern )(implicit ctx : Context ): Position = self.sourcePos
871
+ def Pattern_tpe (self : Pattern )(implicit ctx : Context ): Type = self.tpe.stripTypeVar
872
+ def Pattern_symbol (self : Pattern )(implicit ctx : Context ): Symbol = self.symbol
873
+
874
+ type Value = tpd.Tree
875
+
876
+ def matchPattern_Value (pattern : Pattern ): Option [Value ] = pattern match {
877
+ case lit : tpd.Literal => Some (lit)
878
+ case ref : tpd.RefTree if ref.isTerm => Some (ref)
879
+ case ths : tpd.This => Some (ths)
880
+ case _ => None
881
+ }
882
+
883
+ def Pattern_Value_value (self : Value )(implicit ctx : Context ): Term = self
884
+
885
+ def Pattern_Value_module_apply (term : Term )(implicit ctx : Context ): Value = term match {
886
+ case lit : tpd.Literal => lit
887
+ case ref : tpd.RefTree if ref.isTerm => ref
888
+ case ths : tpd.This => ths
889
+ }
890
+ def Pattern_Value_module_copy (original : Value )(term : Term )(implicit ctx : Context ): Value = term match {
891
+ case lit : tpd.Literal => tpd.cpy.Literal (original)(lit.const)
892
+ case ref : tpd.RefTree if ref.isTerm => tpd.cpy.Ref (original.asInstanceOf [tpd.RefTree ])(ref.name)
893
+ case ths : tpd.This => tpd.cpy.This (original)(ths.qual)
894
+ }
895
+
896
+ type Bind = tpd.Bind
897
+
898
+ def matchPattern_Bind (x : Pattern )(implicit ctx : Context ): Option [Bind ] = x match {
899
+ case x : tpd.Bind if x.name.isTermName => Some (x)
900
+ case _ => None
901
+ }
902
+
903
+ def Pattern_Bind_name (self : Bind )(implicit ctx : Context ): String = self.name.toString
904
+
905
+ def Pattern_Bind_pattern (self : Bind )(implicit ctx : Context ): Pattern = self.body
906
+
907
+ def Pattern_Bind_module_copy (original : Bind )(name : String , pattern : Pattern )(implicit ctx : Context ): Bind =
908
+ withDefaultPos(ctx => tpd.cpy.Bind (original)(name.toTermName, pattern)(ctx))
909
+
910
+ type Unapply = tpd.UnApply
911
+
912
+ def matchPattern_Unapply (pattern : Pattern )(implicit ctx : Context ): Option [Unapply ] = pattern match {
913
+ case pattern @ Trees .UnApply (_, _, _) => Some (pattern)
914
+ case Trees .Typed (pattern @ Trees .UnApply (_, _, _), _) => Some (pattern)
915
+ case _ => None
916
+ }
917
+
918
+ def Pattern_Unapply_fun (self : Unapply )(implicit ctx : Context ): Term = self.fun
919
+ def Pattern_Unapply_implicits (self : Unapply )(implicit ctx : Context ): List [Term ] = self.implicits
920
+ def Pattern_Unapply_patterns (self : Unapply )(implicit ctx : Context ): List [Pattern ] = effectivePatterns(self.patterns)
921
+
922
+ def Pattern_Unapply_module_copy (original : Unapply )(fun : Term , implicits : List [Term ], patterns : List [Pattern ])(implicit ctx : Context ): Unapply =
923
+ withDefaultPos(ctx => tpd.cpy.UnApply (original)(fun, implicits, patterns)(ctx))
924
+
925
+ private def effectivePatterns (patterns : List [Pattern ]): List [Pattern ] = patterns match {
926
+ case patterns0 :+ Trees .SeqLiteral (elems, _) => patterns0 ::: elems
927
+ case _ => patterns
928
+ }
929
+
930
+ type Alternatives = tpd.Alternative
931
+
932
+ def matchPattern_Alternatives (pattern : Pattern )(implicit ctx : Context ): Option [Alternatives ] = pattern match {
933
+ case pattern : tpd.Alternative => Some (pattern)
934
+ case _ => None
935
+ }
936
+
937
+ def Pattern_Alternatives_patterns (self : Alternatives )(implicit ctx : Context ): List [Pattern ] = self.trees
938
+
939
+ def Pattern_Alternatives_module_apply (patterns : List [Pattern ])(implicit ctx : Context ): Alternatives =
940
+ withDefaultPos(ctx => tpd.Alternative (patterns)(ctx))
941
+
942
+ def Pattern_Alternatives_module_copy (original : Alternatives )(patterns : List [Pattern ])(implicit ctx : Context ): Alternatives =
943
+ tpd.cpy.Alternative (original)(patterns)
944
+
945
+ type TypeTest = tpd.Typed
946
+
947
+ def matchPattern_TypeTest (pattern : Pattern )(implicit ctx : Context ): Option [TypeTest ] = pattern match {
948
+ case Trees .Typed (_ : tpd.UnApply , _) => None
949
+ case pattern : tpd.Typed => Some (pattern)
950
+ case _ => None
951
+ }
952
+
953
+ def Pattern_TypeTest_tpt (self : TypeTest )(implicit ctx : Context ): TypeTree = self.tpt
954
+
955
+ def Pattern_TypeTest_module_apply (tpt : TypeTree )(implicit ctx : Context ): TypeTest =
956
+ withDefaultPos(ctx => tpd.Typed (untpd.Ident (nme.WILDCARD )(ctx.source).withType(tpt.tpe)(ctx), tpt)(ctx))
957
+
958
+ def Pattern_TypeTest_module_copy (original : TypeTest )(tpt : TypeTree )(implicit ctx : Context ): TypeTest =
959
+ tpd.cpy.Typed (original)(untpd.Ident (nme.WILDCARD ).withSpan(original.span).withType(tpt.tpe), tpt)
960
+
965
961
//
966
962
// TYPES
967
963
//
0 commit comments