@@ -109,6 +109,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
109109 type Statement = tpd.Tree
110110
111111 def matchStatement (tree : Tree )(given Context ): Option [Statement ] = tree match {
112+ case _ : PatternTree => None
112113 case tree if tree.isTerm => Some (tree)
113114 case _ => matchDefinition(tree)
114115 }
@@ -231,6 +232,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
231232 type Term = tpd.Tree
232233
233234 def matchTerm (tree : Tree )(given Context ): Option [Term ] = tree match {
235+ case _ : PatternTree => None
234236 case x : tpd.SeqLiteral => Some (tree)
235237 case _ if tree.isTerm => Some (tree)
236238 case _ => None
@@ -884,14 +886,14 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
884886 case _ => None
885887 }
886888
887- def CaseDef_pattern (self : CaseDef )(given Context ): Pattern = self.pat
889+ def CaseDef_pattern (self : CaseDef )(given Context ): Tree = self.pat
888890 def CaseDef_guard (self : CaseDef )(given Context ): Option [Term ] = optional(self.guard)
889891 def CaseDef_rhs (self : CaseDef )(given Context ): Term = self.body
890892
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 =
892894 tpd.CaseDef (pattern, guard.getOrElse(tpd.EmptyTree ), body)
893895
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 =
895897 tpd.cpy.CaseDef (original)(pattern, guard.getOrElse(tpd.EmptyTree ), body)
896898
897899 type TypeCaseDef = tpd.CaseDef
@@ -910,114 +912,55 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
910912 def TypeCaseDef_module_copy (original : TypeCaseDef )(pattern : TypeTree , body : TypeTree )(given Context ): TypeCaseDef =
911913 tpd.cpy.CaseDef (original)(pattern, tpd.EmptyTree , body)
912914
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-
945915 type Bind = tpd.Bind
946916
947- def matchPattern_Bind (x : Pattern )(given Context ): Option [Bind ] = x match {
917+ def matchTree_Bind (x : Tree )(given Context ): Option [Bind ] = x match {
948918 case x : tpd.Bind if x.name.isTermName => Some (x)
949919 case _ => None
950920 }
951921
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
953923
954- def Pattern_Bind_pattern (self : Bind )(given Context ): Pattern = self.body
924+ def Tree_Bind_pattern (self : Bind )(given Context ): Tree = self.body
955925
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 =
957927 withDefaultPos(tpd.cpy.Bind (original)(name.toTermName, pattern))
958928
959929 type Unapply = tpd.UnApply
960930
961- def matchPattern_Unapply (pattern : Pattern )(given Context ): Option [Unapply ] = pattern match {
931+ def matchTree_Unapply (pattern : Tree )(given Context ): Option [Unapply ] = pattern match {
962932 case pattern @ Trees .UnApply (_, _, _) => Some (pattern)
963933 case Trees .Typed (pattern @ Trees .UnApply (_, _, _), _) => Some (pattern)
964934 case _ => None
965935 }
966936
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)
970940
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 =
972942 withDefaultPos(tpd.cpy.UnApply (original)(fun, implicits, patterns))
973943
974- private def effectivePatterns (patterns : List [Pattern ]): List [Pattern ] = patterns match {
944+ private def effectivePatterns (patterns : List [Tree ]): List [Tree ] = patterns match {
975945 case patterns0 :+ Trees .SeqLiteral (elems, _) => patterns0 ::: elems
976946 case _ => patterns
977947 }
978948
979949 type Alternatives = tpd.Alternative
980950
981- def matchPattern_Alternatives (pattern : Pattern )(given Context ): Option [Alternatives ] = pattern match {
951+ def matchTree_Alternatives (pattern : Tree )(given Context ): Option [Alternatives ] = pattern match {
982952 case pattern : tpd.Alternative => Some (pattern)
983953 case _ => None
984954 }
985955
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
987957
988- def Pattern_Alternatives_module_apply (patterns : List [Pattern ])(given Context ): Alternatives =
958+ def Tree_Alternatives_module_apply (patterns : List [Tree ])(given Context ): Alternatives =
989959 withDefaultPos(tpd.Alternative (patterns))
990960
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 =
992962 tpd.cpy.Alternative (original)(patterns)
993963
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-
1021964 //
1022965 // TYPES
1023966 //
@@ -1461,9 +1404,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
14611404 def Symbol_tree (self : Symbol )(given Context ): Tree =
14621405 FromSymbol .definitionFromSym(self)
14631406
1464- def Symbol_pattern (self : Symbol )(given ctx : Context ): Pattern =
1465- FromSymbol .definitionFromSym(self)
1466-
14671407 def Symbol_privateWithin (self : Symbol )(given Context ): Option [Type ] = {
14681408 val within = self.privateWithin
14691409 if (within.exists && ! self.is(core.Flags .Protected )) Some (within.typeRef)
0 commit comments