@@ -16,34 +16,34 @@ object TastyImpl extends scala.tasty.Tasty {
16
16
17
17
// ===== Quotes ===================================================
18
18
19
- implicit def QuotedExprDeco [T ](x : quoted.Expr [T ]): AbstractQuotedExpr = new AbstractQuotedExpr {
19
+ def QuotedExprDeco [T ](x : quoted.Expr [T ]): AbstractQuotedExpr = new AbstractQuotedExpr {
20
20
def toTasty (implicit ctx : Context ): Term = PickledQuotes .quotedExprToTree(x)
21
21
}
22
22
23
- implicit def QuotedTypeDeco [T ](x : quoted.Type [T ]): AbstractQuotedType = new AbstractQuotedType {
23
+ def QuotedTypeDeco [T ](x : quoted.Type [T ]): AbstractQuotedType = new AbstractQuotedType {
24
24
def toTasty (implicit ctx : Context ): TypeTree = PickledQuotes .quotedTypeToTree(x)
25
25
}
26
26
27
27
// ===== Contexts =================================================
28
28
29
29
type Context = Contexts .Context
30
30
31
- implicit def ContextDeco (ctx : Context ): AbstractContext = new AbstractContext {
31
+ def ContextDeco (ctx : Context ): AbstractContext = new AbstractContext {
32
32
def owner : Definition = FromSymbol .definition(ctx.owner)(ctx)
33
33
}
34
34
35
35
// ===== Id =======================================================
36
36
37
37
type Id = untpd.Ident
38
38
39
- implicit def IdDeco (x : Id ): AbstractId = new AbstractId {
39
+ def IdDeco (x : Id ): AbstractId = new AbstractId {
40
40
def pos (implicit ctx : Context ): Position = x.pos
41
41
}
42
42
43
43
def idClassTag : ClassTag [Id ] = implicitly[ClassTag [Id ]]
44
44
45
- val Id : IdExtractor = new IdExtractor {
46
- def unapply (x : Id ) = x match {
45
+ object Id extends IdExtractor {
46
+ def unapply (x : Id ): Option [ String ] = x match {
47
47
case x : untpd.Ident => Some (x.name.toString) // TODO how to make sure it is not a Ident or TypeIdent? Check x.tpe?
48
48
case _ => None
49
49
}
@@ -53,22 +53,22 @@ object TastyImpl extends scala.tasty.Tasty {
53
53
54
54
type Tree = tpd.Tree
55
55
56
- implicit def TreeDeco (t : Tree ): AbstractTree = new AbstractTree {
56
+ def TreeDeco (t : Tree ): AbstractTree = new AbstractTree {
57
57
def pos (implicit ctx : Context ): Position = t.pos
58
58
}
59
59
60
60
type PackageClause = tpd.PackageDef
61
61
62
62
def packageClauseClassTag : ClassTag [PackageClause ] = implicitly[ClassTag [PackageClause ]]
63
63
64
- val PackageClause : PackageClauseExtractor = new PackageClauseExtractor {
64
+ object PackageClause extends PackageClauseExtractor {
65
65
def unapply (x : PackageClause )(implicit ctx : Context ): Option [(Term , List [Tree ])] = x match {
66
66
case x : tpd.PackageDef @ unchecked => Some ((x.pid, x.stats))
67
67
case _ => None
68
68
}
69
69
}
70
70
71
- implicit def PackageClauseDeco (x : PackageClause ): AbstractPackageClause = new AbstractPackageClause {
71
+ def PackageClauseDeco (x : PackageClause ): AbstractPackageClause = new AbstractPackageClause {
72
72
override def definition : Definition = ???
73
73
}
74
74
@@ -80,7 +80,7 @@ object TastyImpl extends scala.tasty.Tasty {
80
80
81
81
def importClassTag : ClassTag [Import ] = implicitly[ClassTag [Import ]]
82
82
83
- val Import : ImportExtractor = new ImportExtractor {
83
+ object Import extends ImportExtractor {
84
84
def unapply (x : Import )(implicit ctx : Context ): Option [(Term , List [ImportSelector ])] = x match {
85
85
case x : tpd.Import @ unchecked => Some ((x.expr, x.selectors))
86
86
case _ => None
@@ -91,21 +91,21 @@ object TastyImpl extends scala.tasty.Tasty {
91
91
92
92
def importSelectorClassTag : ClassTag [ImportSelector ] = implicitly[ClassTag [ImportSelector ]]
93
93
94
- val SimpleSelector : SimpleSelectorExtractor = new SimpleSelectorExtractor {
94
+ object SimpleSelector extends SimpleSelectorExtractor {
95
95
def unapply (x : ImportSelector )(implicit ctx : Context ): Option [Id ] = x match {
96
96
case x : untpd.Ident => Some (x) // TODO make sure it will not match other idents
97
97
case _ => None
98
98
}
99
99
}
100
100
101
- val RenameSelector : RenameSelectorExtractor = new RenameSelectorExtractor {
101
+ object RenameSelector extends RenameSelectorExtractor {
102
102
def unapply (x : ImportSelector )(implicit ctx : Context ): Option [(Id , Id )] = x match {
103
103
case Trees .Thicket ((id1 : untpd.Ident ) :: (id2 : untpd.Ident ) :: Nil ) if id2.name != nme.WILDCARD => Some (id1, id2)
104
104
case _ => None
105
105
}
106
106
}
107
107
108
- val OmitSelector : OmitSelectorExtractor = new OmitSelectorExtractor {
108
+ object OmitSelector extends OmitSelectorExtractor {
109
109
def unapply (x : ImportSelector )(implicit ctx : Context ): Option [Id ] = x match {
110
110
case Trees .Thicket ((id : untpd.Ident ) :: Trees .Ident (nme.WILDCARD ) :: Nil ) => Some (id)
111
111
case _ => None
@@ -116,7 +116,7 @@ object TastyImpl extends scala.tasty.Tasty {
116
116
117
117
type Definition = tpd.Tree
118
118
119
- implicit def DefinitionDeco (x : Definition ): AbstractDefinition = new AbstractDefinition {
119
+ def DefinitionDeco (x : Definition ): AbstractDefinition = new AbstractDefinition {
120
120
121
121
def owner (implicit ctx : Context ): Definition = FromSymbol .definition(x.symbol.owner)
122
122
@@ -141,7 +141,7 @@ object TastyImpl extends scala.tasty.Tasty {
141
141
142
142
def classDefClassTag : ClassTag [ClassDef ] = implicitly[ClassTag [ClassDef ]]
143
143
144
- val ClassDef : ClassDefExtractor = new ClassDefExtractor {
144
+ object ClassDef extends ClassDefExtractor {
145
145
def unapply (x : ClassDef )(implicit ctx : Context ): Option [(String , DefDef , List [Parent ], Option [ValDef ], List [Statement ])] = x match {
146
146
case x : tpd.TypeDef @ unchecked if x.isClassDef =>
147
147
val temp @ Trees .Template (constr, parents, self, _) = x.rhs
@@ -157,7 +157,7 @@ object TastyImpl extends scala.tasty.Tasty {
157
157
158
158
def defDefClassTag : ClassTag [DefDef ] = implicitly[ClassTag [DefDef ]]
159
159
160
- val DefDef : DefDefExtractor = new DefDefExtractor {
160
+ object DefDef extends DefDefExtractor {
161
161
def unapply (x : DefDef )(implicit ctx : Context ): Option [(String , List [TypeDef ], List [List [ValDef ]], TypeTree , Option [Term ])] = x match {
162
162
case x : tpd.DefDef @ unchecked =>
163
163
Some ((x.name.toString, x.tparams, x.vparamss, x.tpt, if (x.rhs.isEmpty) None else Some (x.rhs)))
@@ -171,7 +171,7 @@ object TastyImpl extends scala.tasty.Tasty {
171
171
172
172
def valDefClassTag : ClassTag [ValDef ] = implicitly[ClassTag [ValDef ]]
173
173
174
- val ValDef : ValDefExtractor = new ValDefExtractor {
174
+ object ValDef extends ValDefExtractor {
175
175
def unapply (x : ValDef )(implicit ctx : Context ): Option [(String , TypeTree , Option [Term ])] = x match {
176
176
case x : tpd.ValDef @ unchecked =>
177
177
Some ((x.name.toString, x.tpt, if (x.rhs.isEmpty) None else Some (x.rhs)))
@@ -185,7 +185,7 @@ object TastyImpl extends scala.tasty.Tasty {
185
185
186
186
def typeDefClassTag : ClassTag [TypeDef ] = implicitly[ClassTag [TypeDef ]]
187
187
188
- val TypeDef : TypeDefExtractor = new TypeDefExtractor {
188
+ object TypeDef extends TypeDefExtractor {
189
189
def unapply (x : TypeDef )(implicit ctx : Context ): Option [(String , TypeOrBoundsTree /* TypeTree | TypeBoundsTree */ )] = x match {
190
190
case x : tpd.TypeDef @ unchecked if ! x.symbol.isClass => Some ((x.name.toString, x.rhs))
191
191
case _ => None
@@ -196,7 +196,7 @@ object TastyImpl extends scala.tasty.Tasty {
196
196
197
197
def packageDefClassTag : ClassTag [PackageDef ] = implicitly[ClassTag [PackageDef ]]
198
198
199
- val PackageDef : PackageDefExtractor = new PackageDefExtractor {
199
+ object PackageDef extends PackageDefExtractor {
200
200
def unapply (x : PackageDef )(implicit ctx : Context ): Option [(String , List [Statement ])] = x match {
201
201
case x : tpd.PackageDef =>
202
202
// FIXME Do not do this eagerly as it forces everithing in the package to be loaded.
@@ -217,7 +217,7 @@ object TastyImpl extends scala.tasty.Tasty {
217
217
218
218
type Term = tpd.Tree
219
219
220
- implicit def TermDeco (t : Term ): AbstractTerm = new AbstractTerm {
220
+ def TermDeco (t : Term ): AbstractTerm = new AbstractTerm {
221
221
def pos (implicit ctx : Context ): Position = t.pos
222
222
def tpe (implicit ctx : Context ): Types .Type = t.tpe
223
223
}
@@ -385,7 +385,7 @@ object TastyImpl extends scala.tasty.Tasty {
385
385
386
386
def caseDefClassTag : ClassTag [CaseDef ] = implicitly[ClassTag [CaseDef ]]
387
387
388
- val CaseDef : CaseDefExtractor = new CaseDefExtractor {
388
+ object CaseDef extends CaseDefExtractor {
389
389
def unapply (x : CaseDef ): Option [(Pattern , Option [Term ], Term )] = x match {
390
390
case x : tpd.CaseDef @ unchecked =>
391
391
Some (x.pat, if (x.guard.isEmpty) None else Some (x.guard), x.body)
@@ -397,7 +397,7 @@ object TastyImpl extends scala.tasty.Tasty {
397
397
398
398
type Pattern = tpd.Tree
399
399
400
- implicit def PatternDeco (x : Pattern ): AbstractPattern = new AbstractPattern {
400
+ def PatternDeco (x : Pattern ): AbstractPattern = new AbstractPattern {
401
401
def pos (implicit ctx : Context ): Position = x.pos
402
402
def tpe (implicit ctx : Context ): Types .Type = x.tpe.stripTypeVar
403
403
}
@@ -449,15 +449,15 @@ object TastyImpl extends scala.tasty.Tasty {
449
449
450
450
type TypeOrBoundsTree = tpd.Tree
451
451
452
- implicit def TypeOrBoundsTreeDeco (x : TypeOrBoundsTree ): AbstractTypeOrBoundsTree = new AbstractTypeOrBoundsTree {
452
+ def TypeOrBoundsTreeDeco (x : TypeOrBoundsTree ): AbstractTypeOrBoundsTree = new AbstractTypeOrBoundsTree {
453
453
def tpe (implicit ctx : Context ): Type = x.tpe.stripTypeVar
454
454
}
455
455
456
456
// ----- TypeTrees ------------------------------------------------
457
457
458
458
type TypeTree = tpd.Tree
459
459
460
- implicit def TypeTreeDeco (x : TypeTree ): AbstractTypeTree = new AbstractTypeTree {
460
+ def TypeTreeDeco (x : TypeTree ): AbstractTypeTree = new AbstractTypeTree {
461
461
def pos (implicit ctx : Context ): Position = x.pos
462
462
def tpe (implicit ctx : Context ): Types .Type = x.tpe.stripTypeVar
463
463
}
@@ -544,11 +544,11 @@ object TastyImpl extends scala.tasty.Tasty {
544
544
545
545
type TypeBoundsTree = tpd.TypeBoundsTree
546
546
547
- implicit def TypeBoundsTreeDeco (x : TypeBoundsTree ): AbstractTypeBoundsTree = ???
547
+ def TypeBoundsTreeDeco (x : TypeBoundsTree ): AbstractTypeBoundsTree = ???
548
548
549
549
def typeBoundsTreeClassTag : ClassTag [TypeBoundsTree ] = implicitly[ClassTag [TypeBoundsTree ]]
550
550
551
- val TypeBoundsTree : TypeBoundsTreeExtractor = new TypeBoundsTreeExtractor {
551
+ object TypeBoundsTree extends TypeBoundsTreeExtractor {
552
552
def unapply (x : TypeBoundsTree )(implicit ctx : Context ): Option [(TypeTree , TypeTree )] = x match {
553
553
case x : tpd.TypeBoundsTree @ unchecked => Some (x.lo, x.hi)
554
554
case _ => None
@@ -574,7 +574,7 @@ object TastyImpl extends scala.tasty.Tasty {
574
574
def polyTypeClassTag : ClassTag [PolyType ] = implicitly[ClassTag [PolyType ]]
575
575
def typeLambdaClassTag : ClassTag [TypeLambda ] = implicitly[ClassTag [TypeLambda ]]
576
576
577
- implicit def MethodTypeDeco (x : MethodType ): AbstractMethodType = new AbstractMethodType {
577
+ def MethodTypeDeco (x : MethodType ): AbstractMethodType = new AbstractMethodType {
578
578
def isErased : Boolean = x.isErasedMethod
579
579
def isImplicit : Boolean = x.isImplicitMethod
580
580
}
@@ -735,7 +735,7 @@ object TastyImpl extends scala.tasty.Tasty {
735
735
736
736
def typeBoundsClassTag : ClassTag [TypeBounds ] = implicitly[ClassTag [TypeBounds ]]
737
737
738
- val TypeBounds : TypeBoundsExtractor = new TypeBoundsExtractor {
738
+ object TypeBounds extends TypeBoundsExtractor {
739
739
def unapply (x : TypeBounds )(implicit ctx : Context ): Option [(Type , Type )] = x match {
740
740
case x : Types .TypeBounds => Some (x.lo, x.hi)
741
741
case _ => None
@@ -748,15 +748,15 @@ object TastyImpl extends scala.tasty.Tasty {
748
748
749
749
def noPrefixClassTag : ClassTag [NoPrefix ] = implicitly[ClassTag [NoPrefix ]]
750
750
751
- val NoPrefix : NoPrefixExtractor = new NoPrefixExtractor {
751
+ object NoPrefix extends NoPrefixExtractor {
752
752
def unapply (x : NoPrefix )(implicit ctx : Context ): Boolean = x == Types .NoPrefix
753
753
}
754
754
755
755
// ===== Constants ================================================
756
756
757
757
type Constant = Constants .Constant
758
758
759
- implicit def ConstantDeco (x : Constant ): AbstractConstant = new AbstractConstant {
759
+ def ConstantDeco (x : Constant ): AbstractConstant = new AbstractConstant {
760
760
def value : Any = x.value
761
761
}
762
762
@@ -894,13 +894,12 @@ object TastyImpl extends scala.tasty.Tasty {
894
894
895
895
def signatureClassTag : ClassTag [Signature ] = implicitly[ClassTag [Signature ]]
896
896
897
- val Signature : SignatureExtractor = new SignatureExtractor {
897
+ object Signature extends SignatureExtractor {
898
898
def unapply (x : Signature )(implicit ctx : Context ): Option [(List [String ], String )] = {
899
899
Some ((x.paramsSig.map(_.toString), x.resSig.toString))
900
900
}
901
901
}
902
902
903
-
904
903
// ===== Positions ================================================
905
904
906
905
type Position = SourcePosition
0 commit comments