@@ -9,11 +9,11 @@ class Derevo(val c: blackbox.Context) {
9
9
type Newtype = NewtypeP [Tree ]
10
10
type NameAndTypes = NameAndTypesP [Tree , c.Type ]
11
11
12
- val CompositeSymbol = typeOf[composite].typeSymbol
13
- val DelegatingSymbol = typeOf[delegating].typeSymbol
14
- val PhantomSymbol = typeOf[phantom].typeSymbol
15
- val PassTypeArgsSymbol = typeOf[PassTypeArgs ].typeSymbol
16
- val KeepRefinementsSymbol = typeOf[KeepRefinements ].typeSymbol
12
+ val CompositeSymbol = typeOf[composite].typeSymbol
13
+ val DelegatingSymbol = typeOf[delegating].typeSymbol
14
+ val PhantomSymbol = typeOf[phantom].typeSymbol
15
+ val PassTypeArgsSymbol = typeOf[PassTypeArgs ].typeSymbol
16
+ val UnqualifiedSymbol = typeOf[Unqualified ].typeSymbol
17
17
18
18
val instanceDefs = Vector (
19
19
)
@@ -224,25 +224,25 @@ class Derevo(val c: blackbox.Context) {
224
224
def fixFirstTypeParam = {
225
225
val nothingT = c.typeOf[Nothing ]
226
226
227
- c.typecheck(mode.call.duplicate, silent = true , withMacrosDisabled = true ) match {
228
- case q " $method[ $nothing, .. $remainingTpes](.. $args) " if nothing.tpe == nothingT =>
229
- q " $method[ $outTyp, .. $remainingTpes](.. $args) "
230
- case q " $method[ $nothing, .. $remainingTpes] " if nothing.tpe == nothingT =>
231
- q " $method[ $outTyp, .. $remainingTpes] "
232
- case EmptyTree =>
233
- mode.call match {
234
- case q " $method(.. $args) " =>
235
- q " $method[ $outTyp](.. $args) "
236
- case q " $method" =>
237
- q " $method[ $outTyp] "
238
- case _ => tree
239
- }
240
- case _ => tree
227
+ c.typecheck(mode.call.duplicate, silent = true , withMacrosDisabled = true ) match {
228
+ case q " $method[ $nothing, .. $remainingTpes](.. $args) " if nothing.tpe == nothingT =>
229
+ q " $method[ $outTyp, .. $remainingTpes](.. $args) "
230
+ case q " $method[ $nothing, .. $remainingTpes] " if nothing.tpe == nothingT =>
231
+ q " $method[ $outTyp, .. $remainingTpes] "
232
+ case EmptyTree =>
233
+ mode.call match {
234
+ case q " $method(.. $args) " =>
235
+ q " $method[ $outTyp](.. $args) "
236
+ case q " $method" =>
237
+ q " $method[ $outTyp] "
238
+ case _ => tree
239
+ }
240
+ case _ => tree
241
+ }
241
242
}
242
- }
243
243
244
244
if (allTparams.isEmpty || allTparams.length <= mode.drop) {
245
- if (mode.keepRefinements ) {
245
+ if (mode.unqualified ) {
246
246
q """
247
247
@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.All", "scalafix:All", "all"))
248
248
implicit val $tn = $fixFirstTypeParam
@@ -272,7 +272,7 @@ class Derevo(val c: blackbox.Context) {
272
272
}
273
273
else Nil
274
274
275
- if (mode.keepRefinements ) {
275
+ if (mode.unqualified ) {
276
276
q """
277
277
@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.All", "scalafix:All", "all"))
278
278
implicit def $tn[.. $tparams](implicit .. $implicits) = $fixFirstTypeParam
@@ -320,12 +320,15 @@ class Derevo(val c: blackbox.Context) {
320
320
val mangledName = obj.toString.replaceAll(" [^\\ w]" , " _" )
321
321
val name = c.freshName(mangledName)
322
322
323
- val call = extractCall(tree, newType)
323
+ val call = extractCall(tree, newType)
324
324
val tcheckedObj = c.typecheck(obj, silent = true )
325
325
if (tcheckedObj.isEmpty) {
326
- c.warning(c.enclosingPosition, s " Could not typecheck ` $obj`, will try unqualified mode. If you are using local import for derivation object - replace it with package-level import " )
326
+ c.warning(
327
+ c.enclosingPosition,
328
+ s " Could not typecheck ` $obj`, will try unqualified mode. If you are using local import for derivation object - replace it with package-level import "
329
+ )
327
330
328
- return new NameAndTypes (call, name, NoType , NoType , NoType , 0 , false , true ,false )
331
+ return List ( new NameAndTypes (call, name, NoType , NoType , NoType , 0 , false , true , false ) )
329
332
}
330
333
331
334
val objTyp = tcheckedObj.tpe
@@ -351,12 +354,12 @@ class Derevo(val c: blackbox.Context) {
351
354
case _ => false
352
355
}
353
356
354
- val keepRefinements = objTyp.baseType(KeepRefinementsSymbol ) match {
357
+ val unqualified = objTyp.baseType(UnqualifiedSymbol ) match {
355
358
case TypeRef (_, _, _) => true
356
359
case _ => false
357
360
}
358
361
359
- nt.map(_.copy(passArgs = passArgs, keepRefinements = keepRefinements ))
362
+ nt.map(_.copy(passArgs = passArgs, unqualified = unqualified ))
360
363
}
361
364
362
365
trait DerivationMatcher {
@@ -410,7 +413,7 @@ object Derevo {
410
413
newtype : typ,
411
414
drop : Int ,
412
415
cascade : Boolean ,
413
- keepRefinements : Boolean = false ,
416
+ unqualified : Boolean = false ,
414
417
passArgs : Boolean = false ,
415
418
)
416
419
}
0 commit comments