Skip to content

Commit

Permalink
Merge branch 'master' into jb/innerctors
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters authored Feb 3, 2017
2 parents 0190b3a + 3db0193 commit e5242bd
Show file tree
Hide file tree
Showing 38 changed files with 252 additions and 162 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Language changes
the `broadcast` call `(⨳).(a, b)`. Hence, one no longer defines methods
for `.*` etcetera. This also means that "dot operations" automatically
fuse into a single loop, along with other dot calls `f.(x)`. ([#17623])
Similarly for unary operators ([#20249]).
* Newly defined methods are no longer callable from the same dynamic runtime
scope they were defined in ([#17057]).
Expand All @@ -62,8 +63,8 @@ Breaking changes
This section lists changes that do not have deprecation warnings.
* `readline`, `readlines` and `eachline` return lines without line endings by default.
You *must* use `readline(s, chomp=false)`, etc. to get the old behavior where lines
returned include trailing end-of-line character(s). ([#19944])
You *must* use `readline(s, chomp=false)`, etc. to get the old behavior where
returned lines include trailing end-of-line character(s). ([#19944])
* `String`s no longer have a `.data` field (as part of a significant performance
improvement). Use `Vector{UInt8}(str)` to access a string as a byte array.
Expand Down
1 change: 0 additions & 1 deletion base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ typealias NTuple{N,T} Tuple{Vararg{T,N}}
(::Type{Array{T}}){T}(m::Int, n::Int, o::Int) = Array{T,3}(m, n, o)

(::Type{Array{T,1}}){T}() = Array{T,1}(0)
(::Type{Array{T,2}}){T}() = Array{T,2}(0, 0)

# primitive Symbol constructors
function Symbol(s::String)
Expand Down
4 changes: 0 additions & 4 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ function process_options(opts::JLOptions)
println()
break
end
# eval expression but don't disable interactive mode
if opts.postboot != C_NULL
eval(Main, parse_input_line(unsafe_string(opts.postboot)))
end
# load file
if !isempty(ARGS) && !isempty(ARGS[1])
# program
Expand Down
7 changes: 0 additions & 7 deletions base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,23 +363,16 @@ end

const valid_opts = [:header, :has_header, :use_mmap, :quotes, :comments, :dims, :comment_char, :skipstart, :skipblanks]
const valid_opt_types = [Bool, Bool, Bool, Bool, Bool, NTuple{2,Integer}, Char, Integer, Bool]
const deprecated_opts = Dict(:has_header => :header)

function val_opts(opts)
d = Dict{Symbol,Union{Bool,NTuple{2,Integer},Char,Integer}}()
for (opt_name, opt_val) in opts
if opt_name == :ignore_invalid_chars
Base.depwarn("the ignore_invalid_chars option is no longer supported and will be ignored", :val_opts)
continue
end
in(opt_name, valid_opts) ||
throw(ArgumentError("unknown option $opt_name"))
opt_typ = valid_opt_types[findfirst(valid_opts, opt_name)]
isa(opt_val, opt_typ) ||
throw(ArgumentError("$opt_name should be of type $opt_typ, got $(typeof(opt_val))"))
d[opt_name] = opt_val
haskey(deprecated_opts, opt_name) &&
Base.depwarn("$opt_name is deprecated, use $(deprecated_opts[opt_name]) instead", :val_opts)
end
return d
end
Expand Down
4 changes: 2 additions & 2 deletions base/dates/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function tryparsenext end
"""
format(io::IO, tok::AbstractDateToken, dt::TimeType, locale)
format the `tok` token from `dt` and write it to `io`. The formatting can
Format the `tok` token from `dt` and write it to `io`. The formatting can
be based on `locale`.
all subtypes of `AbstractDateToken` must define this method in order
All subtypes of `AbstractDateToken` must define this method in order
to be able to print a Date / DateTime object according to a `DateFormat`
containing that token.
"""
Expand Down
27 changes: 17 additions & 10 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ function promote_op(op::Type, Ts::Type...)
return op
end

# NOTE: Deprecation of `isdefined(a::Array, i::Int)` is implemented in src/array.c
# and deprecation of `invoke(f, (types...), ...)` is implemented in src/builtins.c
# To be removed when 0.6 deprecations are removed

# NOTE: Deprecation of Channel{T}() is implemented in channels.jl.
# To be removed from there when 0.6 deprecations are removed.

Expand Down Expand Up @@ -926,8 +930,8 @@ unsafe_wrap(::Type{String}, p::Cstring, len::Integer, own::Bool=false) =
unsafe_wrap(String, convert(Ptr{UInt8}, p), len, own)

# #19660
@deprecate finalize(sa::LibGit2.StrArrayStruct) close(sa)
@deprecate finalize(sa::LibGit2.Buffer) close(sa)
@deprecate finalize(sa::LibGit2.StrArrayStruct) LibGit2.free(sa)
@deprecate finalize(sa::LibGit2.Buffer) LibGit2.free(sa)

## produce, consume, and task iteration
# NOTE: When removing produce/consume, also remove field Task.consumers and related code in
Expand Down Expand Up @@ -1157,14 +1161,6 @@ end
return false
end

# Not exported
eval(LibGit2, quote
function owner(x)
Base.depwarn("owner(x) is deprecated, use repository(x) instead.", :owner)
repository(x)
end
end)

@deprecate EachLine(stream, ondone) EachLine(stream, ondone=ondone)

# These conversions should not be defined, see #19896
Expand Down Expand Up @@ -1213,6 +1209,17 @@ end)

@deprecate FloatRange{T}(start::T, step, len, den) Base.floatrange(T, start, step, len, den)

@noinline zero_arg_matrix_constructor(prefix::String) =
depwarn("$prefix() is deprecated, use $prefix(0, 0) instead.", :zero_arg_matrix_constructor)
function (::Type{Matrix{T}}){T}()
zero_arg_matrix_constructor("Matrix{T}")
return Matrix{T}(0, 0)
end
function (::Type{Matrix})()
zero_arg_matrix_constructor("Matrix")
return Matrix(0, 0)
end

for name in ("alnum", "alpha", "cntrl", "digit", "number", "graph",
"lower", "print", "punct", "space", "upper", "xdigit")
f = Symbol("is",name)
Expand Down
2 changes: 1 addition & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export
OrdinalRange,
Pair,
PartialQuickSort,
PermutedDimsArray,
PollingFileWatcher,
QuickSort,
Range,
Expand Down Expand Up @@ -653,7 +654,6 @@ export
lqfact,
rank,
scale!,
scale,
schur,
schurfact!,
schurfact,
Expand Down
14 changes: 7 additions & 7 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,13 @@ const TypeName_module_fieldindex = fieldindex(TypeName, :module)
const TypeName_wrapper_fieldindex = fieldindex(TypeName, :wrapper)

function const_datatype_getfield_tfunc(sv, fld)
if (fld == DataType_name_fieldindex ||
fld == DataType_parameters_fieldindex ||
fld == DataType_types_fieldindex ||
fld == DataType_super_fieldindex)
return abstract_eval_constant(getfield(sv, fld))
end
return nothing
if (fld == DataType_name_fieldindex ||
fld == DataType_parameters_fieldindex ||
fld == DataType_types_fieldindex ||
fld == DataType_super_fieldindex)
return abstract_eval_constant(getfield(sv, fld))
end
return nothing
end

# returns (type, isexact)
Expand Down
4 changes: 2 additions & 2 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,11 @@ removed. When called with a file name, the file is opened once at the beginning
iteration and closed at the end. If iteration is interrupted, the file will be
closed when the `EachLine` object is garbage collected.
"""
eachline(stream::IO=STDIN; chomp::Bool=true) = EachLine(stream, chomp=chomp)
eachline(stream::IO=STDIN; chomp::Bool=true) = EachLine(stream, chomp=chomp)::EachLine

function eachline(filename::AbstractString; chomp::Bool=true)
s = open(filename)
EachLine(s, ondone=()->close(s), chomp=chomp)
EachLine(s, ondone=()->close(s), chomp=chomp)::EachLine
end

start(itr::EachLine) = nothing
Expand Down
6 changes: 3 additions & 3 deletions base/libgit2/blob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ function Base.show(io::IO, blob::GitBlob)
if !isbinary(blob)
conts = split(content(blob), "\n")
showlen = max(length(conts), 3)
print(io, "GitBlob:\nBlob id: ", GitHash(blob), "\nContents:\n")
println(io, "GitBlob:\nBlob id: ", GitHash(blob), "\nContents:")
for i in 1:showlen
print(io, conts[i],"\n")
println(io, conts[i])
end
else
print(io, "GitBlob:\nBlob id: ", GitHash(blob), "\nContents are binary.\n")
println(io, "GitBlob:\nBlob id: ", GitHash(blob), "\nContents are binary.")
end
end
2 changes: 1 addition & 1 deletion base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ end
"""
upstream(ref::GitReference) -> Nullable{GitReference}
Determine if the branch specified by `ref` has a specified upstream branch.
Determine if the branch containing `ref` has a specified upstream branch.
`upstream` returns a `Nullable`, which will be null if the requested branch does
not have an upstream counterpart. If the upstream branch does exist, the `Nullable`
Expand Down
1 change: 0 additions & 1 deletion base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ buf_ref = Ref(Buffer())
free(buf_ref)
```
In particular, note that `LibGit2.free` should be called afterward on the `Ref` object.
"""
immutable Buffer
ptr::Ptr{Cchar}
Expand Down
12 changes: 6 additions & 6 deletions base/multimedia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module Multimedia

export Display, display, pushdisplay, popdisplay, displayable, redisplay,
MIME, @MIME_str, reprmime, stringmime, istextmime,
mimewritable, TextDisplay
MIME, @MIME_str, reprmime, stringmime, istextmime,
mimewritable, TextDisplay

###########################################################################
# We define a singleton type MIME{mime symbol} for each MIME type, so
Expand Down Expand Up @@ -194,7 +194,7 @@ function display(x)
return display(displays[i], x)
catch e
isa(e, MethodError) && e.f in (display, show) ||
rethrow()
rethrow()
end
end
end
Expand All @@ -208,7 +208,7 @@ function display(m::MIME, x)
return display(displays[i], m, x)
catch e
isa(e, MethodError) && e.f == display ||
rethrow()
rethrow()
end
end
end
Expand Down Expand Up @@ -240,7 +240,7 @@ function redisplay(x)
return redisplay(displays[i], x)
catch e
isa(e, MethodError) && e.f in (redisplay, display, show) ||
rethrow()
rethrow()
end
end
end
Expand All @@ -254,7 +254,7 @@ function redisplay(m::Union{MIME,AbstractString}, x)
return redisplay(displays[i], m, x)
catch e
isa(e, MethodError) && e.f in (redisplay, display) ||
rethrow()
rethrow()
end
end
end
Expand Down
1 change: 0 additions & 1 deletion base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ immutable JLOptions
julia_bin::Ptr{UInt8}
eval::Ptr{UInt8}
print::Ptr{UInt8}
postboot::Ptr{UInt8}
load::Ptr{UInt8}
image_file::Ptr{UInt8}
cpu_target::Ptr{UInt8}
Expand Down
27 changes: 26 additions & 1 deletion base/permuteddimsarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module PermutedDimsArrays

export permutedims
export permutedims, PermutedDimsArray

# Some day we will want storage-order-aware iteration, so put perm in the parameters
immutable PermutedDimsArray{T,N,perm,iperm,AA<:AbstractArray} <: AbstractArray{T,N}
Expand All @@ -16,6 +16,29 @@ immutable PermutedDimsArray{T,N,perm,iperm,AA<:AbstractArray} <: AbstractArray{T
end
end

"""
PermutedDimsArray(A, perm) -> B
Given an AbstractArray `A`, create a view `B` such that the
dimensions appear to be permuted. Similar to `permutedims`, except
that no copying occurs (`B` shares storage with `A`).
See also: [`permutedims`](@ref).
# Example
```jldoctest
julia> A = rand(3,5,4);
julia> B = PermutedDimsArray(A, (3,1,2));
julia> size(B)
(4, 3, 5)
julia> B[3,1,2] == A[1,2,3]
true
```
"""
function PermutedDimsArray(data::AbstractArray{T,N}, perm) where (T,N)
length(perm) == N || throw(ArgumentError(string(perm, " is not a valid permutation of dimensions 1:", N)))
iperm = invperm(perm)
Expand Down Expand Up @@ -50,6 +73,8 @@ Permute the dimensions of array `A`. `perm` is a vector specifying a permutation
`ndims(A)`. This is a generalization of transpose for multi-dimensional arrays. Transpose is
equivalent to `permutedims(A, [2,1])`.
See also: [`PermutedDimsArray`](@ref).
```jldoctest
julia> A = reshape(collect(1:8), (2,2,2))
2×2×2 Array{Int64,3}:
Expand Down
2 changes: 1 addition & 1 deletion base/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ function eachline(cmd::AbstractCmd, stdin; chomp::Bool=true)
out = stdout.out
# implicitly close after reading lines, since we opened
return EachLine(out, chomp=chomp,
ondone=()->(close(out); success(processes) || pipeline_error(processes)))
ondone=()->(close(out); success(processes) || pipeline_error(processes)))::EachLine
end
eachline(cmd::AbstractCmd; chomp::Bool=true) = eachline(cmd, DevNull, chomp=chomp)

Expand Down
42 changes: 34 additions & 8 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,22 +332,48 @@ enumerated types (see `@enum`).
function instances end

# subtypes
function _subtypes(m::Module, x::DataType, sts=Set{DataType}(), visited=Set{Module}())
function _subtypes(m::Module, x::Union{DataType,UnionAll},
sts=Set{Union{DataType,UnionAll}}(), visited=Set{Module}())
push!(visited, m)
xt = unwrap_unionall(x)
if !isa(xt, DataType)
return sts
end
xt = xt::DataType
for s in names(m, true)
if isdefined(m, s) && !isdeprecated(m, s)
t = getfield(m, s)
if isa(t, DataType) && t.name.name == s && supertype(t).name == x.name
ti = typeintersect(t, x)
ti != Bottom && push!(sts, ti)
elseif isa(t, Module) && !in(t, visited)
_subtypes(t, x, sts, visited)
if isa(t, DataType)
t = t::DataType
if t.name.name === s && supertype(t).name == xt.name
ti = typeintersect(t, x)
ti != Bottom && push!(sts, ti)
end
elseif isa(t, UnionAll)
t = t::UnionAll
tt = unwrap_unionall(t)
isa(tt, DataType) || continue
tt = tt::DataType
if tt.name.name === s && supertype(tt).name == xt.name
ti = typeintersect(t, x)
ti != Bottom && push!(sts, ti)
end
elseif isa(t, Module)
t = t::Module
in(t, visited) || _subtypes(t, x, sts, visited)
end
end
end
return sts
end
subtypes(m::Module, x::DataType) = x.abstract ? sort!(collect(_subtypes(m, x)), by=string) : DataType[]
function subtypes(m::Module, x::Union{DataType,UnionAll})
if isabstract(x)
sort!(collect(_subtypes(m, x)), by=string)
else
# Fast path
Union{DataType,UnionAll}[]
end
end

"""
subtypes(T::DataType)
Expand All @@ -364,7 +390,7 @@ julia> subtypes(Integer)
Unsigned
```
"""
subtypes(x::DataType) = subtypes(Main, x)
subtypes(x::Union{DataType,UnionAll}) = subtypes(Main, x)

function to_tuple_type(t::ANY)
@_pure_meta
Expand Down
Loading

0 comments on commit e5242bd

Please sign in to comment.