From aaa528e9d922362039859f00384920b24ab7cf11 Mon Sep 17 00:00:00 2001 From: Mus M Date: Wed, 19 Apr 2017 08:58:15 -0400 Subject: [PATCH] Misc files to where syntax --- base/base.jl | 2 +- base/dft.jl | 16 ++++++++-------- base/dict.jl | 10 +++++----- base/generator.jl | 2 +- base/int.jl | 28 ++++++++++++++-------------- base/iterators.jl | 30 +++++++++++++++--------------- base/linalg/factorization.jl | 2 +- base/multidimensional.jl | 30 +++++++++++++++--------------- base/pair.jl | 2 +- base/refpointer.jl | 18 +++++++++--------- base/sparse/cholmod.jl | 6 +++--- base/strings/utf8proc.jl | 2 +- 12 files changed, 74 insertions(+), 74 deletions(-) diff --git a/base/base.jl b/base/base.jl index 652b9106a18c16..fd04ea496b6ad4 100644 --- a/base/base.jl +++ b/base/base.jl @@ -129,7 +129,7 @@ function finalizer(o::ANY, f::ANY) ccall(:jl_gc_add_finalizer_th, Void, (Ptr{Void}, Any, Any), Core.getptls(), o, f) end -function finalizer{T}(o::T, f::Ptr{Void}) +function finalizer(o::T, f::Ptr{Void}) where T @_inline_meta if isimmutable(T) error("objects of type ", T, " cannot be finalized") diff --git a/base/dft.jl b/base/dft.jl index ec0b69d5a7158c..fd0c4dd57ccbde 100644 --- a/base/dft.jl +++ b/base/dft.jl @@ -22,24 +22,24 @@ export fft, ifft, bfft, fft!, ifft!, bfft!, const FFTWFloat = Union{Float32,Float64} fftwfloat(x) = _fftwfloat(float(x)) -_fftwfloat{T<:FFTWFloat}(::Type{T}) = T +_fftwfloat(::Type{T}) where {T<:FFTWFloat} = T _fftwfloat(::Type{Float16}) = Float32 -_fftwfloat{T}(::Type{Complex{T}}) = Complex{_fftwfloat(T)} -_fftwfloat{T}(::Type{T}) = error("type $T not supported") -_fftwfloat{T}(x::T) = _fftwfloat(T)(x) +_fftwfloat(::Type{Complex{T}}) where {T} = Complex{_fftwfloat(T)} +_fftwfloat(::Type{T}) where {T} = error("type $T not supported") +_fftwfloat(x::T) where {T} = _fftwfloat(T)(x) complexfloat(x::StridedArray{Complex{<:FFTWFloat}}) = x realfloat(x::StridedArray{<:FFTWFloat}) = x # return an Array, rather than similar(x), to avoid an extra copy for FFTW # (which only works on StridedArray types). -complexfloat{T<:Complex}(x::AbstractArray{T}) = copy1(typeof(fftwfloat(zero(T))), x) -complexfloat{T<:Real}(x::AbstractArray{T}) = copy1(typeof(complex(fftwfloat(zero(T)))), x) +complexfloat(x::AbstractArray{T}) where {T<:Complex} = copy1(typeof(fftwfloat(zero(T))), x) +complexfloat(x::AbstractArray{T}) where {T<:Real} = copy1(typeof(complex(fftwfloat(zero(T)))), x) -realfloat{T<:Real}(x::AbstractArray{T}) = copy1(typeof(fftwfloat(zero(T))), x) +realfloat(x::AbstractArray{T}) where {T<:Real} = copy1(typeof(fftwfloat(zero(T))), x) # copy to a 1-based array, using circular permutation -function copy1{T}(::Type{T}, x) +function copy1(::Type{T}, x) where T y = Array{T}(map(length, indices(x))) Base.circcopy!(y, x) end diff --git a/base/dict.jl b/base/dict.jl index 6a52d682f46168..bfe6ca4322a73e 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -154,12 +154,12 @@ end TP{K,V} = Union{Type{Tuple{K,V}},Type{Pair{K,V}}} -associative_with_eltype{K,V}(DT_apply, kv, ::TP{K,V}) = DT_apply(K, V)(kv) -associative_with_eltype{K,V}(DT_apply, kv::Generator, ::TP{K,V}) = DT_apply(K, V)(kv) -associative_with_eltype{K,V}(DT_apply, ::Type{Pair{K,V}}) = DT_apply(K, V)() +associative_with_eltype(DT_apply, kv, ::TP{K,V}) where {K,V} = DT_apply(K, V)(kv) +associative_with_eltype(DT_apply, kv::Generator, ::TP{K,V}) where {K,V} = DT_apply(K, V)(kv) +associative_with_eltype(DT_apply, ::Type{Pair{K,V}}) where {K,V} = DT_apply(K, V)() associative_with_eltype(DT_apply, ::Type) = DT_apply(Any, Any)() -associative_with_eltype{F}(DT_apply::F, kv, t) = grow_to!(associative_with_eltype(DT_apply, _default_eltype(typeof(kv))), kv) -function associative_with_eltype{F}(DT_apply::F, kv::Generator, t) +associative_with_eltype(DT_apply::F, kv, t) where {F} = grow_to!(associative_with_eltype(DT_apply, _default_eltype(typeof(kv))), kv) +function associative_with_eltype(DT_apply::F, kv::Generator, t) where F T = _default_eltype(typeof(kv)) if T <: Union{Pair, Tuple{Any, Any}} && isleaftype(T) return associative_with_eltype(DT_apply, kv, T) diff --git a/base/generator.jl b/base/generator.jl index 53d69e9adde54e..e4f7398ad2728c 100644 --- a/base/generator.jl +++ b/base/generator.jl @@ -115,4 +115,4 @@ size(g::Generator) = size(g.iter) indices(g::Generator) = indices(g.iter) ndims(g::Generator) = ndims(g.iter) -iteratoreltype{I,T}(::Type{Generator{I,T}}) = EltypeUnknown() +iteratoreltype(::Type{Generator{I,T}}) where {I,T} = EltypeUnknown() diff --git a/base/int.jl b/base/int.jl index fa1846b2c12aec..81fe224a3617be 100644 --- a/base/int.jl +++ b/base/int.jl @@ -70,7 +70,7 @@ iseven(n::Integer) = !isodd(n) signbit(x::Integer) = x < 0 signbit(x::Unsigned) = false -flipsign{T<:BitSigned}(x::T, y::T) = flipsign_int(x, y) +flipsign(x::T, y::T) where {T<:BitSigned} = flipsign_int(x, y) flipsign(x::Signed, y::Signed) = convert(typeof(x), flipsign(promote_noncircular(x, y)...)) flipsign(x::Signed, y::Float16) = flipsign(x, bitcast(Int16, y)) @@ -166,38 +166,38 @@ julia> mod(-eps(), 3) 3.0 ``` """ -function mod{T<:Integer}(x::T, y::T) +function mod(x::T, y::T) where T<:Integer y == -1 && return T(0) # avoid potential overflow in fld return x - fld(x, y) * y end mod(x::Signed, y::Unsigned) = rem(y + unsigned(rem(x, y)), y) mod(x::Unsigned, y::Signed) = rem(y + signed(rem(x, y)), y) -mod{T<:Unsigned}(x::T, y::T) = rem(x, y) +mod(x::T, y::T) where {T<:Unsigned} = rem(x, y) cld(x::Signed, y::Unsigned) = div(x, y) + (!signbit(x) & (rem(x, y) != 0)) cld(x::Unsigned, y::Signed) = div(x, y) + (!signbit(y) & (rem(x, y) != 0)) # Don't promote integers for div/rem/mod since there is no danger of overflow, # while there is a substantial performance penalty to 64-bit promotion. -div{T<:BitSigned64}(x::T, y::T) = checked_sdiv_int(x, y) -rem{T<:BitSigned64}(x::T, y::T) = checked_srem_int(x, y) -div{T<:BitUnsigned64}(x::T, y::T) = checked_udiv_int(x, y) -rem{T<:BitUnsigned64}(x::T, y::T) = checked_urem_int(x, y) +div(x::T, y::T) where {T<:BitSigned64} = checked_sdiv_int(x, y) +rem(x::T, y::T) where {T<:BitSigned64} = checked_srem_int(x, y) +div(x::T, y::T) where {T<:BitUnsigned64} = checked_udiv_int(x, y) +rem(x::T, y::T) where {T<:BitUnsigned64} = checked_urem_int(x, y) # fld(x,y) == div(x,y) - ((x>=0) != (y>=0) && rem(x,y) != 0 ? 1 : 0) -fld{T<:Unsigned}(x::T, y::T) = div(x,y) -function fld{T<:Integer}(x::T, y::T) +fld(x::T, y::T) where {T<:Unsigned} = div(x,y) +function fld(x::T, y::T) where T<:Integer d = div(x, y) return d - (signbit(x ⊻ y) & (d * y != x)) end # cld(x,y) = div(x,y) + ((x>0) == (y>0) && rem(x,y) != 0 ? 1 : 0) -function cld{T<:Unsigned}(x::T, y::T) +function cld(x::T, y::T) where T<:Unsigned d = div(x, y) return d + (d * y != x) end -function cld{T<:Integer}(x::T, y::T) +function cld(x::T, y::T) where T<:Integer d = div(x, y) return d + (((x > 0) == (y > 0)) & (d * y != x)) end @@ -205,9 +205,9 @@ end ## integer bitwise operations ## (~)(x::BitInteger) = not_int(x) -(&){T<:BitInteger}(x::T, y::T) = and_int(x, y) -(|){T<:BitInteger}(x::T, y::T) = or_int(x, y) -xor{T<:BitInteger}(x::T, y::T) = xor_int(x, y) +(&)(x::T, y::T) where {T<:BitInteger} = and_int(x, y) +(|)(x::T, y::T) where {T<:BitInteger} = or_int(x, y) +xor(x::T, y::T) where {T<:BitInteger} = xor_int(x, y) bswap(x::Union{Int8, UInt8}) = x bswap(x::Union{Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128}) = diff --git a/base/iterators.jl b/base/iterators.jl index e9c2426079ff84..70db41e4a232c8 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -23,7 +23,7 @@ and_iteratorsize(::HasLength, ::HasShape) = HasLength() and_iteratorsize(::HasShape, ::HasLength) = HasLength() and_iteratorsize(a, b) = SizeUnknown() -and_iteratoreltype{T}(iel::T, ::T) = iel +and_iteratoreltype(iel::T, ::T) where {T} = iel and_iteratoreltype(a, b) = EltypeUnknown() # enumerate @@ -68,7 +68,7 @@ end eltype(::Type{Enumerate{I}}) where {I} = Tuple{Int, eltype(I)} iteratorsize{I}(::Type{Enumerate{I}}) = iteratorsize(I) -iteratoreltype{I}(::Type{Enumerate{I}}) = iteratoreltype(I) +iteratoreltype(::Type{Enumerate{I}}) where {I} = iteratoreltype(I) struct IndexValue{I,A<:AbstractArray} data::A @@ -138,7 +138,7 @@ end eltype(::Type{IndexValue{I,A}}) where {I,A} = Tuple{eltype(I), eltype(A)} iteratorsize{I}(::Type{IndexValue{I}}) = iteratorsize(I) -iteratoreltype{I}(::Type{IndexValue{I}}) = iteratoreltype(I) +iteratoreltype(::Type{IndexValue{I}}) where {I} = iteratoreltype(I) # zip @@ -167,7 +167,7 @@ end @inline done(z::Zip1, st) = done(z.a,st) iteratorsize{I}(::Type{Zip1{I}}) = iteratorsize(I) -iteratoreltype{I}(::Type{Zip1{I}}) = iteratoreltype(I) +iteratoreltype(::Type{Zip1{I}}) where {I} = iteratoreltype(I) struct Zip2{I1, I2} <: AbstractZipIterator a::I1 @@ -187,7 +187,7 @@ end @inline done(z::Zip2, st) = done(z.a,st[1]) | done(z.b,st[2]) iteratorsize{I1,I2}(::Type{Zip2{I1,I2}}) = zip_iteratorsize(iteratorsize(I1),iteratorsize(I2)) -iteratoreltype{I1,I2}(::Type{Zip2{I1,I2}}) = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) +iteratoreltype(::Type{Zip2{I1,I2}}) where {I1,I2} = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) struct Zip{I, Z<:AbstractZipIterator} <: AbstractZipIterator a::I @@ -238,7 +238,7 @@ end @inline done(z::Zip, st) = done(z.a,st[1]) | done(z.z,st[2]) iteratorsize{I1,I2}(::Type{Zip{I1,I2}}) = zip_iteratorsize(iteratorsize(I1),iteratorsize(I2)) -iteratoreltype{I1,I2}(::Type{Zip{I1,I2}}) = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) +iteratoreltype(::Type{Zip{I1,I2}}) where {I1,I2} = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) # filter @@ -278,7 +278,7 @@ end done(f::Filter, s) = s[1] eltype(::Type{Filter{F,I}}) where {F,I} = eltype(I) -iteratoreltype{F,I}(::Type{Filter{F,I}}) = iteratoreltype(I) +iteratoreltype(::Type{Filter{F,I}}) where {F,I} = iteratoreltype(I) iteratorsize(::Type{<:Filter}) = SizeUnknown() # Rest -- iterate starting at the given state @@ -300,7 +300,7 @@ next(i::Rest, st) = next(i.itr, st) done(i::Rest, st) = done(i.itr, st) eltype(::Type{Rest{I}}) where {I} = eltype(I) -iteratoreltype{I,S}(::Type{Rest{I,S}}) = iteratoreltype(I) +iteratoreltype(::Type{Rest{I,S}}) where {I,S} = iteratoreltype(I) rest_iteratorsize(a) = SizeUnknown() rest_iteratorsize(::IsInfinite) = IsInfinite() iteratorsize{I,S}(::Type{Rest{I,S}}) = rest_iteratorsize(iteratorsize(I)) @@ -366,7 +366,7 @@ take(xs, n::Integer) = Take(xs, Int(n)) take(xs::Take, n::Integer) = Take(xs.xs, min(Int(n), xs.n)) eltype(::Type{Take{I}}) where {I} = eltype(I) -iteratoreltype{I}(::Type{Take{I}}) = iteratoreltype(I) +iteratoreltype(::Type{Take{I}}) where {I} = iteratoreltype(I) take_iteratorsize(a) = HasLength() take_iteratorsize(::SizeUnknown) = SizeUnknown() iteratorsize{I}(::Type{Take{I}}) = take_iteratorsize(iteratorsize(I)) @@ -421,7 +421,7 @@ drop(xs::Take, n::Integer) = Take(drop(xs.xs, Int(n)), max(0, xs.n - Int(n))) drop(xs::Drop, n::Integer) = Drop(xs.xs, Int(n) + xs.n) eltype(::Type{Drop{I}}) where {I} = eltype(I) -iteratoreltype{I}(::Type{Drop{I}}) = iteratoreltype(I) +iteratoreltype(::Type{Drop{I}}) where {I} = iteratoreltype(I) drop_iteratorsize(::SizeUnknown) = SizeUnknown() drop_iteratorsize(::Union{HasShape, HasLength}) = HasLength() drop_iteratorsize(::IsInfinite) = IsInfinite() @@ -457,7 +457,7 @@ An iterator that cycles through `iter` forever. cycle(xs) = Cycle(xs) eltype(::Type{Cycle{I}}) where {I} = eltype(I) -iteratoreltype{I}(::Type{Cycle{I}}) = iteratoreltype(I) +iteratoreltype(::Type{Cycle{I}}) where {I} = iteratoreltype(I) iteratorsize{I}(::Type{Cycle{I}}) = IsInfinite() function start(it::Cycle) @@ -563,7 +563,7 @@ indices(p::Prod1) = _prod_indices(p.a, iteratorsize(p.a)) end @inline done(p::Prod1, st) = done(p.a, st) -iteratoreltype{I}(::Type{Prod1{I}}) = iteratoreltype(I) +iteratoreltype(::Type{Prod1{I}}) where {I} = iteratoreltype(I) iteratorsize{I}(::Type{Prod1{I}}) = iteratorsize(I) # two iterators @@ -590,7 +590,7 @@ product(a, b) = Prod2(a, b) eltype(::Type{Prod2{I1,I2}}) where {I1,I2} = Tuple{eltype(I1), eltype(I2)} -iteratoreltype{I1,I2}(::Type{Prod2{I1,I2}}) = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) +iteratoreltype(::Type{Prod2{I1,I2}}) where {I1,I2} = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) iteratorsize{I1,I2}(::Type{Prod2{I1,I2}}) = prod_iteratorsize(iteratorsize(I1),iteratorsize(I2)) function start(p::AbstractProdIterator) @@ -627,7 +627,7 @@ product(a, b, c...) = Prod(a, product(b, c...)) eltype(::Type{Prod{I1,I2}}) where {I1,I2} = tuple_type_cons(eltype(I1), eltype(I2)) -iteratoreltype{I1,I2}(::Type{Prod{I1,I2}}) = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) +iteratoreltype(::Type{Prod{I1,I2}}) where {I1,I2} = and_iteratoreltype(iteratoreltype(I1),iteratoreltype(I2)) iteratorsize{I1,I2}(::Type{Prod{I1,I2}}) = prod_iteratorsize(iteratorsize(I1),iteratorsize(I2)) @inline function next{I1,I2}(p::Prod{I1,I2}, st) @@ -669,7 +669,7 @@ flatten(itr) = Flatten(itr) eltype(::Type{Flatten{I}}) where {I} = eltype(eltype(I)) iteratorsize{I}(::Type{Flatten{I}}) = SizeUnknown() -iteratoreltype{I}(::Type{Flatten{I}}) = _flatteneltype(I, iteratoreltype(I)) +iteratoreltype(::Type{Flatten{I}}) where {I} = _flatteneltype(I, iteratoreltype(I)) _flatteneltype(I, ::HasEltype) = iteratoreltype(eltype(I)) _flatteneltype(I, et) = EltypeUnknown() diff --git a/base/linalg/factorization.jl b/base/linalg/factorization.jl index 7a3a2d881fc613..e2cfd6e578fc5c 100644 --- a/base/linalg/factorization.jl +++ b/base/linalg/factorization.jl @@ -4,7 +4,7 @@ abstract type Factorization{T} end -eltype{T}(::Type{Factorization{T}}) = T +eltype(::Type{Factorization{T}}) where {T} = T transpose(F::Factorization) = error("transpose not implemented for $(typeof(F))") ctranspose(F::Factorization) = error("ctranspose not implemented for $(typeof(F))") diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 5fae18d4a33d32..bf275c92701b05 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -65,27 +65,27 @@ module IteratorsMD one(::Type{CartesianIndex{N}}) where {N} = CartesianIndex(ntuple(x -> 1, Val{N})) # arithmetic, min/max - @inline (-){N}(index::CartesianIndex{N}) = + @inline (-)(index::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(-, index.I)) - @inline (+){N}(index1::CartesianIndex{N}, index2::CartesianIndex{N}) = + @inline (+)(index1::CartesianIndex{N}, index2::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(+, index1.I, index2.I)) - @inline (-){N}(index1::CartesianIndex{N}, index2::CartesianIndex{N}) = + @inline (-)(index1::CartesianIndex{N}, index2::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(-, index1.I, index2.I)) - @inline min{N}(index1::CartesianIndex{N}, index2::CartesianIndex{N}) = + @inline min(index1::CartesianIndex{N}, index2::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(min, index1.I, index2.I)) - @inline max{N}(index1::CartesianIndex{N}, index2::CartesianIndex{N}) = + @inline max(index1::CartesianIndex{N}, index2::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(max, index1.I, index2.I)) @inline (+)(i::Integer, index::CartesianIndex) = index+i - @inline (+){N}(index::CartesianIndex{N}, i::Integer) = CartesianIndex{N}(map(x->x+i, index.I)) - @inline (-){N}(index::CartesianIndex{N}, i::Integer) = CartesianIndex{N}(map(x->x-i, index.I)) - @inline (-){N}(i::Integer, index::CartesianIndex{N}) = CartesianIndex{N}(map(x->i-x, index.I)) - @inline (*){N}(a::Integer, index::CartesianIndex{N}) = CartesianIndex{N}(map(x->a*x, index.I)) - @inline (*)(index::CartesianIndex,a::Integer)=*(a,index) + @inline (+)(index::CartesianIndex{N}, i::Integer) where {N} = CartesianIndex{N}(map(x->x+i, index.I)) + @inline (-)(index::CartesianIndex{N}, i::Integer) where {N} = CartesianIndex{N}(map(x->x-i, index.I)) + @inline (-)(i::Integer, index::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(x->i-x, index.I)) + @inline (*)(a::Integer, index::CartesianIndex{N}) where {N} = CartesianIndex{N}(map(x->a*x, index.I)) + @inline (*)(index::CartesianIndex, a::Integer) = *(a,index) # comparison - @inline isless{N}(I1::CartesianIndex{N}, I2::CartesianIndex{N}) = _isless(0, I1.I, I2.I) - @inline function _isless{N}(ret, I1::NTuple{N,Int}, I2::NTuple{N,Int}) + @inline isless(I1::CartesianIndex{N}, I2::CartesianIndex{N}) where {N} = _isless(0, I1.I, I2.I) + @inline function _isless(ret, I1::NTuple{N,Int}, I2::NTuple{N,Int}) where N newret = ifelse(ret==0, icmp(I1[N], I2[N]), ret) _isless(newret, Base.front(I1), Base.front(I2)) end @@ -155,7 +155,7 @@ module IteratorsMD end iter.start end - @inline function next{I<:CartesianIndex}(iter::CartesianRange{I}, state) + @inline function next(iter::CartesianRange{I}, state) where I<:CartesianIndex state, I(inc(state.I, iter.start.I, iter.stop.I)) end # increment & carry @@ -1195,7 +1195,7 @@ end ## findn -@generated function findn{N}(B::BitArray{N}) +@generated function findn(B::BitArray{N}) where N quote nnzB = countnz(B) I = ntuple(x->Vector{Int}(nnzB), Val{$N}) @@ -1255,7 +1255,7 @@ function checkdims_perm{TP,TB,N}(P::AbstractArray{TP,N}, B::AbstractArray{TB,N}, end for (V, PT, BT) in [((:N,), BitArray, BitArray), ((:T,:N), Array, StridedArray)] - @eval @generated function permutedims!{$(V...)}(P::$PT{$(V...)}, B::$BT{$(V...)}, perm) + @eval @generated function permutedims!(P::$PT{$(V...)}, B::$BT{$(V...)}, perm) where $(V...) quote checkdims_perm(P, B, perm) diff --git a/base/pair.jl b/base/pair.jl index 483179157e22f4..77ebbb70fab45f 100644 --- a/base/pair.jl +++ b/base/pair.jl @@ -10,7 +10,7 @@ const => = Pair start(p::Pair) = 1 done(p::Pair, i) = i>2 next(p::Pair, i) = (getfield(p,i), i+1) -eltype{A,B}(p::Pair{A,B}) = Union{A,B} +eltype(p::Pair{A,B}) where {A,B} = Union{A,B} indexed_next(p::Pair, i::Int, state) = (getfield(p,i), i+1) diff --git a/base/refpointer.jl b/base/refpointer.jl index 8671f215c595ef..11ef66c0d31489 100644 --- a/base/refpointer.jl +++ b/base/refpointer.jl @@ -27,7 +27,7 @@ end ### General Methods for Ref{T} type -eltype{T}(x::Type{Ref{T}}) = T +eltype(x::Type{Ref{T}}) where {T} = T convert(::Type{Ref{T}}, x::Ref{T}) where {T} = x # create Ref objects for general object conversion @@ -48,11 +48,11 @@ Ref(x::Ref) = x Ref(x::Any) = RefValue(x) Ref{T}(x::Ptr{T}, i::Integer=1) = x + (i-1)*Core.sizeof(T) Ref(x, i::Integer) = (i != 1 && error("Object only has one element"); Ref(x)) -(::Type{Ref{T}}){T}() = RefValue{T}() # Ref{T}() -(::Type{Ref{T}}){T}(x) = RefValue{T}(x) # Ref{T}(x) +(::Type{Ref{T}})() where {T} = RefValue{T}() # Ref{T}() +(::Type{Ref{T}})(x) where {T} = RefValue{T}(x) # Ref{T}(x) convert(::Type{Ref{T}}, x) where {T} = RefValue{T}(x) -function unsafe_convert{T}(P::Type{Ptr{T}}, b::RefValue{T}) +function unsafe_convert(P::Type{Ptr{T}}, b::RefValue{T}) where T if isbits(T) return convert(P, data_pointer_from_objref(b)) else @@ -76,7 +76,7 @@ RefArray{T}(x::AbstractArray{T},i::Int=1,roots::Void=nothing) = RefArray{T,typeo convert(::Type{Ref{T}}, x::AbstractArray{T}) where {T} = RefArray(x, 1) Ref(x::AbstractArray, i::Integer=1) = RefArray(x, i) -function unsafe_convert{T}(P::Type{Ptr{T}}, b::RefArray{T}) +function unsafe_convert(P::Type{Ptr{T}}, b::RefArray{T}) where T if isbits(T) convert(P, pointer(b.x, b.i)) else @@ -108,10 +108,10 @@ function (::Type{Ref{P}}){P<:Union{Ptr,Cwstring,Cstring},T}(a::Array{T}) # Ref{P return RefArray(ptrs,1,roots) end end -cconvert{P<:Ptr}(::Type{Ptr{P}}, a::Array{<:Ptr}) = a -cconvert{P<:Ptr}(::Type{Ref{P}}, a::Array{<:Ptr}) = a -cconvert{P<:Union{Ptr,Cwstring,Cstring}}(::Type{Ptr{P}}, a::Array) = Ref{P}(a) -cconvert{P<:Union{Ptr,Cwstring,Cstring}}(::Type{Ref{P}}, a::Array) = Ref{P}(a) +cconvert(::Type{Ptr{P}}, a::Array{<:Ptr}) where {P<:Ptr} = a +cconvert(::Type{Ref{P}}, a::Array{<:Ptr}) where {P<:Ptr} = a +cconvert(::Type{Ptr{P}}, a::Array) where {P<:Union{Ptr,Cwstring,Cstring}} = Ref{P}(a) +cconvert(::Type{Ref{P}}, a::Array) where {P<:Union{Ptr,Cwstring,Cstring}} = Ref{P}(a) ### diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index b3a0cac192b57a..89b47734cc4089 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -1173,9 +1173,9 @@ free!(A::Dense) = free_dense!(A.p) free!(A::Sparse) = free_sparse!(A.p) free!(F::Factor) = free_factor!(F.p) -eltype{T<:VTypes}(::Type{Dense{T}}) = T -eltype{T<:VTypes}(::Type{Factor{T}}) = T -eltype{T<:VTypes}(::Type{Sparse{T}}) = T +eltype(::Type{Dense{T}}) where {T<:VTypes} = T +eltype(::Type{Factor{T}}) where {T<:VTypes} = T +eltype(::Type{Sparse{T}}) where {T<:VTypes} = T nnz(F::Factor) = nnz(Sparse(F)) diff --git a/base/strings/utf8proc.jl b/base/strings/utf8proc.jl index 6fb8dbce5b0094..acadd79f750d18 100644 --- a/base/strings/utf8proc.jl +++ b/base/strings/utf8proc.jl @@ -352,7 +352,7 @@ letter combined with an accent mark is a single grapheme.) """ graphemes(s::AbstractString) = GraphemeIterator{typeof(s)}(s) -eltype{S}(::Type{GraphemeIterator{S}}) = SubString{S} +eltype(::Type{GraphemeIterator{S}}) where {S} = SubString{S} function length(g::GraphemeIterator) c0 = Char(0x00ad) # soft hyphen (grapheme break always allowed after this)