@@ -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 }
@@ -884,14 +885,14 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
884885 case _ => None
885886 }
886887
887- def CaseDef_pattern (self : CaseDef )(given Context ): Pattern = self.pat
888+ def CaseDef_pattern (self : CaseDef )(given Context ): Tree = self.pat
888889 def CaseDef_guard (self : CaseDef )(given Context ): Option [Term ] = optional(self.guard)
889890 def CaseDef_rhs (self : CaseDef )(given Context ): Term = self.body
890891
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 =
892893 tpd.CaseDef (pattern, guard.getOrElse(tpd.EmptyTree ), body)
893894
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 =
895896 tpd.cpy.CaseDef (original)(pattern, guard.getOrElse(tpd.EmptyTree ), body)
896897
897898 type TypeCaseDef = tpd.CaseDef
@@ -910,114 +911,55 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
910911 def TypeCaseDef_module_copy (original : TypeCaseDef )(pattern : TypeTree , body : TypeTree )(given Context ): TypeCaseDef =
911912 tpd.cpy.CaseDef (original)(pattern, tpd.EmptyTree , body)
912913
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-
945914 type Bind = tpd.Bind
946915
947- def matchPattern_Bind (x : Pattern )(given Context ): Option [Bind ] = x match {
916+ def matchTree_Bind (x : Tree )(given Context ): Option [Bind ] = x match {
948917 case x : tpd.Bind if x.name.isTermName => Some (x)
949918 case _ => None
950919 }
951920
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
953922
954- def Pattern_Bind_pattern (self : Bind )(given Context ): Pattern = self.body
923+ def Tree_Bind_pattern (self : Bind )(given Context ): Tree = self.body
955924
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 =
957926 withDefaultPos(tpd.cpy.Bind (original)(name.toTermName, pattern))
958927
959928 type Unapply = tpd.UnApply
960929
961- def matchPattern_Unapply (pattern : Pattern )(given Context ): Option [Unapply ] = pattern match {
930+ def matchTree_Unapply (pattern : Tree )(given Context ): Option [Unapply ] = pattern match {
962931 case pattern @ Trees .UnApply (_, _, _) => Some (pattern)
963932 case Trees .Typed (pattern @ Trees .UnApply (_, _, _), _) => Some (pattern)
964933 case _ => None
965934 }
966935
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)
970939
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 =
972941 withDefaultPos(tpd.cpy.UnApply (original)(fun, implicits, patterns))
973942
974- private def effectivePatterns (patterns : List [Pattern ]): List [Pattern ] = patterns match {
943+ private def effectivePatterns (patterns : List [Tree ]): List [Tree ] = patterns match {
975944 case patterns0 :+ Trees .SeqLiteral (elems, _) => patterns0 ::: elems
976945 case _ => patterns
977946 }
978947
979948 type Alternatives = tpd.Alternative
980949
981- def matchPattern_Alternatives (pattern : Pattern )(given Context ): Option [Alternatives ] = pattern match {
950+ def matchTree_Alternatives (pattern : Tree )(given Context ): Option [Alternatives ] = pattern match {
982951 case pattern : tpd.Alternative => Some (pattern)
983952 case _ => None
984953 }
985954
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
987956
988- def Pattern_Alternatives_module_apply (patterns : List [Pattern ])(given Context ): Alternatives =
957+ def Tree_Alternatives_module_apply (patterns : List [Tree ])(given Context ): Alternatives =
989958 withDefaultPos(tpd.Alternative (patterns))
990959
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 =
992961 tpd.cpy.Alternative (original)(patterns)
993962
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-
1021963 //
1022964 // TYPES
1023965 //
@@ -1461,9 +1403,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
14611403 def Symbol_tree (self : Symbol )(given Context ): Tree =
14621404 FromSymbol .definitionFromSym(self)
14631405
1464- def Symbol_pattern (self : Symbol )(given ctx : Context ): Pattern =
1465- FromSymbol .definitionFromSym(self)
1466-
14671406 def Symbol_privateWithin (self : Symbol )(given Context ): Option [Type ] = {
14681407 val within = self.privateWithin
14691408 if (within.exists && ! self.is(core.Flags .Protected )) Some (within.typeRef)
0 commit comments