@@ -5,6 +5,9 @@ import scala.annotation.nowarn
5
5
import scala .reflect .ClassTag
6
6
import com .eed3si9n .ifdef .ifdef
7
7
8
+ @ nowarn(" msg=make nowarn used" )
9
+ private [typeclass] final class Optionally_MakeNowarnUsed
10
+
8
11
/**
9
12
* Describes how to represent an optional value
10
13
*
@@ -244,33 +247,42 @@ private[typeclass] trait LowPrioBiOptionally {
244
247
@ ifdef(" scalaEpochVersion:2" )
245
248
def contextToExprOption [Ctx <: scala.reflect.macros.blackbox.Context with Singleton , A ](implicit typA: Ctx # TypeTag [A ]): BiOptionally [Ctx , Ctx # Expr , Ctx # Expr [A ], Ctx # Expr [Option [A ]]] = BiOptionally .apply(
246
249
(ctx: Ctx ) => {
247
- @ nowarn(" msg=never used" ) implicit val typA2 : ctx.TypeTag [A ] = typA.asInstanceOf [ctx.TypeTag [A ]]
248
- selectTermNames[Option [A ]](ctx)(" _root_" , " scala" , " None" ).asInstanceOf [Ctx # Expr [Option [A ]]]
250
+ val myBindSingletonContexts = new BindSingletonContexts [Ctx , ctx.type ]
251
+ import myBindSingletonContexts ._
252
+ @ nowarn(" msg=never used" ) implicit val typA2 : ctx.TypeTag [A ] = typA
253
+ selectTermNames[Option [A ]](ctx)(" _root_" , " scala" , " None" ): Ctx # Expr [Option [A ]]
249
254
},
250
255
(value, ctx) => {
251
- @ nowarn(" msg=never used" ) implicit val typA2 : ctx.TypeTag [A ] = typA.asInstanceOf [ctx.TypeTag [A ]]
252
- val value2 = value.asInstanceOf [ctx.Expr [A ]]
256
+ val myBindSingletonContexts = new BindSingletonContexts [Ctx , ctx.type ]
257
+ import myBindSingletonContexts ._
258
+ @ nowarn(" msg=never used" ) implicit val typA2 : ctx.TypeTag [A ] = typA
259
+ val value2 : ctx.Expr [A ] = value
253
260
val rootTree = ctx.universe.Ident (ctx.universe.TermName (" _root_" ))
254
261
val namesTree = List (" scala" , " Some" , " apply" ).foldLeft[ctx.universe.Tree ](rootTree)({(folding, name) => ctx.universe.Select (folding, ctx.universe.TermName (name))})
255
- ctx.Expr [Option [A ]](ctx.universe.Apply (namesTree, List (value2.tree))). asInstanceOf [ Ctx # Expr [Option [A ] ]]
262
+ ctx.Expr [Option [A ]](ctx.universe.Apply (namesTree, List (value2.tree))): Ctx # Expr [Option [A ]]
256
263
},
257
264
(value, ctx) => {
258
- val value2 = value.asInstanceOf [ctx.Expr [Option [A ]]]
259
- select[Option [A ], Boolean ](ctx)(value2, " isEmpty" ).asInstanceOf [Ctx # Expr [Boolean ]]
265
+ val myBindSingletonContexts = new BindSingletonContexts [Ctx , ctx.type ]
266
+ import myBindSingletonContexts ._
267
+ val value2 = value : ctx.Expr [Option [A ]]
268
+ select[Option [A ], Boolean ](ctx)(value2, " isEmpty" ): Ctx # Expr [Boolean ]
260
269
},
261
270
PartialExprFunction (
262
271
(value, ctx) => {
263
- val value2 = value.asInstanceOf [ctx.Expr [Option [A ]]]
264
- select[Option [A ], Boolean ](ctx)(value2, " nonEmpty" ).asInstanceOf [Ctx # Expr [Boolean ]]
272
+ val myBindSingletonContexts = new BindSingletonContexts [Ctx , ctx.type ]
273
+ import myBindSingletonContexts ._
274
+ val value2 = value : ctx.Expr [Option [A ]]
275
+ select[Option [A ], Boolean ](ctx)(value2, " nonEmpty" ): Ctx # Expr [Boolean ]
265
276
},
266
277
(value, ctx) => {
267
- val value2 = value.asInstanceOf [ctx.Expr [Option [A ]]]
268
- select[Option [A ], A ](ctx)(value2, " get" ).asInstanceOf [Ctx # Expr [A ]]
278
+ val myBindSingletonContexts = new BindSingletonContexts [Ctx , ctx.type ]
279
+ import myBindSingletonContexts ._
280
+ val value2 = value : ctx.Expr [Option [A ]]
281
+ select[Option [A ], A ](ctx)(value2, " get" ): Ctx # Expr [A ]
269
282
},
270
283
)
271
284
)
272
285
273
- @ nowarn(" msg=make nowarn used" )
274
286
@ ifdef(" scalaBinaryVersion:3" )
275
287
implicit def quotedToExprOption [A ](implicit typ : TypeCreator [A ]): BiOptionally [scala.quoted.Quotes , scala.quoted.Expr , scala.quoted.Expr [A ], scala.quoted.Expr [Option [A ]]] =
276
288
OptionallyImpl .quotedToExprOption[A ]
0 commit comments