@@ -16,9 +16,9 @@ object MacroImpl {
16
16
import c .universe .Quasiquote
17
17
18
18
implicit val thisCToExpr = typeclass.ToExprMapping .forContext(c)
19
- val constExpr : Function1 [String , c.Expr [String ]] = {x => c.Expr (c.universe.Literal (c.universe.Constant (x)))}
20
- val constNullExpr : c.Expr [Null ] = c.Expr (c.universe.Literal (c.universe.Constant (null )))
21
- val constNegOneExpr : c.Expr [Int ] = c.Expr (c.universe.Literal (c.universe.Constant (- 1 )))
19
+ val constExpr : Function1 [String , c.Expr [String ]] = {x => c.Expr [ String ] (c.universe.Literal (c.universe.Constant (x)))}
20
+ val constNullExpr : c.Expr [Null ] = c.Expr [ Null ] (c.universe.Literal (c.universe.Constant (null )))
21
+ val constNegOneExpr : c.Expr [Int ] = c.Expr [ Int ] (c.universe.Literal (c.universe.Constant (- 1 )))
22
22
def parseByteHex (x: (Char , Char )): Int = java.lang.Integer .parseInt(s " ${x._1}${x._2}" , 16 )
23
23
24
24
val hexChar : Interpolator [Char ] = charWhere(c => '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' ).opaque(" hexChar" )
@@ -101,14 +101,14 @@ object MacroImpl {
101
101
}
102
102
/* Luckily, the URI constructor seems to be able to surround v6 addresses in brackets automatically, so that we don't have to */
103
103
val variableInetAddress : Interpolator [c.Expr [String ]] = ofType(c.typeTag[java.net.InetAddress ])
104
- .map((x, _:c.type ) => c.Expr (q " $x.getHostName() " ))
104
+ .map((x, _:c.type ) => c.Expr [ String ] (q " $x.getHostName() " ))
105
105
variableInetAddress <|> literalIpv4 <|> literalIpv6 <|> literalName
106
106
}
107
107
108
108
val port : Interpolator [c.Expr [Int ]] = {
109
109
val literal : Interpolator [c.Expr [Int ]] = digitChar.repeat(1 )
110
110
.map({(x, _:c.type ) => java.lang.Integer .parseInt(x)})
111
- .map({(x, _:c.type ) => c.Expr (c.universe.Literal (c.universe.Constant (x)))})
111
+ .map({(x, _:c.type ) => c.Expr [ Int ] (c.universe.Literal (c.universe.Constant (x)))})
112
112
.opaque(" Port" )
113
113
val literalEmpty : Interpolator [c.Expr [Int ]] = isString(" " ).map({(_:Unit , _:c.type ) => constNegOneExpr})
114
114
val variable : Interpolator [c.Expr [Int ]] = ofType[Int ]
@@ -117,11 +117,11 @@ object MacroImpl {
117
117
118
118
val hostPort : Interpolator [(c.Expr [String ], c.Expr [Int ])] = {
119
119
val literal = host <~> (isString(" :" ) <~> port)
120
- .optionally().map((x, _:c.type ) => x.getOrElse(c. Expr ( q " -1 " ) ))
120
+ .optionally().map((x, _:c.type ) => x.getOrElse(constNegOneExpr ))
121
121
val SockAddr = ofType(c.typeTag[java.net.InetSocketAddress ])
122
122
.map((x, _:c.type ) => (
123
- c.Expr (q " $x.getHostString() " ),
124
- c.Expr (q " $x.getPort() " )
123
+ c.Expr [ String ] (q " $x.getHostString() " ),
124
+ c.Expr [ Int ] (q " $x.getPort() " )
125
125
))
126
126
SockAddr <|> literal
127
127
}
@@ -271,7 +271,7 @@ object MacroImpl {
271
271
}) <|>
272
272
(opaquePart <~> fragment).map({(x, _:c.type ) =>
273
273
x match {case (ssp, frag) =>
274
- c.Expr (q """
274
+ c.Expr [ URI ] (q """
275
275
new java.net.URI(
276
276
$scheme,
277
277
$ssp,
@@ -310,7 +310,7 @@ object MacroImpl {
310
310
val resolvedUri : Interpolator [c.Expr [URI ]] = {
311
311
(ofType[URI ] <~> relativeUri).map({(params, _:c.type ) =>
312
312
val (base, resolvant) = params
313
- c.Expr (q " $base.resolve( $resolvant) " )
313
+ c.Expr [ URI ] (q " $base.resolve( $resolvant) " )
314
314
})
315
315
}
316
316
0 commit comments