@@ -102,13 +102,14 @@ trait TreeOps extends Core {
102
102
abstract class DefDefModule {
103
103
def apply (symbol : DefSymbol , rhsFn : List [Type ] => List [List [Term ]] => Option [Term ])(implicit ctx : Context ): DefDef
104
104
def copy (original : DefDef )(name : String , typeParams : List [TypeDef ], paramss : List [List [ValDef ]], tpt : TypeTree , rhs : Option [Term ])(implicit ctx : Context ): DefDef
105
- def unapply (tree : Tree )(implicit ctx : Context ): Option [(String , List [TypeDef ], List [List [ValDef ]], TypeTree , Option [Term ])]
105
+ def unapply (tree : Tree )(implicit ctx : Context ): Option [(String , List [TypeDef ], List [List [ValDef ]], TypeTree , Option [Term ])] =
106
+ kernel.isDefDef(tree).map(x => (x.name, x.typeParams, x.paramss, x.returnTpt, x.rhs))
106
107
}
107
108
108
109
implicit class DefDefAPI (self : DefDef ) {
109
110
def typeParams (implicit ctx : Context ): List [TypeDef ] = kernel.DefDef_typeParams (self)
110
111
def paramss (implicit ctx : Context ): List [List [ValDef ]] = kernel.DefDef_paramss (self)
111
- def returnTpt (implicit ctx : Context ): TypeTree = kernel.DefDef_returnTpt (self)
112
+ def returnTpt (implicit ctx : Context ): TypeTree = kernel.DefDef_returnTpt (self) // TODO rename to tpt
112
113
def rhs (implicit ctx : Context ): Option [Term ] = kernel.DefDef_rhs (self)
113
114
def symbol (implicit ctx : Context ): DefSymbol = kernel.DefDef_symbol (self)
114
115
}
@@ -142,7 +143,8 @@ trait TreeOps extends Core {
142
143
abstract class TypeDefModule {
143
144
def apply (symbol : TypeSymbol )(implicit ctx : Context ): TypeDef
144
145
def copy (original : TypeDef )(name : String , rhs : TypeOrBoundsTree )(implicit ctx : Context ): TypeDef
145
- def unapply (tree : Tree )(implicit ctx : Context ): Option [(String , TypeOrBoundsTree /* TypeTree | TypeBoundsTree */ )]
146
+ def unapply (tree : Tree )(implicit ctx : Context ): Option [(String , TypeOrBoundsTree /* TypeTree | TypeBoundsTree */ )] =
147
+ kernel.isTypeDef(tree).map(x => (x.name, x.rhs))
146
148
}
147
149
148
150
implicit class TypeDefAPI (self : TypeDef ) {
@@ -153,7 +155,8 @@ trait TreeOps extends Core {
153
155
// PackageDef
154
156
155
157
object IsPackageDef {
156
- def unapply (tree : Tree )(implicit ctx : Context ): Option [PackageDef ] = kernel.isPackageDef(tree)
158
+ def unapply (tree : Tree )(implicit ctx : Context ): Option [PackageDef ] =
159
+ kernel.isPackageDef(tree)
157
160
}
158
161
159
162
implicit class PackageDefAPI (self : PackageDef ) {
@@ -180,6 +183,7 @@ trait TreeOps extends Core {
180
183
/** Matches any term */
181
184
def unapply (tree : Tree )(implicit ctx : Context ): Option [Term ] =
182
185
kernel.isTerm(tree)
186
+
183
187
/** Matches any term */
184
188
def unapply (parent : TermOrTypeTree )(implicit ctx : Context , dummy : DummyImplicit ): Option [Term ] =
185
189
kernel.isTermNotTypeTree(parent)
0 commit comments