Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the new signature of invoke #10939

Merged
merged 2 commits into from
May 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function writepos{T}(t::TextTerminal, x, y, b::Array{T})
writepos(t, x, y, reinterpret(UInt8, b))
else
cmove(t, x, y)
invoke(write, (IO, Array), s, a)
invoke(write, Tuple{IO, Array}, s, a)
end
end
function writepos(t::TextTerminal, x, y, args...)
Expand Down
2 changes: 1 addition & 1 deletion base/deepcopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function deepcopy_internal(x::Function, stackdict::ObjectIdDict)
if isa(x.env, Union(MethodTable, Symbol)) || x.env === ()
return x
end
invoke(deepcopy_internal, (Any, ObjectIdDict), x, stackdict)
invoke(deepcopy_internal, Tuple{Any, ObjectIdDict}, x, stackdict)
end

function deepcopy_internal(x, stackdict::ObjectIdDict)
Expand Down
2 changes: 1 addition & 1 deletion base/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ catdoc(xs...) = vcat(xs...)
# Modules

function doc(m::Module)
md = invoke(doc, (Any,), m)
md = invoke(doc, Tuple{Any}, m)
md == nothing || return md
readme = Pkg.dir(string(m), "README.md")
if isfile(readme)
Expand Down
4 changes: 2 additions & 2 deletions base/fs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function write{T}(f::File, a::Array{T})
if isbits(T)
write(f,pointer(a),length(a)*sizeof(eltype(a)))
else
invoke(write, (IO, Array), f, a)
invoke(write, Tuple{IO, Array}, f, a)
end
end

Expand Down Expand Up @@ -238,7 +238,7 @@ function read!{T}(f::File, a::Array{T}, nel=length(a))
f.handle, a, nb)
uv_error("read",ret)
else
invoke(read, (IO, Array), s, a)
invoke(read, Tuple{IO, Array}, s, a)
end
a
end
Expand Down
6 changes: 3 additions & 3 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function write{T}(s::IOStream, a::Array{T})
Int(ccall(:ios_write, UInt, (Ptr{Void}, Ptr{Void}, UInt),
s.ios, a, length(a)*sizeof(T)))
else
invoke(write, (IO, Array), s, a)
invoke(write, Tuple{IO, Array}, s, a)
end
end

Expand All @@ -139,7 +139,7 @@ end

function write{T,N,A<:Array}(s::IOStream, a::SubArray{T,N,A})
if !isbits(T) || stride(a,1)!=1
return invoke(write, (Any, AbstractArray), s, a)
return invoke(write, Tuple{Any, AbstractArray}, s, a)
end
colsz = size(a,1)*sizeof(T)
if N<=1
Expand Down Expand Up @@ -170,7 +170,7 @@ function read!{T}(s::IOStream, a::Array{T})
throw(EOFError())
end
else
invoke(read!, (IO, Array), s, a)
invoke(read!, Tuple{IO, Array}, s, a)
end
a
end
Expand Down
4 changes: 2 additions & 2 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,11 @@ function serialize(s, rr::RemoteRef)
#println("send add $rr to $i")
send_add_client(rr, i)
end
invoke(serialize, (Any, Any), s, rr)
invoke(serialize, Tuple{Any, Any}, s, rr)
end

function deserialize(s, t::Type{RemoteRef})
rr = invoke(deserialize, (Any, DataType), s, t)
rr = invoke(deserialize, Tuple{Any, DataType}, s, t)
where = rr.where
if where == myid()
add_client(rr2id(rr), myid())
Expand Down
2 changes: 1 addition & 1 deletion base/serialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end

function serialize{T<:AbstractString}(s, ss::SubString{T})
# avoid saving a copy of the parent string, keeping the type of ss
invoke(serialize, (Any,Any), s, convert(SubString{T}, convert(T,ss)))
invoke(serialize, Tuple{Any, Any}, s, convert(SubString{T}, convert(T,ss)))
end

# Don't serialize the pointers
Expand Down
2 changes: 1 addition & 1 deletion base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function serialize(s, S::SharedArray)
end

