@@ -109,6 +109,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
109
109
type Statement = tpd.Tree
110
110
111
111
def matchStatement (tree : Tree )(given Context ): Option [Statement ] = tree match {
112
+ case _ : PatternTree => None
112
113
case tree if tree.isTerm => Some (tree)
113
114
case _ => matchDefinition(tree)
114
115
}
@@ -884,14 +885,14 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
884
885
case _ => None
885
886
}
886
887
887
- def CaseDef_pattern (self : CaseDef )(given Context ): Pattern = self.pat
888
+ def CaseDef_pattern (self : CaseDef )(given Context ): Tree = self.pat
888
889
def CaseDef_guard (self : CaseDef )(given Context ): Option [Term ] = optional(self.guard)
889
890
def CaseDef_rhs (self : CaseDef )(given Context ): Term = self.body
890
891
891
- def CaseDef_module_apply (pattern : Pattern , guard : Option [Term ], body : Term )(given Context ): CaseDef =
892
+ def CaseDef_module_apply (pattern : Tree , guard : Option [Term ], body : Term )(given Context ): CaseDef =
892
893
tpd.CaseDef (pattern, guard.getOrElse(tpd.EmptyTree ), body)
893
894
894
- def CaseDef_module_copy (original : CaseDef )(pattern : Pattern , guard : Option [Term ], body : Term )(given Context ): CaseDef =
895
+ def CaseDef_module_copy (original : CaseDef )(pattern : Tree , guard : Option [Term ], body : Term )(given Context ): CaseDef =
895
896
tpd.cpy.CaseDef (original)(pattern, guard.getOrElse(tpd.EmptyTree ), body)
896
897
897
898
type TypeCaseDef = tpd.CaseDef
@@ -910,114 +911,55 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
910
911
def TypeCaseDef_module_copy (original : TypeCaseDef )(pattern : TypeTree , body : TypeTree )(given Context ): TypeCaseDef =
911
912
tpd.cpy.CaseDef (original)(pattern, tpd.EmptyTree , body)
912
913
913
- //
914
- // PATTERNS
915
- //
916
-
917
- type Pattern = tpd.Tree
918
-
919
- def Pattern_pos (self : Pattern )(given Context ): Position = self.sourcePos
920
- def Pattern_tpe (self : Pattern )(given Context ): Type = self.tpe.stripTypeVar
921
- def Pattern_symbol (self : Pattern )(given Context ): Symbol = self.symbol
922
-
923
- type Value = tpd.Tree
924
-
925
- def matchPattern_Value (pattern : Pattern ): Option [Value ] = pattern match {
926
- case lit : tpd.Literal => Some (lit)
927
- case ref : tpd.RefTree if ref.isTerm && ! tpd.isWildcardArg(ref) => Some (ref)
928
- case ths : tpd.This => Some (ths)
929
- case _ => None
930
- }
931
-
932
- def Pattern_Value_value (self : Value )(given Context ): Term = self
933
-
934
- def Pattern_Value_module_apply (term : Term )(given Context ): Value = term match {
935
- case lit : tpd.Literal => lit
936
- case ref : tpd.RefTree if ref.isTerm => ref
937
- case ths : tpd.This => ths
938
- }
939
- def Pattern_Value_module_copy (original : Value )(term : Term )(given Context ): Value = term match {
940
- case lit : tpd.Literal => tpd.cpy.Literal (original)(lit.const)
941
- case ref : tpd.RefTree if ref.isTerm => tpd.cpy.Ref (original.asInstanceOf [tpd.RefTree ])(ref.name)
942
- case ths : tpd.This => tpd.cpy.This (original)(ths.qual)
943
- }
944
-
945
914
type Bind = tpd.Bind
946
915
947
- def matchPattern_Bind (x : Pattern )(given Context ): Option [Bind ] = x match {
916
+ def matchTree_Bind (x : Tree )(given Context ): Option [Bind ] = x match {
948
917
case x : tpd.Bind if x.name.isTermName => Some (x)
949
918
case _ => None
950
919
}
951
920
952
- def Pattern_Bind_name (self : Bind )(given Context ): String = self.name.toString
921
+ def Tree_Bind_name (self : Bind )(given Context ): String = self.name.toString
953
922
954
- def Pattern_Bind_pattern (self : Bind )(given Context ): Pattern = self.body
923
+ def Tree_Bind_pattern (self : Bind )(given Context ): Tree = self.body
955
924
956
- def Pattern_Bind_module_copy (original : Bind )(name : String , pattern : Pattern )(given Context ): Bind =
925
+ def Tree_Bind_module_copy (original : Bind )(name : String , pattern : Tree )(given Context ): Bind =
957
926
withDefaultPos(tpd.cpy.Bind (original)(name.toTermName, pattern))
958
927
959
928
type Unapply = tpd.UnApply
960
929
961
- def matchPattern_Unapply (pattern : Pattern )(given Context ): Option [Unapply ] = pattern match {
930
+ def matchTree_Unapply (pattern : Tree )(given Context ): Option [Unapply ] = pattern match {
962
931
case pattern @ Trees .UnApply (_, _, _) => Some (pattern)
963
932
case Trees .Typed (pattern @ Trees .UnApply (_, _, _), _) => Some (pattern)
964
933
case _ => None
965
934
}
966
935
967
- def Pattern_Unapply_fun (self : Unapply )(given Context ): Term = self.fun
968
- def Pattern_Unapply_implicits (self : Unapply )(given Context ): List [Term ] = self.implicits
969
- def Pattern_Unapply_patterns (self : Unapply )(given Context ): List [Pattern ] = effectivePatterns(self.patterns)
936
+ def Tree_Unapply_fun (self : Unapply )(given Context ): Term = self.fun
937
+ def Tree_Unapply_implicits (self : Unapply )(given Context ): List [Term ] = self.implicits
938
+ def Tree_Unapply_patterns (self : Unapply )(given Context ): List [Tree ] = effectivePatterns(self.patterns)
970
939
971
- def Pattern_Unapply_module_copy (original : Unapply )(fun : Term , implicits : List [Term ], patterns : List [Pattern ])(given Context ): Unapply =
940
+ def Tree_Unapply_module_copy (original : Unapply )(fun : Term , implicits : List [Term ], patterns : List [Tree ])(given Context ): Unapply =
972
941
withDefaultPos(tpd.cpy.UnApply (original)(fun, implicits, patterns))
973
942
974
- private def effectivePatterns (patterns : List [Pattern ]): List [Pattern ] = patterns match {
943
+ private def effectivePatterns (patterns : List [Tree ]): List [Tree ] = patterns match {
975
944
case patterns0 :+ Trees .SeqLiteral (elems, _) => patterns0 ::: elems
976
945
case _ => patterns
977
946
}
978
947
979
948
type Alternatives = tpd.Alternative
980
949
981
- def matchPattern_Alternatives (pattern : Pattern )(given Context ): Option [Alternatives ] = pattern match {
950
+ def matchTree_Alternatives (pattern : Tree )(given Context ): Option [Alternatives ] = pattern match {
982
951
case pattern : tpd.Alternative => Some (pattern)
983
952
case _ => None
984
953
}
985
954
986
- def Pattern_Alternatives_patterns (self : Alternatives )(given Context ): List [Pattern ] = self.trees
955
+ def Tree_Alternatives_patterns (self : Alternatives )(given Context ): List [Tree ] = self.trees
987
956
988
- def Pattern_Alternatives_module_apply (patterns : List [Pattern ])(given Context ): Alternatives =
957
+ def Tree_Alternatives_module_apply (patterns : List [Tree ])(given Context ): Alternatives =
989
958
withDefaultPos(tpd.Alternative (patterns))
990
959
991
- def Pattern_Alternatives_module_copy (original : Alternatives )(patterns : List [Pattern ])(given Context ): Alternatives =
960
+ def Tree_Alternatives_module_copy (original : Alternatives )(patterns : List [Tree ])(given Context ): Alternatives =
992
961
tpd.cpy.Alternative (original)(patterns)
993
962
994
- type TypeTest = tpd.Typed
995
-
996
- def matchPattern_TypeTest (pattern : Pattern )(given Context ): Option [TypeTest ] = pattern match {
997
- case Trees .Typed (_ : tpd.UnApply , _) => None
998
- case pattern : tpd.Typed => Some (pattern)
999
- case _ => None
1000
- }
1001
-
1002
- def Pattern_TypeTest_tpt (self : TypeTest )(given Context ): TypeTree = self.tpt
1003
-
1004
- def Pattern_TypeTest_module_apply (tpt : TypeTree )(given ctx : Context ): TypeTest =
1005
- withDefaultPos(tpd.Typed (untpd.Ident (nme.WILDCARD )(ctx.source).withType(tpt.tpe), tpt))
1006
-
1007
- def Pattern_TypeTest_module_copy (original : TypeTest )(tpt : TypeTree )(given Context ): TypeTest =
1008
- tpd.cpy.Typed (original)(untpd.Ident (nme.WILDCARD ).withSpan(original.span).withType(tpt.tpe), tpt)
1009
-
1010
- type WildcardPattern = tpd.Ident
1011
-
1012
- def matchPattern_WildcardPattern (pattern : Pattern )(given Context ): Option [WildcardPattern ] =
1013
- pattern match {
1014
- case pattern : tpd.Ident if tpd.isWildcardArg(pattern) => Some (pattern)
1015
- case _ => None
1016
- }
1017
-
1018
- def Pattern_WildcardPattern_module_apply (tpe : TypeOrBounds )(given Context ): WildcardPattern =
1019
- untpd.Ident (nme.WILDCARD ).withType(tpe)
1020
-
1021
963
//
1022
964
// TYPES
1023
965
//
@@ -1461,9 +1403,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
1461
1403
def Symbol_tree (self : Symbol )(given Context ): Tree =
1462
1404
FromSymbol .definitionFromSym(self)
1463
1405
1464
- def Symbol_pattern (self : Symbol )(given ctx : Context ): Pattern =
1465
- FromSymbol .definitionFromSym(self)
1466
-
1467
1406
def Symbol_privateWithin (self : Symbol )(given Context ): Option [Type ] = {
1468
1407
val within = self.privateWithin
1469
1408
if (within.exists && ! self.is(core.Flags .Protected )) Some (within.typeRef)
0 commit comments