From 3025d49475571ae04abcd9fd8f0aafbea14e4ae1 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sun, 16 Jul 2017 15:35:58 -0400 Subject: [PATCH] switch remaining files to `where` syntax (#11310) --- examples/lru.jl | 2 +- examples/lru_test.jl | 4 +- test/TestHelpers.jl | 22 +++++------ test/abstractarray.jl | 74 ++++++++++++++++++------------------- test/arrayops.jl | 14 +++---- test/bitarray.jl | 6 +-- test/broadcast.jl | 4 +- test/compile.jl | 10 ++--- test/dates/periods.jl | 2 +- test/dict.jl | 2 +- test/docs.jl | 4 +- test/intrinsics.jl | 2 +- test/linalg/arnoldi.jl | 2 +- test/linalg/generic.jl | 2 +- test/linalg/tridiag.jl | 2 +- test/misc.jl | 2 +- test/nullable.jl | 2 +- test/numbers.jl | 2 +- test/ranges.jl | 2 +- test/reducedim.jl | 16 ++++---- test/reflection.jl | 4 +- test/replcompletions.jl | 4 +- test/replutil.jl | 6 +-- test/serialize.jl | 2 +- test/show.jl | 2 +- test/sparse/sparse.jl | 2 +- test/sparse/sparsevector.jl | 4 +- test/specificity.jl | 18 ++++----- test/subarray.jl | 14 +++---- test/threads.jl | 14 +++---- 30 files changed, 123 insertions(+), 123 deletions(-) diff --git a/examples/lru.jl b/examples/lru.jl index 7fa54ff7eae9b..a76550deb41f2 100644 --- a/examples/lru.jl +++ b/examples/lru.jl @@ -109,7 +109,7 @@ function setindex!(lru::LRU, v, key) end # Eviction -function setindex!{V,K}(lru::BoundedLRU, v::V, key::K) +function setindex!(lru::BoundedLRU, v::V, key::K) where {V,K} invoke(setindex!, Tuple{LRU,V,K}, lru, v, key) nrm = length(lru) - lru.maxsize for i in 1:nrm diff --git a/examples/lru_test.jl b/examples/lru_test.jl index 3370220719dcd..21b4e5b668cdc 100644 --- a/examples/lru_test.jl +++ b/examples/lru_test.jl @@ -7,8 +7,8 @@ TestBLRU = LRUExample.BoundedLRU{String, String}(1000) get_str(i) = String(vcat(map(x->[x>>4; x&0x0F], reinterpret(UInt8, [Int32(i)]))...)) -isbounded{L<:LRUExample.LRU}(::Type{L}) = any(map(n->n==:maxsize, fieldnames(L))) -isbounded{L<:LRUExample.LRU}(l::L) = isbounded(L) +isbounded(::Type{L}) where {L<:LRUExample.LRU} = any(map(n->n==:maxsize, fieldnames(L))) +isbounded(l::L) where {L<:LRUExample.LRU} = isbounded(L) nmax = round.(Int, logspace(2, 5, 4)) diff --git a/test/TestHelpers.jl b/test/TestHelpers.jl index 044167ee349c3..d95bbee9da0e1 100644 --- a/test/TestHelpers.jl +++ b/test/TestHelpers.jl @@ -126,14 +126,14 @@ struct OffsetArray{T,N,AA<:AbstractArray} <: AbstractArray{T,N} end OffsetVector{T,AA<:AbstractArray} = OffsetArray{T,1,AA} -OffsetArray{T,N}(A::AbstractArray{T,N}, offsets::NTuple{N,Int}) = OffsetArray{T,N,typeof(A)}(A, offsets) -OffsetArray{T,N}(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) = OffsetArray(A, offsets) +OffsetArray(A::AbstractArray{T,N}, offsets::NTuple{N,Int}) where {T,N} = OffsetArray{T,N,typeof(A)}(A, offsets) +OffsetArray(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) where {T,N} = OffsetArray(A, offsets) -(::Type{OffsetArray{T,N}}){T,N}(inds::Indices{N}) = OffsetArray{T,N,Array{T,N}}(Array{T,N}(map(length, inds)), map(indsoffset, inds)) -(::Type{OffsetArray{T}}){T,N}(inds::Indices{N}) = OffsetArray{T,N}(inds) +(::Type{OffsetArray{T,N}})(inds::Indices{N}) where {T,N} = OffsetArray{T,N,Array{T,N}}(Array{T,N}(map(length, inds)), map(indsoffset, inds)) +(::Type{OffsetArray{T}})(inds::Indices{N}) where {T,N} = OffsetArray{T,N}(inds) -Base.IndexStyle{T<:OffsetArray}(::Type{T}) = Base.IndexStyle(parenttype(T)) -parenttype{T,N,AA}(::Type{OffsetArray{T,N,AA}}) = AA +Base.IndexStyle(::Type{T}) where {T<:OffsetArray} = Base.IndexStyle(parenttype(T)) +parenttype(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA parenttype(A::OffsetArray) = parenttype(typeof(A)) Base.parent(A::OffsetArray) = A.parent @@ -151,7 +151,7 @@ Base.eachindex(::IndexLinear, A::OffsetVector) = indices(A, 1) @inline Base.indices(A::OffsetArray) = _indices(indices(parent(A)), A.offsets) # would rather use ntuple, but see #15276 @inline _indices(inds, offsets) = (inds[1]+offsets[1], _indices(tail(inds), tail(offsets))...) _indices(::Tuple{}, ::Tuple{}) = () -Base.indices1{T}(A::OffsetArray{T,0}) = 1:1 # we only need to specialize this one +Base.indices1(A::OffsetArray{T,0}) where {T} = 1:1 # we only need to specialize this one function Base.similar(A::OffsetArray, T::Type, dims::Dims) B = similar(parent(A), T, dims) @@ -165,7 +165,7 @@ Base.similar(f::Union{Function,Type}, shape::Tuple{UnitRange,Vararg{UnitRange}}) Base.reshape(A::AbstractArray, inds::Tuple{UnitRange,Vararg{UnitRange}}) = OffsetArray(reshape(A, map(length, inds)), map(indsoffset, inds)) -@inline function Base.getindex{T,N}(A::OffsetArray{T,N}, I::Vararg{Int,N}) +@inline function Base.getindex(A::OffsetArray{T,N}, I::Vararg{Int,N}) where {T,N} checkbounds(A, I...) @inbounds ret = parent(A)[offset(A.offsets, I)...] ret @@ -182,7 +182,7 @@ end @inbounds ret = parent(A)[i] ret end -@inline function Base.setindex!{T,N}(A::OffsetArray{T,N}, val, I::Vararg{Int,N}) +@inline function Base.setindex!(A::OffsetArray{T,N}, val, I::Vararg{Int,N}) where {T,N} checkbounds(A, I...) @inbounds parent(A)[offset(A.offsets, I)...] = val val @@ -203,7 +203,7 @@ end @inbounds deleteat!(parent(A), offset(A.offsets, (i,))[1]) end -@inline function Base.deleteat!{T,N}(A::OffsetArray{T,N}, I::Vararg{Int, N}) +@inline function Base.deleteat!(A::OffsetArray{T,N}, I::Vararg{Int, N}) where {T,N} checkbounds(A, I...) @inbounds deleteat!(parent(A), offset(A.offsets, I)...) end @@ -217,7 +217,7 @@ end end # Computing a shifted index (subtracting the offset) -offset{N}(offsets::NTuple{N,Int}, inds::NTuple{N,Int}) = _offset((), offsets, inds) +offset(offsets::NTuple{N,Int}, inds::NTuple{N,Int}) where {N} = _offset((), offsets, inds) _offset(out, ::Tuple{}, ::Tuple{}) = out @inline _offset(out, offsets, inds) = _offset((out..., inds[1]-offsets[1]), Base.tail(offsets), Base.tail(inds)) diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 616528dd3bd9b..5a0fc7ff2204e 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -202,28 +202,28 @@ end T24Linear(::Type{T}, dims::Int...) where T = T24Linear(T, dims) T24Linear(::Type{T}, dims::NTuple{N,Int}) where {T,N} = T24Linear{T,N,dims}() -Base.convert{T,N }(::Type{T24Linear }, X::AbstractArray{T,N}) = convert(T24Linear{T,N}, X) -Base.convert{T,N,_}(::Type{T24Linear{T }}, X::AbstractArray{_,N}) = convert(T24Linear{T,N}, X) -Base.convert{T,N }(::Type{T24Linear{T,N}}, X::AbstractArray ) = T24Linear{T,N,size(X)}(X...) +Base.convert(::Type{T24Linear }, X::AbstractArray{T,N}) where {T,N } = convert(T24Linear{T,N}, X) +Base.convert(::Type{T24Linear{T }}, X::AbstractArray{_,N}) where {T,N,_} = convert(T24Linear{T,N}, X) +Base.convert(::Type{T24Linear{T,N}}, X::AbstractArray ) where {T,N } = T24Linear{T,N,size(X)}(X...) -Base.size{T,N,dims}(::T24Linear{T,N,dims}) = dims +Base.size(::T24Linear{T,N,dims}) where {T,N,dims} = dims import Base: IndexLinear -Base.IndexStyle{A<:T24Linear}(::Type{A}) = IndexLinear() +Base.IndexStyle(::Type{A}) where {A<:T24Linear} = IndexLinear() Base.getindex(A::T24Linear, i::Int) = getfield(A, i) -Base.setindex!{T}(A::T24Linear{T}, v, i::Int) = setfield!(A, i, convert(T, v)) +Base.setindex!(A::T24Linear{T}, v, i::Int) where {T} = setfield!(A, i, convert(T, v)) # A custom linear slow sparse-like array that relies upon Dict for its storage struct TSlow{T,N} <: AbstractArray{T,N} data::Dict{NTuple{N,Int}, T} dims::NTuple{N,Int} end -TSlow{T}(::Type{T}, dims::Int...) = TSlow(T, dims) -TSlow{T,N}(::Type{T}, dims::NTuple{N,Int}) = TSlow{T,N}(Dict{NTuple{N,Int}, T}(), dims) +TSlow(::Type{T}, dims::Int...) where {T} = TSlow(T, dims) +TSlow(::Type{T}, dims::NTuple{N,Int}) where {T,N} = TSlow{T,N}(Dict{NTuple{N,Int}, T}(), dims) -Base.convert{T,N }(::Type{TSlow{T,N}}, X::TSlow{T,N}) = X -Base.convert{T,N }(::Type{TSlow }, X::AbstractArray{T,N}) = convert(TSlow{T,N}, X) -Base.convert{T,N,_}(::Type{TSlow{T }}, X::AbstractArray{_,N}) = convert(TSlow{T,N}, X) -Base.convert{T,N }(::Type{TSlow{T,N}}, X::AbstractArray ) = begin +Base.convert(::Type{TSlow{T,N}}, X::TSlow{T,N}) where {T,N } = X +Base.convert(::Type{TSlow }, X::AbstractArray{T,N}) where {T,N } = convert(TSlow{T,N}, X) +Base.convert(::Type{TSlow{T }}, X::AbstractArray{_,N}) where {T,N,_} = convert(TSlow{T,N}, X) +Base.convert(::Type{TSlow{T,N}}, X::AbstractArray ) where {T,N } = begin A = TSlow(T, size(X)) for I in CartesianRange(size(X)) A[I.I...] = X[I.I...] @@ -232,32 +232,32 @@ Base.convert{T,N }(::Type{TSlow{T,N}}, X::AbstractArray ) = begin end Base.size(A::TSlow) = A.dims -Base.similar{T}(A::TSlow, ::Type{T}, dims::Dims) = TSlow(T, dims) +Base.similar(A::TSlow, ::Type{T}, dims::Dims) where {T} = TSlow(T, dims) import Base: IndexCartesian -Base.IndexStyle{A<:TSlow}(::Type{A}) = IndexCartesian() +Base.IndexStyle(::Type{A}) where {A<:TSlow} = IndexCartesian() # Until #11242 is merged, we need to define each dimension independently -Base.getindex{T}(A::TSlow{T,0}) = get(A.data, (), zero(T)) -Base.getindex{T}(A::TSlow{T,1}, i1::Int) = get(A.data, (i1,), zero(T)) -Base.getindex{T}(A::TSlow{T,2}, i1::Int, i2::Int) = get(A.data, (i1,i2), zero(T)) -Base.getindex{T}(A::TSlow{T,3}, i1::Int, i2::Int, i3::Int) = +Base.getindex(A::TSlow{T,0}) where {T} = get(A.data, (), zero(T)) +Base.getindex(A::TSlow{T,1}, i1::Int) where {T} = get(A.data, (i1,), zero(T)) +Base.getindex(A::TSlow{T,2}, i1::Int, i2::Int) where {T} = get(A.data, (i1,i2), zero(T)) +Base.getindex(A::TSlow{T,3}, i1::Int, i2::Int, i3::Int) where {T} = get(A.data, (i1,i2,i3), zero(T)) -Base.getindex{T}(A::TSlow{T,4}, i1::Int, i2::Int, i3::Int, i4::Int) = +Base.getindex(A::TSlow{T,4}, i1::Int, i2::Int, i3::Int, i4::Int) where {T} = get(A.data, (i1,i2,i3,i4), zero(T)) -Base.getindex{T}(A::TSlow{T,5}, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) = +Base.getindex(A::TSlow{T,5}, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) where {T} = get(A.data, (i1,i2,i3,i4,i5), zero(T)) -Base.setindex!{T}(A::TSlow{T,0}, v) = (A.data[()] = v) -Base.setindex!{T}(A::TSlow{T,1}, v, i1::Int) = (A.data[(i1,)] = v) -Base.setindex!{T}(A::TSlow{T,2}, v, i1::Int, i2::Int) = (A.data[(i1,i2)] = v) -Base.setindex!{T}(A::TSlow{T,3}, v, i1::Int, i2::Int, i3::Int) = +Base.setindex!(A::TSlow{T,0}, v) where {T} = (A.data[()] = v) +Base.setindex!(A::TSlow{T,1}, v, i1::Int) where {T} = (A.data[(i1,)] = v) +Base.setindex!(A::TSlow{T,2}, v, i1::Int, i2::Int) where {T} = (A.data[(i1,i2)] = v) +Base.setindex!(A::TSlow{T,3}, v, i1::Int, i2::Int, i3::Int) where {T} = (A.data[(i1,i2,i3)] = v) -Base.setindex!{T}(A::TSlow{T,4}, v, i1::Int, i2::Int, i3::Int, i4::Int) = +Base.setindex!(A::TSlow{T,4}, v, i1::Int, i2::Int, i3::Int, i4::Int) where {T} = (A.data[(i1,i2,i3,i4)] = v) -Base.setindex!{T}(A::TSlow{T,5}, v, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) = +Base.setindex!(A::TSlow{T,5}, v, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) where {T} = (A.data[(i1,i2,i3,i4,i5)] = v) const can_inline = Base.JLOptions().can_inline != 0 -function test_scalar_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray}) +function test_scalar_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T N = prod(shape) A = reshape(collect(1:N), shape) B = T(A) @@ -367,7 +367,7 @@ function test_scalar_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray}) @test A == B end -function test_vector_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray}) +function test_vector_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T @testset "test_vector_indexing{$(T)}" begin N = prod(shape) A = reshape(collect(1:N), shape) @@ -410,7 +410,7 @@ function test_vector_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray}) end end -function test_primitives{T}(::Type{T}, shape, ::Type{TestAbstractArray}) +function test_primitives(::Type{T}, shape, ::Type{TestAbstractArray}) where T N = prod(shape) A = reshape(collect(1:N), shape) B = T(A) @@ -481,7 +481,7 @@ Base.IndexStyle(::UnimplementedSlowArray) = Base.IndexCartesian() mutable struct UnimplementedArray{T, N} <: AbstractArray{T, N} end -function test_getindex_internals{T}(::Type{T}, shape, ::Type{TestAbstractArray}) +function test_getindex_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T N = prod(shape) A = reshape(collect(1:N), shape) B = T(A) @@ -501,7 +501,7 @@ function test_getindex_internals(::Type{TestAbstractArray}) @test_throws ErrorException Base.unsafe_getindex(V, 1, 1) end -function test_setindex!_internals{T}(::Type{T}, shape, ::Type{TestAbstractArray}) +function test_setindex!_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T N = prod(shape) A = reshape(collect(1:N), shape) B = T(A) @@ -616,17 +616,17 @@ end mutable struct TSlowNIndexes{T,N} <: AbstractArray{T,N} data::Array{T,N} end -Base.IndexStyle{A<:TSlowNIndexes}(::Type{A}) = Base.IndexCartesian() +Base.IndexStyle(::Type{A}) where {A<:TSlowNIndexes} = Base.IndexCartesian() Base.size(A::TSlowNIndexes) = size(A.data) Base.getindex(A::TSlowNIndexes, index::Int...) = error("Must use $(ndims(A)) indexes") -Base.getindex{T}(A::TSlowNIndexes{T,2}, i::Int, j::Int) = A.data[i,j] +Base.getindex(A::TSlowNIndexes{T,2}, i::Int, j::Int) where {T} = A.data[i,j] mutable struct GenericIterator{N} end -Base.start{N}(::GenericIterator{N}) = 1 -Base.next{N}(::GenericIterator{N}, i) = (i, i + 1) -Base.done{N}(::GenericIterator{N}, i) = i > N ? true : false -Base.iteratorsize{N}(::Type{GenericIterator{N}}) = Base.SizeUnknown() +Base.start(::GenericIterator{N}) where {N} = 1 +Base.next(::GenericIterator{N}, i) where {N} = (i, i + 1) +Base.done(::GenericIterator{N}, i) where {N} = i > N ? true : false +Base.iteratorsize(::Type{GenericIterator{N}}) where {N} = Base.SizeUnknown() function test_map(::Type{TestAbstractArray}) empty_pool = WorkerPool([myid()]) diff --git a/test/arrayops.jl b/test/arrayops.jl index 5dd0b5eac89f7..66715a1bd3308 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -1706,16 +1706,16 @@ module RetTypeDecl struct MeterUnits{T,P} <: Number val::T end - MeterUnits{T}(val::T, pow::Int) = MeterUnits{T,pow}(val) + MeterUnits(val::T, pow::Int) where {T} = MeterUnits{T,pow}(val) m = MeterUnits(1.0, 1) # 1.0 meter, i.e. units of length m2 = MeterUnits(1.0, 2) # 1.0 meter^2, i.e. units of area - (+){T,pow}(x::MeterUnits{T,pow}, y::MeterUnits{T,pow}) = MeterUnits{T,pow}(x.val+y.val) - (*){T,pow}(x::Int, y::MeterUnits{T,pow}) = MeterUnits{typeof(x*one(T)),pow}(x*y.val) - (*){T}(x::MeterUnits{T,1}, y::MeterUnits{T,1}) = MeterUnits{T,2}(x.val*y.val) - broadcast{T}(::typeof(*), x::MeterUnits{T,1}, y::MeterUnits{T,1}) = MeterUnits{T,2}(x.val*y.val) - convert{T,pow}(::Type{MeterUnits{T,pow}}, y::Real) = MeterUnits{T,pow}(convert(T,y)) + (+)(x::MeterUnits{T,pow}, y::MeterUnits{T,pow}) where {T,pow} = MeterUnits{T,pow}(x.val+y.val) + (*)(x::Int, y::MeterUnits{T,pow}) where {T,pow} = MeterUnits{typeof(x*one(T)),pow}(x*y.val) + (*)(x::MeterUnits{T,1}, y::MeterUnits{T,1}) where {T} = MeterUnits{T,2}(x.val*y.val) + broadcast(::typeof(*), x::MeterUnits{T,1}, y::MeterUnits{T,1}) where {T} = MeterUnits{T,2}(x.val*y.val) + convert(::Type{MeterUnits{T,pow}}, y::Real) where {T,pow} = MeterUnits{T,pow}(convert(T,y)) @test @inferred(m+[m,m]) == [m+m,m+m] @test @inferred([m,m]+m) == [m+m,m+m] @@ -1750,7 +1750,7 @@ struct LinSlowMatrix{T} <: DenseArray{T,2} end # This is the default, but just to be sure -Base.IndexStyle{A<:LinSlowMatrix}(::Type{A}) = Base.IndexCartesian() +Base.IndexStyle(::Type{A}) where {A<:LinSlowMatrix} = Base.IndexCartesian() Base.size(A::LinSlowMatrix) = size(A.data) diff --git a/test/bitarray.jl b/test/bitarray.jl index 3e6a480c5a981..b1b5655e0d459 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -2,10 +2,10 @@ using Base: findprevnot, findnextnot -tc{N}(r1::NTuple{N,Any}, r2::NTuple{N,Any}) = all(x->tc(x...), [zip(r1,r2)...]) -tc{N}(r1::BitArray{N}, r2::Union{BitArray{N},Array{Bool,N}}) = true +tc(r1::NTuple{N,Any}, r2::NTuple{N,Any}) where {N} = all(x->tc(x...), [zip(r1,r2)...]) +tc(r1::BitArray{N}, r2::Union{BitArray{N},Array{Bool,N}}) where {N} = true tc(r1::RowVector{Bool,BitVector}, r2::Union{RowVector{Bool,BitVector},RowVector{Bool,Vector{Bool}}}) = true -tc{T}(r1::T, r2::T) = true +tc(r1::T, r2::T) where {T} = true tc(r1,r2) = false bitcheck(b::BitArray) = Base._check_bitarray_consistency(b) diff --git a/test/broadcast.jl b/test/broadcast.jl index 6eafb648bf2c3..aa84edb2c700f 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -70,7 +70,7 @@ function as_sub(x::AbstractMatrix) end y end -function as_sub{T}(x::AbstractArray{T,3}) +function as_sub(x::AbstractArray{T,3}) where T y = similar(x, eltype(x), tuple(([size(x)...]*2)...)) y = view(y, 2:2:size(y,1), 2:2:size(y,2), 2:2:size(y,3)) for k=1:size(x,3) @@ -422,7 +422,7 @@ Base.getindex(A::Array19745, i::Integer...) = A.data[i...] Base.setindex!(A::Array19745, v::Any, i::Integer...) = setindex!(A.data, v, i...) Base.size(A::Array19745) = size(A.data) -Base.Broadcast._containertype{T<:Array19745}(::Type{T}) = Array19745 +Base.Broadcast._containertype(::Type{T}) where {T<:Array19745} = Array19745 Base.Broadcast.promote_containertype(::Type{Array19745}, ::Type{Array19745}) = Array19745 Base.Broadcast.promote_containertype(::Type{Array19745}, ::Type{Array}) = Array19745 diff --git a/test/compile.jl b/test/compile.jl index 8821493033395..0bdf22388eece 100644 --- a/test/compile.jl +++ b/test/compile.jl @@ -112,9 +112,9 @@ try pool::NominalPool{T, R, NominalValue{T, R}} end (::Union{Type{NominalValue}, Type{OrdinalValue}})() = 1 - (::Union{Type{NominalValue{T}}, Type{OrdinalValue{T}}}){T}() = 2 - (::Type{Vector{NominalValue{T, R}}}){T, R}() = 3 - (::Type{Vector{NominalValue{T, T}}}){T}() = 4 + (::Union{Type{NominalValue{T}}, Type{OrdinalValue{T}}})() where {T} = 2 + (::Type{Vector{NominalValue{T, R}}})() where {T, R} = 3 + (::Type{Vector{NominalValue{T, T}}})() where {T} = 4 (::Type{Vector{NominalValue{Int, Int}}})() = 5 # more tests for method signature involving a complicated type @@ -125,9 +125,9 @@ try struct Value18343{T, R} pool::Pool18343{R, Value18343{T, R}} end - Base.convert{S}(::Type{Nullable{S}}, ::Value18343{Nullable}) = 2 + Base.convert(::Type{Nullable{S}}, ::Value18343{Nullable}) where {S} = 2 Base.convert(::Type{Nullable{Value18343}}, ::Value18343{Nullable}) = 2 - Base.convert{T}(::Type{Ref}, ::Value18343{T}) = 3 + Base.convert(::Type{Ref}, ::Value18343{T}) where {T} = 3 let some_method = @which Base.include("string") diff --git a/test/dates/periods.jl b/test/dates/periods.jl index f8c068e39e032..86cf216733305 100644 --- a/test/dates/periods.jl +++ b/test/dates/periods.jl @@ -249,7 +249,7 @@ let Dates.toms(b::Beat) = Dates.value(b) * 86400 Dates._units(b::Beat) = " beat" * (abs(Dates.value(b)) == 1 ? "" : "s") Base.promote_rule(::Type{Dates.Day}, ::Type{Beat}) = Dates.Millisecond - Base.convert{T<:Dates.Millisecond}(::Type{T}, b::Beat) = T(Dates.toms(b)) + Base.convert(::Type{T}, b::Beat) where {T<:Dates.Millisecond} = T(Dates.toms(b)) @test Beat(1000) == Dates.Day(1) @test Beat(1) < Dates.Day(1) diff --git a/test/dict.jl b/test/dict.jl index c27af86751a5b..53c32705c5cde 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -161,7 +161,7 @@ end let local bar bestkey(d, key) = key - bestkey{K<:AbstractString,V}(d::Associative{K,V}, key) = string(key) + bestkey(d::Associative{K,V}, key) where {K<:AbstractString,V} = string(key) bar(x) = bestkey(x, :y) @test bar(Dict(:x => [1,2,5])) == :y @test bar(Dict("x" => [1,2,5])) == "y" diff --git a/test/docs.jl b/test/docs.jl index e91238c2781d0..ea3497e4b3f92 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -135,7 +135,7 @@ const K = :K t(x::AbstractString) = x t(x::Int, y) = y -t{S <: Integer}(x::S) = x +t(x::S) where {S <: Integer} = x "t-1" t(::AbstractString) @@ -613,7 +613,7 @@ module I12515 struct EmptyType{T} end "A new method" -Base.collect{T}(::Type{EmptyType{T}}) = "borked" +Base.collect(::Type{EmptyType{T}}) where {T} = "borked" end diff --git a/test/intrinsics.jl b/test/intrinsics.jl index 7e4dbfa46f99f..1551f09b0e807 100644 --- a/test/intrinsics.jl +++ b/test/intrinsics.jl @@ -69,7 +69,7 @@ compiled_addf(x, y) = Core.Intrinsics.add_float(x, y) @test_throws ErrorException compiled_addf(im, im) @test_throws ErrorException compiled_addf(true, true) -function compiled_conv{T}(::Type{T}, x) +function compiled_conv(::Type{T}, x) where T t = Core.Intrinsics.trunc_int(T, x) z = Core.Intrinsics.zext_int(typeof(x), t) s = Core.Intrinsics.sext_int(typeof(x), t) diff --git a/test/linalg/arnoldi.jl b/test/linalg/arnoldi.jl index d1518327592cb..dad2e420148fb 100644 --- a/test/linalg/arnoldi.jl +++ b/test/linalg/arnoldi.jl @@ -116,7 +116,7 @@ size(Phi::CPM) = (size(Phi.kraus,1)^2,size(Phi.kraus,3)^2) issymmetric(Phi::CPM) = false ishermitian(Phi::CPM) = false import Base: A_mul_B! -function A_mul_B!{T<:Base.LinAlg.BlasFloat}(rho2::StridedVector{T},Phi::CPM{T},rho::StridedVector{T}) +function A_mul_B!(rho2::StridedVector{T},Phi::CPM{T},rho::StridedVector{T}) where {T<:Base.LinAlg.BlasFloat} rho = reshape(rho,(size(Phi.kraus,3),size(Phi.kraus,3))) rho1 = zeros(T,(size(Phi.kraus,1),size(Phi.kraus,1))) for s = 1:size(Phi.kraus,2) diff --git a/test/linalg/generic.jl b/test/linalg/generic.jl index d41df65481fa7..0b3530ed210dc 100644 --- a/test/linalg/generic.jl +++ b/test/linalg/generic.jl @@ -14,7 +14,7 @@ end Quaternion(s::Real, v1::Real, v2::Real, v3::Real) = Quaternion(promote(s, v1, v2, v3)...) Base.abs2(q::Quaternion) = q.s*q.s + q.v1*q.v1 + q.v2*q.v2 + q.v3*q.v3 Base.abs(q::Quaternion) = sqrt(abs2(q)) -Base.real{T}(::Type{Quaternion{T}}) = T +Base.real(::Type{Quaternion{T}}) where {T} = T Base.conj(q::Quaternion) = Quaternion(q.s, -q.v1, -q.v2, -q.v3) Base.isfinite(q::Quaternion) = isfinite(q.s) & isfinite(q.v1) & isfinite(q.v2) & isfinite(q.v3) diff --git a/test/linalg/tridiag.jl b/test/linalg/tridiag.jl index 1fd499b675841..0130f43451d04 100644 --- a/test/linalg/tridiag.jl +++ b/test/linalg/tridiag.jl @@ -226,7 +226,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) end #Test equivalence of eigenvectors/singular vectors taking into account possible phase (sign) differences -function test_approx_eq_vecs{S<:Real,T<:Real}(a::StridedVecOrMat{S}, b::StridedVecOrMat{T}, error=nothing) +function test_approx_eq_vecs(a::StridedVecOrMat{S}, b::StridedVecOrMat{T}, error=nothing) where {S<:Real,T<:Real} n = size(a, 1) @test n==size(b,1) && size(a,2)==size(b,2) error===nothing && (error=n^3*(eps(S)+eps(T))) diff --git a/test/misc.jl b/test/misc.jl index 4b1013a478d19..6b7d3f4c966e2 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -681,7 +681,7 @@ let end abstract type DA_19281{T, N} <: AbstractArray{T, N} end -Base.convert{S,T,N}(::Type{Array{S, N}}, ::DA_19281{T, N}) = error() +Base.convert(::Type{Array{S, N}}, ::DA_19281{T, N}) where {S,T,N} = error() x_19281 = [(), (1,)] mutable struct Foo_19281 f::Vector{Tuple} diff --git a/test/nullable.jl b/test/nullable.jl index 15bcb9e1b5ecd..4148b44045033 100644 --- a/test/nullable.jl +++ b/test/nullable.jl @@ -521,7 +521,7 @@ end @test repr(Nullable()) == "Nullable{Union{}}()" # issue #19270 -let f19270{S,T}(x::S, y::T) = Base.promote_op(^, S, T) +let f19270(x::S, y::T) where {S,T} = Base.promote_op(^, S, T) @test f19270(Nullable(0.0f0), Nullable(BigInt(0))) == Nullable{Float32} end diff --git a/test/numbers.jl b/test/numbers.jl index e99aa5be4006c..6128e37b0d817 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -2916,7 +2916,7 @@ struct PR20889; x; end ^(::PR20530, p::Int) = 1 ^(t::PR20889, b) = t.x + b ^(t::PR20889, b::Integer) = t.x + b -Base.literal_pow{p}(::typeof(^), ::PR20530, ::Val{p}) = 2 +Base.literal_pow(::typeof(^), ::PR20530, ::Val{p}) where {p} = 2 @testset "literal powers" begin x = PR20530() p = 2 diff --git a/test/ranges.jl b/test/ranges.jl index 956e58317ae09..a7badb6715fd3 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -680,7 +680,7 @@ test_range_index(linspace(1.0, 1.0, 1), 1:1) test_range_index(linspace(1.0, 1.0, 1), 1:0) test_range_index(linspace(1.0, 2.0, 0), 1:0) -function test_linspace_identity{T}(r::Range{T}, mr) +function test_linspace_identity(r::Range{T}, mr) where T @test -r == mr @test -collect(r) == collect(mr) @test isa(-r, typeof(r)) diff --git a/test/reducedim.jl b/test/reducedim.jl index 4da34397991ef..e5d6fb1fcdd54 100644 --- a/test/reducedim.jl +++ b/test/reducedim.jl @@ -6,14 +6,14 @@ function safe_mapslices(op, A, region) newregion = intersect(region, 1:ndims(A)) return isempty(newregion) ? A : mapslices(op, A, newregion) end -safe_sum{T}(A::Array{T}, region) = safe_mapslices(sum, A, region) -safe_prod{T}(A::Array{T}, region) = safe_mapslices(prod, A, region) -safe_maximum{T}(A::Array{T}, region) = safe_mapslices(maximum, A, region) -safe_minimum{T}(A::Array{T}, region) = safe_mapslices(minimum, A, region) -safe_sumabs{T}(A::Array{T}, region) = safe_mapslices(sum, abs.(A), region) -safe_sumabs2{T}(A::Array{T}, region) = safe_mapslices(sum, abs2.(A), region) -safe_maxabs{T}(A::Array{T}, region) = safe_mapslices(maximum, abs.(A), region) -safe_minabs{T}(A::Array{T}, region) = safe_mapslices(minimum, abs.(A), region) +safe_sum(A::Array{T}, region) where {T} = safe_mapslices(sum, A, region) +safe_prod(A::Array{T}, region) where {T} = safe_mapslices(prod, A, region) +safe_maximum(A::Array{T}, region) where {T} = safe_mapslices(maximum, A, region) +safe_minimum(A::Array{T}, region) where {T} = safe_mapslices(minimum, A, region) +safe_sumabs(A::Array{T}, region) where {T} = safe_mapslices(sum, abs.(A), region) +safe_sumabs2(A::Array{T}, region) where {T} = safe_mapslices(sum, abs2.(A), region) +safe_maxabs(A::Array{T}, region) where {T} = safe_mapslices(maximum, abs.(A), region) +safe_minabs(A::Array{T}, region) where {T} = safe_mapslices(minimum, abs.(A), region) Areduc = rand(3, 4, 5, 6) for region in Any[ diff --git a/test/reflection.jl b/test/reflection.jl index 8b285e4958a39..8d4f0ef9f49d8 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -141,7 +141,7 @@ end # issue #10165 i10165(::Type) = 0 -i10165{T,n}(::Type{AbstractArray{T,n}}) = 1 +i10165(::Type{AbstractArray{T,n}}) where {T,n} = 1 @test i10165(AbstractArray{Int,n} where n) == 0 @test which(i10165, Tuple{Type{AbstractArray{Int,n} where n},}).sig == Tuple{typeof(i10165),Type} @@ -283,7 +283,7 @@ let ex = :(a + b) ex.typ = Integer @test string(ex) == "(a + b)::Integer" end -foo13825{T, N}(::Array{T,N}, ::Array, ::Vector) = nothing +foo13825(::Array{T, N}, ::Array, ::Vector) where {T, N} = nothing @test startswith(string(first(methods(foo13825))), "foo13825(::Array{T,N}, ::Array, ::Array{T,1} where T)") diff --git a/test/replcompletions.jl b/test/replcompletions.jl index fd53878cac705..27c2a665fadd0 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -29,9 +29,9 @@ ex = quote Base.keys(d::CustomDict) = collect(keys(d.mydict)) Base.length(d::CustomDict) = length(d.mydict) - test{T<:Real}(x::T, y::T) = pass + test(x::T, y::T) where {T<:Real} = pass test(x::Real, y::Real) = pass - test{T<:Real}(x::AbstractArray{T}, y) = pass + test(x::AbstractArray{T}, y) where {T<:Real} = pass test(args...) = pass test1(x::Type{Float64}) = pass diff --git a/test/replutil.jl b/test/replutil.jl index d0597d4d919f5..aee58020c24c4 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -52,7 +52,7 @@ method_c2(x::Int32, args...) = true method_c2(x::Int32, y::Float64, args...) = true method_c2(x::Int32, y::Float64) = true method_c2(x::Int32, y::Int32, z::Int32) = true -method_c2{T<:Real}(x::T, y::T, z::T) = true +method_c2(x::T, y::T, z::T) where {T<:Real} = true Base.show_method_candidates(buf, Base.MethodError(method_c2,(1., 1., 2))) color = "\e[0m\nClosest candidates are:\n method_c2(\e[1m\e[31m::Int32\e[0m, ::Float64, ::Any...)$cfile$(c2line+2)\n method_c2(\e[1m\e[31m::Int32\e[0m, ::Any...)$cfile$(c2line+1)\n method_c2(::T<:Real, ::T<:Real, \e[1m\e[31m::T<:Real\e[0m)$cfile$(c2line+5)\n ...\e[0m" @@ -98,7 +98,7 @@ mutable struct PR16155 b end PR16155line2 = @__LINE__() + 1 -(::Type{T}){T<:PR16155}(arg::Any) = "replace call-to-convert method from sysimg" +(::Type{T})(arg::Any) where {T<:PR16155} = "replace call-to-convert method from sysimg" Base.show_method_candidates(buf, MethodError(PR16155,(1.0, 2.0, Int64(3)))) test_have_color(buf, "\e[0m\nClosest candidates are:\n $(curmod_prefix)PR16155(::Any, ::Any)$cfile$PR16155line\n $(curmod_prefix)PR16155(\e[1m\e[31m::Int64\e[0m, ::Any)$cfile$PR16155line\n $(curmod_prefix)PR16155(::Any) where T<:$(curmod_prefix)PR16155$cfile$PR16155line2\e[0m", @@ -356,7 +356,7 @@ Base.Symbol() = throw(ErrorException("1")) EightBitType() = throw(ErrorException("3")) (::EightBitType)() = throw(ErrorException("4")) EightBitTypeT() = throw(ErrorException("5")) -(::Type{EightBitTypeT{T}}){T}() = throw(ErrorException("6")) +(::Type{EightBitTypeT{T}})() where {T} = throw(ErrorException("6")) (::EightBitTypeT)() = throw(ErrorException("7")) (::FunctionLike)() = throw(ErrorException("8")) diff --git a/test/serialize.jl b/test/serialize.jl index b136ad7b40425..ec1e302f1a72b 100644 --- a/test/serialize.jl +++ b/test/serialize.jl @@ -251,7 +251,7 @@ module ArrayWrappers struct ArrayWrapper{T,N,A<:AbstractArray} <: AbstractArray{T,N} data::A end -ArrayWrapper{T,N}(data::AbstractArray{T,N}) = ArrayWrapper{T,N,typeof(data)}(data) +ArrayWrapper(data::AbstractArray{T,N}) where {T,N} = ArrayWrapper{T,N,typeof(data)}(data) Base.size(A::ArrayWrapper) = size(A.data) Base.size(A::ArrayWrapper, d) = size(A.data, d) Base.getindex(A::ArrayWrapper, i::Real...) = getindex(A.data, i...) diff --git a/test/show.jl b/test/show.jl index e53b98ba63130..4d503946531cf 100644 --- a/test/show.jl +++ b/test/show.jl @@ -570,7 +570,7 @@ show_f1(x...) = [x...] show_f2(x::Vararg{Any}) = [x...] show_f3(x::Vararg) = [x...] show_f4(x::Vararg{Any,3}) = [x...] -show_f5{T, N}(A::AbstractArray{T,N}, indexes::Vararg{Int,N}) = [indexes...] +show_f5(A::AbstractArray{T, N}, indexes::Vararg{Int,N}) where {T, N} = [indexes...] test_mt(show_f1, "show_f1(x...)") test_mt(show_f2, "show_f2(x...)") test_mt(show_f3, "show_f3(x...)") diff --git a/test/sparse/sparse.jl b/test/sparse/sparse.jl index 27c964f6c845c..85e12fbf47e8e 100644 --- a/test/sparse/sparse.jl +++ b/test/sparse/sparse.jl @@ -1031,7 +1031,7 @@ end @test size(rotl90(a)) == (5,3) end -function test_getindex_algs{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, I::AbstractVector, J::AbstractVector, alg::Int) +function test_getindex_algs(A::SparseMatrixCSC{Tv,Ti}, I::AbstractVector, J::AbstractVector, alg::Int) where {Tv,Ti} # Sorted vectors for indexing rows. # Similar to getindex_general but without the transpose trick. (m, n) = size(A) diff --git a/test/sparse/sparsevector.jl b/test/sparse/sparsevector.jl index 4ea50dc01a367..04c4bcaf17e56 100644 --- a/test/sparse/sparsevector.jl +++ b/test/sparse/sparsevector.jl @@ -656,7 +656,7 @@ end ### Zero-preserving math functions: sparse -> sparse -function check_nz2z_z2z{T}(f::Function, x::SparseVector{T}, xf::Vector{T}) +function check_nz2z_z2z(f::Function, x::SparseVector{T}, xf::Vector{T}) where T R = typeof(f(zero(T))) r = f(x) isa(r, AbstractSparseVector) || error("$f(x) is not a sparse vector.") @@ -678,7 +678,7 @@ end ### Non-zero-preserving math functions: sparse -> dense -function check_z2nz{T}(f::Function, x::SparseVector{T}, xf::Vector{T}) +function check_z2nz(f::Function, x::SparseVector{T}, xf::Vector{T}) where T R = typeof(f(zero(T))) r = f(x) isa(r, Vector) || error("$f(x) is not a dense vector.") diff --git a/test/specificity.jl b/test/specificity.jl index 65ac3c4fbdc91..88a2d86fbf33d 100644 --- a/test/specificity.jl +++ b/test/specificity.jl @@ -69,8 +69,8 @@ let A = Tuple{Any, Tuple{Vararg{Integer,N} where N}}, end # with bound varargs -_bound_vararg_specificity_1{T,N}(::Type{Array{T,N}}, d::Vararg{Int, N}) = 0 -_bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1 +_bound_vararg_specificity_1(::Type{Array{T,N}}, d::Vararg{Int, N}) where {T,N} = 0 +_bound_vararg_specificity_1(::Type{Array{T,1}}, d::Int) where {T} = 1 @test _bound_vararg_specificity_1(Array{Int,1}, 1) == 1 @test _bound_vararg_specificity_1(Array{Int,2}, 1, 1) == 0 @@ -81,22 +81,22 @@ _bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1 # Method specificity begin local f, A - f{T}(dims::Tuple{}, A::AbstractArray{T,0}) = 1 - f{T,N}(dims::NTuple{N,Int}, A::AbstractArray{T,N}) = 2 - f{T,M,N}(dims::NTuple{M,Int}, A::AbstractArray{T,N}) = 3 + f(dims::Tuple{}, A::AbstractArray{T,0}) where {T} = 1 + f(dims::NTuple{N,Int}, A::AbstractArray{T,N}) where {T,N} = 2 + f(dims::NTuple{M,Int}, A::AbstractArray{T,N}) where {T,M,N} = 3 A = zeros(2,2) @test f((1,2,3), A) == 3 @test f((1,2), A) == 2 @test f((), reshape([1])) == 1 - f{T,N}(dims::NTuple{N,Int}, A::AbstractArray{T,N}) = 4 + f(dims::NTuple{N,Int}, A::AbstractArray{T,N}) where {T,N} = 4 @test f((1,2), A) == 4 @test f((1,2,3), A) == 3 end # a method specificity issue -c99991{T}(::Type{T},x::T) = 0 -c99991{T}(::Type{UnitRange{T}},x::StepRangeLen{T}) = 1 -c99991{T}(::Type{UnitRange{T}},x::Range{T}) = 2 +c99991(::Type{T},x::T) where {T} = 0 +c99991(::Type{UnitRange{T}},x::StepRangeLen{T}) where {T} = 1 +c99991(::Type{UnitRange{T}},x::Range{T}) where {T} = 2 @test c99991(UnitRange{Float64}, 1.0:2.0) == 1 @test c99991(UnitRange{Int}, 1:2) == 2 diff --git a/test/subarray.jl b/test/subarray.jl index 71d79d74223ee..f80ba3c200c1b 100644 --- a/test/subarray.jl +++ b/test/subarray.jl @@ -47,7 +47,7 @@ ensure_iterable(t::Tuple{Union{Number, CartesianIndex}, Vararg{Any}}) = ((t[1],) ensure_iterable(t::Tuple{Any, Vararg{Any}}) = (t[1], ensure_iterable(Base.tail(t))...) index_ndims(t::Tuple) = tup2val(Base.index_ndims(t)) -tup2val{N}(::NTuple{N}) = Val(N) +tup2val(::NTuple{N}) where {N} = Val(N) # To avoid getting confused by manipulations that are implemented for SubArrays, # it's good to copy the contents to an Array. This version protects against @@ -126,8 +126,8 @@ function test_linear(@nospecialize(A), @nospecialize(B)) end # "mixed" means 2 indexes even for N-dimensional arrays -test_mixed{T}(::AbstractArray{T,1}, ::Array) = nothing -test_mixed{T}(::AbstractArray{T,2}, ::Array) = nothing +test_mixed(::AbstractArray{T,1}, ::Array) where {T} = nothing +test_mixed(::AbstractArray{T,2}, ::Array) where {T} = nothing test_mixed(A, B::Array) = _test_mixed(A, reshape(B, size(A))) function _test_mixed(@nospecialize(A), @nospecialize(B)) m = size(A, 1) @@ -238,7 +238,7 @@ function runviews(SB::AbstractArray, indexN, indexNN, indexNNN) end end -function runviews{T}(SB::AbstractArray{T,2}, indexN, indexNN, indexNNN) +function runviews(SB::AbstractArray{T,2}, indexN, indexNN, indexNNN) where T for i2 in indexN, i1 in indexN runsubarraytests(SB, i1, i2) end @@ -247,13 +247,13 @@ function runviews{T}(SB::AbstractArray{T,2}, indexN, indexNN, indexNNN) end end -function runviews{T}(SB::AbstractArray{T,1}, indexN, indexNN, indexNNN) +function runviews(SB::AbstractArray{T,1}, indexN, indexNN, indexNNN) where T for i1 in indexN runsubarraytests(SB, i1) end end -runviews{T}(SB::AbstractArray{T,0}, indexN, indexNN, indexNNN) = nothing +runviews(SB::AbstractArray{T,0}, indexN, indexNN, indexNNN) where {T} = nothing ######### Tests ######### @@ -276,7 +276,7 @@ end # with the exception of Int-slicing oindex = (:, 6, 3:7, reshape([12]), [8,4,6,12,5,7], [3:7 1:5 2:6 4:8 5:9]) -_ndims{T,N}(::AbstractArray{T,N}) = N +_ndims(::AbstractArray{T,N}) where {T,N} = N _ndims(x) = 1 if testfull diff --git a/test/threads.jl b/test/threads.jl index a93c336795b29..fc0a1d984a84b 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -34,7 +34,7 @@ end test_threaded_loop_and_atomic_add() # Helper for test_threaded_atomic_minmax that verifies sequential consistency. -function check_minmax_consistency{T}(old::Array{T,1}, m::T, start::T, o::Base.Ordering) +function check_minmax_consistency(old::Array{T,1}, m::T, start::T, o::Base.Ordering) where T for v in old if v != start # Check that atomic op that installed v reported consistent old value. @@ -43,7 +43,7 @@ function check_minmax_consistency{T}(old::Array{T,1}, m::T, start::T, o::Base.Or end end -function test_threaded_atomic_minmax{T}(m::T,n::T) +function test_threaded_atomic_minmax(m::T,n::T) where T mid = m + (n-m)>>1 x = Atomic{T}(mid) y = Atomic{T}(mid) @@ -63,7 +63,7 @@ end test_threaded_atomic_minmax(Int16(-5000),Int16(5000)) test_threaded_atomic_minmax(UInt16(27000),UInt16(37000)) -function threaded_add_locked{LockT}(::Type{LockT}, x, n) +function threaded_add_locked(::Type{LockT}, x, n) where LockT critical = LockT() @threads for i = 1:n @test lock(critical) === nothing @@ -119,7 +119,7 @@ end # Make sure doing a GC while holding a lock doesn't cause dead lock # PR 14190. (This is only meaningful for threading) -function threaded_gc_locked{LockT}(::Type{LockT}) +function threaded_gc_locked(::Type{LockT}) where LockT critical = LockT() @threads for i = 1:20 @test lock(critical) === nothing @@ -296,7 +296,7 @@ let atomic_types = [Int8, Int16, Int32, Int64, Int128, end # Test atomic_cas! and atomic_xchg! -function test_atomic_cas!{T}(var::Atomic{T}, range::StepRange{Int,Int}) +function test_atomic_cas!(var::Atomic{T}, range::StepRange{Int,Int}) where T for i in range while true old = atomic_cas!(var, T(i-1), T(i)) @@ -316,7 +316,7 @@ for T in (Int32, Int64, Float32, Float64) @test var[] === T(nloops) end -function test_atomic_xchg!{T}(var::Atomic{T}, i::Int, accum::Atomic{Int}) +function test_atomic_xchg!(var::Atomic{T}, i::Int, accum::Atomic{Int}) where T old = atomic_xchg!(var, T(i)) atomic_add!(accum, Int(old)) end @@ -330,7 +330,7 @@ for T in (Int32, Int64, Float32, Float64) @test accum[] + Int(var[]) === sum(0:nloops) end -function test_atomic_float{T}(varadd::Atomic{T}, varmax::Atomic{T}, varmin::Atomic{T}, i::Int) +function test_atomic_float(varadd::Atomic{T}, varmax::Atomic{T}, varmin::Atomic{T}, i::Int) where T atomic_add!(varadd, T(i)) atomic_max!(varmax, T(i)) atomic_min!(varmin, T(i))