Skip to content

Commit b40b844

Browse files
committed
Rework return type annotations
1 parent 3edd2f7 commit b40b844

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/FixedPointDecimals.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ end
230230
_apply_exact_float{T}(f, ::Type{T}, x::Real, i::Integer) = f(T, x, i)
231231

232232
for fn in [:trunc, :floor, :ceil]
233-
@eval $fn{TI <: Integer}(::Type{TI}, x::FD)::TI = $fn(x)
233+
@eval ($fn{TI <: Integer}(::Type{TI}, x::FD)::TI) = $fn(x)
234234

235235
# round/trunc/ceil/flooring to FD; generic
236236
@eval function $fn{T, f}(::Type{FD{T, f}}, x::Real)
@@ -241,8 +241,8 @@ for fn in [:trunc, :floor, :ceil]
241241
reinterpret(FD{T, f}, val)
242242
end
243243
end
244-
function round{TI <: Integer}(::Type{TI}, x::FD, ::RoundingMode{:Nearest}=RoundNearest)::TI
245-
round(x)
244+
function round{TI <: Integer}(::Type{TI}, x::FD, ::RoundingMode{:Nearest}=RoundNearest)
245+
convert(TI, round(x))::TI
246246
end
247247
function round{T, f}(::Type{FD{T, f}}, x::Real, ::RoundingMode{:Nearest}=RoundNearest)
248248
reinterpret(FD{T, f}, round(T, x * coefficient(FD{T, f})))
@@ -260,9 +260,9 @@ end
260260

261261
convert{T <: FD}(::Type{T}, x::AbstractFloat) = round(T, x)
262262

263-
function convert{T, f}(::Type{FD{T, f}}, x::Rational)::FD{T, f}
263+
function convert{T, f}(::Type{FD{T, f}}, x::Rational)
264264
powt = coefficient(FD{T, f})
265-
reinterpret(FD{T, f}, T(x * powt))
265+
reinterpret(FD{T, f}, T(x * powt))::FD{T, f}
266266
end
267267

268268
function convert{T, f, U, g}(::Type{FD{T, f}}, x::FD{U, g})
@@ -290,20 +290,22 @@ for divfn in [:div, :fld, :fld1]
290290
end
291291

292292
convert(::Type{AbstractFloat}, x::FD) = convert(floattype(typeof(x)), x)
293-
function convert{TF <: AbstractFloat, T, f}(::Type{TF}, x::FD{T, f})::TF
294-
x.i / coefficient(FD{T, f})
293+
function convert{TF <: AbstractFloat, T, f}(::Type{TF}, x::FD{T, f})
294+
convert(TF, x.i / coefficient(FD{T, f}))::TF
295295
end
296296

297-
function convert{TF <: BigFloat, T, f}(::Type{TF}, x::FD{T, f})::TF
298-
BigInt(x.i) / BigInt(coefficient(FD{T, f}))
297+
function convert{TF <: BigFloat, T, f}(::Type{TF}, x::FD{T, f})
298+
convert(TF, BigInt(x.i) / BigInt(coefficient(FD{T, f})))::TF
299299
end
300300

301-
function convert{TI <: Integer, T, f}(::Type{TI}, x::FD{T, f})::TI
301+
function convert{TI <: Integer, T, f}(::Type{TI}, x::FD{T, f})
302302
isinteger(x) || throw(InexactError(:convert, TI, x))
303-
div(x.i, coefficient(FD{T, f}))
303+
convert(TI, div(x.i, coefficient(FD{T, f})))::TI
304304
end
305305

306-
convert{TR <: Rational, T, f}(::Type{TR}, x::FD{T, f})::TR = x.i // coefficient(FD{T, f})
306+
function convert{TR <: Rational, T, f}(::Type{TR}, x::FD{T, f})
307+
convert(TR, x.i // coefficient(FD{T, f}))::TR
308+
end
307309

308310
promote_rule{T, f, TI <: Integer}(::Type{FD{T, f}}, ::Type{TI}) = FD{T, f}
309311
promote_rule{T, f, TF <: AbstractFloat}(::Type{FD{T, f}}, ::Type{TF}) = TF

0 commit comments

Comments
 (0)