@@ -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
}
@@ -231,6 +232,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
231
232
type Term = tpd.Tree
232
233
233
234
def matchTerm (tree : Tree )(given Context ): Option [Term ] = tree match {
235
+ case _ : PatternTree => None
234
236
case x : tpd.SeqLiteral => Some (tree)
235
237
case _ if tree.isTerm => Some (tree)
236
238
case _ => None
@@ -884,14 +886,14 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
884
886
case _ => None
885
887
}
886
888
887
- def CaseDef_pattern (self : CaseDef )(given Context ): Pattern = self.pat
889
+ def CaseDef_pattern (self : CaseDef )(given Context ): Tree = self.pat
888
890
def CaseDef_guard (self : CaseDef )(given Context ): Option [Term ] = optional(self.guard)
889
891
def CaseDef_rhs (self : CaseDef )(given Context ): Term = self.body
890
892
891
- def CaseDef_module_apply (pattern : Pattern , guard : Option [Term ], body : Term )(given Context ): CaseDef =
893
+ def CaseDef_module_apply (pattern : Tree , guard : Option [Term ], body : Term )(given Context ): CaseDef =
892
894
tpd.CaseDef (pattern, guard.getOrElse(tpd.EmptyTree ), body)
893
895
894
- def CaseDef_module_copy (original : CaseDef )(pattern : Pattern , guard : Option [Term ], body : Term )(given Context ): CaseDef =
896
+ def CaseDef_module_copy (original : CaseDef )(pattern : Tree , guard : Option [Term ], body : Term )(given Context ): CaseDef =
895
897
tpd.cpy.CaseDef (original)(pattern, guard.getOrElse(tpd.EmptyTree ), body)
896
898
897
899
type TypeCaseDef = tpd.CaseDef
@@ -910,114 +912,55 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
910
912
def TypeCaseDef_module_copy (original : TypeCaseDef )(pattern : TypeTree , body : TypeTree )(given Context ): TypeCaseDef =
911
913
tpd.cpy.CaseDef (original)(pattern, tpd.EmptyTree , body)
912
914
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
915
type Bind = tpd.Bind
946
916
947
- def matchPattern_Bind (x : Pattern )(given Context ): Option [Bind ] = x match {
917
+ def matchTree_Bind (x : Tree )(given Context ): Option [Bind ] = x match {
948
918
case x : tpd.Bind if x.name.isTermName => Some (x)
949
919
case _ => None
950
920
}
951
921
952
- def Pattern_Bind_name (self : Bind )(given Context ): String = self.name.toString
922
+ def Tree_Bind_name (self : Bind )(given Context ): String = self.name.toString
953
923
954
- def Pattern_Bind_pattern (self : Bind )(given Context ): Pattern = self.body
924
+ def Tree_Bind_pattern (self : Bind )(given Context ): Tree = self.body
955
925
956
- def Pattern_Bind_module_copy (original : Bind )(name : String , pattern : Pattern )(given Context ): Bind =
926
+ def Tree_Bind_module_copy (original : Bind )(name : String , pattern : Tree )(given Context ): Bind =
957
927
withDefaultPos(tpd.cpy.Bind (original)(name.toTermName, pattern))
958
928
959
929
type Unapply = tpd.UnApply
960
930
961
- def matchPattern_Unapply (pattern : Pattern )(given Context ): Option [Unapply ] = pattern match {
931
+ def matchTree_Unapply (pattern : Tree )(given Context ): Option [Unapply ] = pattern match {
962
932
case pattern @ Trees .UnApply (_, _, _) => Some (pattern)
963
933
case Trees .Typed (pattern @ Trees .UnApply (_, _, _), _) => Some (pattern)
964
934
case _ => None
965
935
}
966
936
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)
937
+ def Tree_Unapply_fun (self : Unapply )(given Context ): Term = self.fun
938
+ def Tree_Unapply_implicits (self : Unapply )(given Context ): List [Term ] = self.implicits
939
+ def Tree_Unapply_patterns (self : Unapply )(given Context ): List [Tree ] = effectivePatterns(self.patterns)
970
940
971
- def Pattern_Unapply_module_copy (original : Unapply )(fun : Term , implicits : List [Term ], patterns : List [Pattern ])(given Context ): Unapply =
941
+ def Tree_Unapply_module_copy (original : Unapply )(fun : Term , implicits : List [Term ], patterns : List [Tree ])(given Context ): Unapply =
972
942
withDefaultPos(tpd.cpy.UnApply (original)(fun, implicits, patterns))
973
943
974
- private def effectivePatterns (patterns : List [Pattern ]): List [Pattern ] = patterns match {
944
+ private def effectivePatterns (patterns : List [Tree ]): List [Tree ] = patterns match {
975
945
case patterns0 :+ Trees .SeqLiteral (elems, _) => patterns0 ::: elems
976
946
case _ => patterns
977
947
}
978
948
979
949
type Alternatives = tpd.Alternative
980
950
981
- def matchPattern_Alternatives (pattern : Pattern )(given Context ): Option [Alternatives ] = pattern match {
951
+ def matchTree_Alternatives (pattern : Tree )(given Context ): Option [Alternatives ] = pattern match {
982
952
case pattern : tpd.Alternative => Some (pattern)
983
953
case _ => None
984
954
}
985
955
986
- def Pattern_Alternatives_patterns (self : Alternatives )(given Context ): List [Pattern ] = self.trees
956
+ def Tree_Alternatives_patterns (self : Alternatives )(given Context ): List [Tree ] = self.trees
987
957
988
- def Pattern_Alternatives_module_apply (patterns : List [Pattern ])(given Context ): Alternatives =
958
+ def Tree_Alternatives_module_apply (patterns : List [Tree ])(given Context ): Alternatives =
989
959
withDefaultPos(tpd.Alternative (patterns))
990
960
991
- def Pattern_Alternatives_module_copy (original : Alternatives )(patterns : List [Pattern ])(given Context ): Alternatives =
961
+ def Tree_Alternatives_module_copy (original : Alternatives )(patterns : List [Tree ])(given Context ): Alternatives =
992
962
tpd.cpy.Alternative (original)(patterns)
993
963
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
964
//
1022
965
// TYPES
1023
966
//
@@ -1461,9 +1404,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
1461
1404
def Symbol_tree (self : Symbol )(given Context ): Tree =
1462
1405
FromSymbol .definitionFromSym(self)
1463
1406
1464
- def Symbol_pattern (self : Symbol )(given ctx : Context ): Pattern =
1465
- FromSymbol .definitionFromSym(self)
1466
-
1467
1407
def Symbol_privateWithin (self : Symbol )(given Context ): Option [Type ] = {
1468
1408
val within = self.privateWithin
1469
1409
if (within.exists && ! self.is(core.Flags .Protected )) Some (within.typeRef)
0 commit comments