function deserialize{T,N}(s, t::Type{SharedArray{T,N}})
S = invoke(deserialize, (Any, DataType), s, t)
S = invoke(deserialize, Tuple{Any, DataType}, s, t)
init_loc_flds(S)
S
end
Expand Down
10 changes: 5 additions & 5 deletions base/sparse/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function (*){TvA,TiA,TvB,TiB}(A::SparseMatrixCSC{TvA,TiA}, B::SparseMatrixCSC{Tv
A * B
end

(*){TvA,TiA}(A::SparseMatrixCSC{TvA,TiA}, X::BitArray{1}) = invoke(*, (SparseMatrixCSC, AbstractVector), A, X)
(*){TvA,TiA}(A::SparseMatrixCSC{TvA,TiA}, X::BitArray{1}) = invoke(*, Tuple{SparseMatrixCSC, AbstractVector}, A, X)
# In matrix-vector multiplication, the correct orientation of the vector is assumed.
function A_mul_B!(α::Number, A::SparseMatrixCSC, x::AbstractVector, β::Number, y::AbstractVector)
A.n == length(x) || throw(DimensionMismatch())
Expand Down Expand Up @@ -113,7 +113,7 @@ function At_mul_B{TA,S,Tx}(A::SparseMatrixCSC{TA,S}, x::AbstractVector{Tx})
At_mul_B!(one(T), A, x, zero(T), Array(T, A.n))
end

*(X::BitArray{1}, A::SparseMatrixCSC) = invoke(*, (AbstractVector, SparseMatrixCSC), X, A)
*(X::BitArray{1}, A::SparseMatrixCSC) = invoke(*, Tuple{AbstractVector, SparseMatrixCSC}, X, A)
# In vector-matrix multiplication, the correct orientation of the vector is assumed.
# XXX: this is wrong (i.e. not what Arrays would do)!!
function *{T1,T2}(X::AbstractVector{T1}, A::SparseMatrixCSC{T2})
Expand All @@ -127,7 +127,7 @@ function *{T1,T2}(X::AbstractVector{T1}, A::SparseMatrixCSC{T2})
Y
end

*{TvA,TiA}(A::SparseMatrixCSC{TvA,TiA}, X::BitArray{2}) = invoke(*, (SparseMatrixCSC, AbstractMatrix), A, X)
*{TvA,TiA}(A::SparseMatrixCSC{TvA,TiA}, X::BitArray{2}) = invoke(*, Tuple{SparseMatrixCSC, AbstractMatrix}, A, X)
function (*){TvA,TiA,TX}(A::SparseMatrixCSC{TvA,TiA}, X::AbstractMatrix{TX})
mX, nX = size(X)
A.n==mX || throw(DimensionMismatch())
Expand All @@ -144,9 +144,9 @@ function (*){TvA,TiA,TX}(A::SparseMatrixCSC{TvA,TiA}, X::AbstractMatrix{TX})
Y
end

*{TvA,TiA}(X::BitArray{2}, A::SparseMatrixCSC{TvA,TiA}) = invoke(*, (AbstractMatrix, SparseMatrixCSC), X, A)
*{TvA,TiA}(X::BitArray{2}, A::SparseMatrixCSC{TvA,TiA}) = invoke(*, Tuple{AbstractMatrix, SparseMatrixCSC}, X, A)
# TODO: Tridiagonal * Sparse should be implemented more efficiently
*{TX,TvA,TiA}(X::Tridiagonal{TX}, A::SparseMatrixCSC{TvA,TiA}) = invoke(*, (Tridiagonal, AbstractMatrix), X, A)
*{TX,TvA,TiA}(X::Tridiagonal{TX}, A::SparseMatrixCSC{TvA,TiA}) = invoke(*, Tuple{Tridiagonal, AbstractMatrix}, X, A)
*{TvA,TiA}(X::AbstractTriangular, A::SparseMatrixCSC{TvA,TiA}) = full(X)*A
function *{TX,TvA,TiA}(X::AbstractMatrix{TX}, A::SparseMatrixCSC{TvA,TiA})
mX, nX = size(X)
Expand Down
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ function write{T}(s::AsyncStream, a::Array{T})
return buffer_or_write(s, pointer(a), n);
else
check_open(s)
invoke(write,(IO,Array),s,a)
invoke(write, Tuple{IO, Array},s,a)
end
end

Expand Down
9 changes: 8 additions & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ end
# issue #2169
let
i2169{T}(a::Array{T}) = typemin(T)
@test invoke(i2169,(Array,),Int8[1]) === Int8(-128)
@test invoke(i2169, Tuple{Array} ,Int8[1]) === Int8(-128)
end

# issue #2365
Expand Down Expand Up @@ -2046,6 +2046,13 @@ end
f9520a(::Any, ::Any, args...) = 15
f9520b(::Any, ::Any, ::Any, args...) = 23
f9520c(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, args...) = 46
@test invoke(f9520a, Tuple{Any, Any}, 1, 2) == 15
@test invoke(f9520a, Tuple{Any, Any, Any}, 1, 2, 3) == 15
@test invoke(f9520b, Tuple{Any, Any, Any}, 1, 2, 3) == 23
@test invoke(f9520b, Tuple{Any, Any, Any, Any, Any, Any}, 1, 2, 3, 4, 5, 6) == 23
@test invoke(f9520c, Tuple{Any, Any, Any, Any, Any, Any}, 1, 2, 3, 4, 5, 6) == 46
@test invoke(f9520c, Tuple{Any, Any, Any, Any, Any, Any, Any}, 1, 2, 3, 4, 5, 6, 7) == 46
# Keep until the old signature of invoke is dropped.
@test invoke(f9520a, (Any, Any), 1, 2) == 15
@test invoke(f9520a, (Any, Any, Any), 1, 2, 3) == 15
@test invoke(f9520b, (Any, Any, Any), 1, 2, 3) == 23
Expand Down
4 changes: 2 additions & 2 deletions test/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end

for T=types[2:end], x=vals
a = coerce(T,x)
@test hash(a,zero(UInt)) == invoke(hash,(Real,UInt),a,zero(UInt))
@test hash(a,zero(UInt)) == invoke(hash, Tuple{Real, UInt}, a, zero(UInt))
end

for T=types, S=types, x=vals
Expand All @@ -50,7 +50,7 @@ end
@test hash(prevfloat(2.0^64)) == hash(UInt64(prevfloat(2.0^64)))

# issue #9264
@test hash(1//6,zero(UInt)) == invoke(hash,(Real,UInt),1//6,zero(UInt))
@test hash(1//6,zero(UInt)) == invoke(hash, Tuple{Real, UInt}, 1//6, zero(UInt))
@test hash(1//6) == hash(big(1)//big(6))
@test hash(1//6) == hash(0x01//0x06)

Expand Down
3 changes: 2 additions & 1 deletion test/linalg2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ for elty in (Float32, Float64, Complex{Float32}, Complex{Float64})
end

## QR
FJulia = invoke(qrfact!, (AbstractMatrix,Type{Val{false}}), copy(A), Val{false})
FJulia = invoke(qrfact!, Tuple{AbstractMatrix, Type{Val{false}}},
copy(A), Val{false})
FLAPACK = Base.LinAlg.LAPACK.geqrf!(copy(A))
@test_approx_eq FJulia.factors FLAPACK[1]
@test_approx_eq FJulia.τ FLAPACK[2]
Expand Down
2 changes: 1 addition & 1 deletion test/linalg4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ for elty in (Float32, Float64, Complex{Float32}, Complex{Float64})
end
A = convert(Matrix{elty}, A'A)
for ul in (:U, :L)
@test_approx_eq full(cholfact(A, ul)[ul]) full(invoke(Base.LinAlg.chol!, (AbstractMatrix, Type{Val{ul}}),copy(A), Val{ul}))
@test_approx_eq full(cholfact(A, ul)[ul]) full(invoke(Base.LinAlg.chol!, Tuple{AbstractMatrix, Type{Val{ul}}},copy(A), Val{ul}))
end
end

Expand Down
12 changes: 6 additions & 6 deletions test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ b = complex(randn(32), randn(32))
@test_approx_eq sumabs2(b) sum(abs2(b))

# check variants of summation for type-stability and other issues (#6069)
sum2(itr) = invoke(sum, (Any,), itr)
sum2(itr) = invoke(sum, Tuple{Any}, itr)
plus(x,y) = x + y
sum3(A) = reduce(plus, A)
sum4(itr) = invoke(reduce, (Function, Any), plus, itr)
sum4(itr) = invoke(reduce, Tuple{Function, Any}, plus, itr)
sum5(A) = reduce(plus, 0, A)
sum6(itr) = invoke(reduce, (Function, Int, Any), plus, 0, itr)
sum6(itr) = invoke(reduce, Tuple{Function, Int, Any}, plus, 0, itr)
sum7(A) = mapreduce(x->x, plus, A)
sum8(itr) = invoke(mapreduce, (Function, Function, Any), x->x, plus, itr)
sum8(itr) = invoke(mapreduce, Tuple{Function, Function, Any}, x->x, plus, itr)
sum9(A) = mapreduce(x->x, plus, 0, A)
sum10(itr) = invoke(mapreduce, (Function, Function, Int, Any), x->x,plus,0,itr)
sum10(itr) = invoke(mapreduce, Tuple{Function, Function, Int, Any}, x->x,plus,0,itr)
for f in (sum2, sum5, sum6, sum9, sum10)
@test sum(z) == f(z)
@test sum(Int[]) == f(Int[]) == 0
Expand Down Expand Up @@ -117,7 +117,7 @@ end
@test prod(big(typemax(Int64)):big(typemax(Int64))+16) == parse(BigInt,"25300281663413827620486300433089141956148633919452440329174083959168114253708467653081909888307573358090001734956158476311046124934597861626299416732205795533726326734482449215730132757595422510465791525610410023802664753402501982524443370512346073948799084936298007821432734720004795146875180123558814648586972474376192000")

# check type-stability
prod2(itr) = invoke(prod, (Any,), itr)
prod2(itr) = invoke(prod, Tuple{Any}, itr)
@test prod(Int[]) === prod2(Int[]) === 1
@test prod(Int[7]) === prod2(Int[7]) === 7
@test typeof(prod(Int8[])) == typeof(prod(Int8[1])) == typeof(prod(Int8[1, 7])) == Int
Expand Down
2 changes: 1 addition & 1 deletion test/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ let f =IOBuffer(),
x = split("1 2 3")
@test write(f, x) == 3
@test takebuf_string(f) == "123"
@test invoke(write, (IO, AbstractArray), f, x) == 3
@test invoke(write, Tuple{IO, AbstractArray}, f, x) == 3
@test takebuf_string(f) == "123"
end

Expand Down