diff --git a/README.md b/README.md index d61786405..60ed52581 100644 --- a/README.md +++ b/README.md @@ -63,15 +63,13 @@ Currently, the `@compat` macro supports the following syntaxes: to declare abstract and primitive types. [#20418] This only works when `@compat` is applied directly on the declaration. -* `@compat Base.IndexStyle(::Type{<:MyArray}) = IndexLinear()` and `@compat Base.IndexStyle(::Type{<:MyArray}) = IndexCartesian()` to define traits for abstract arrays, replacing the former `Base.linearindexing{T<:MyArray}(::Type{T}) = Base.LinearFast()` and `Base.linearindexing{T<:MyArray}(::Type{T}) = Base.LinearSlow()`, respectively. - * `Compat.collect(A)` returns an `Array`, no matter what indices the array `A` has. [#21257] * `@compat foo(::CartesianRange{N})` to replace the former `foo(::CartesianRange{CartesianIndex{N}})` ([#20974]). Note that `CartesianRange` now has two type parameters, so using them as fields in other `struct`s requires manual intervention. - + * Required keyword arguments ([#25830]). For example, `@compat foo(; x, y)` makes `x` and `y` required keyword arguments: when calling `foo`, an error is thrown if `x` or `y` is not explicitly provided. ## Module Aliases diff --git a/src/Compat.jl b/src/Compat.jl index e91d6d75a..99e34ee3c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -250,15 +250,6 @@ include("arraymacros.jl") # julia #18839 import Base.Iterators # TODO deprecate, remove -@static if VERSION < v"0.6.0-dev.2840" - export IndexStyle, IndexLinear, IndexCartesian - eval(Expr(:typealias, :IndexStyle, :(Base.LinearIndexing))) - eval(Expr(:typealias, :IndexLinear, :(Base.LinearFast))) - eval(Expr(:typealias, :IndexCartesian, :(Base.LinearSlow))) - IndexStyle{T}(::Type{T}) = Base.linearindexing(T) - IndexStyle(args...) = Base.linearindexing(args...) -end - if VERSION < v"0.6.0-dev.1653" for (fname, felt) in ((:zeros,:zero), (:ones,:one)) @eval begin diff --git a/src/compatmacro.jl b/src/compatmacro.jl index cc2c1669e..69c149040 100644 --- a/src/compatmacro.jl +++ b/src/compatmacro.jl @@ -7,12 +7,6 @@ export @compat """Get just the function part of a function declaration.""" withincurly(ex) = isexpr(ex, :curly) ? ex.args[1] : ex -is_index_style(ex::Expr) = ex == :(Compat.IndexStyle) || ex == :(Base.IndexStyle) || - (ex.head == :(.) && (ex.args[1] == :Compat || ex.args[1] == :Base) && - ex.args[2] == Expr(:quote, :IndexStyle)) - -is_index_style(arg) = false - istopsymbol(ex, mod, sym) = ex in (sym, Expr(:(.), mod, Expr(:quote, sym))) if !isdefined(Base, :UndefKeywordError) @@ -40,18 +34,6 @@ function _compat(ex::Expr) # Passthrough return ex end - if VERSION < v"0.6.0-dev.2840" - if ex.head == :(=) && isa(ex.args[1], Expr) && ex.args[1].head == :call - a = ex.args[1].args[1] - if is_index_style(a) - ex.args[1].args[1] = :(Base.linearindexing) - elseif isa(a, Expr) && a.head == :curly - if is_index_style(a.args[1]) - ex.args[1].args[1].args[1] = :(Base.linearindexing) - end - end - end - end if VERSION < v"0.7.0-DEV.880" if ex.head == :curly && ex.args[1] == :CartesianRange && length(ex.args) >= 2 a = ex.args[2] diff --git a/test/runtests.jl b/test/runtests.jl index d26bdca0d..c6cc296c9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -434,31 +434,6 @@ end @test isbitstype(Primitive20418{Int}) @test sizeof(Primitive20418{Int}) == 2 -module CompatArray - using Compat - const struct_sym = VERSION < v"0.7.0-DEV.1263" ? :type : :struct - eval(Expr( - struct_sym, false, - Expr(:(<:), :(CartesianArray{T,N}), :(AbstractArray{T,N})), - quote - parent::Array{T,N} - end)) - eval(Expr( - struct_sym, false, - Expr(:(<:), :(LinearArray{T,N}), :(AbstractArray{T,N})), - quote - parent::Array{T,N} - end)) - @compat Base.IndexStyle(::Type{<:LinearArray}) = IndexLinear() -end -@test IndexStyle(Array{Float32,2}) === IndexLinear() -@test IndexStyle(CompatArray.CartesianArray{Float32,2}) === IndexCartesian() -@test IndexStyle(CompatArray.LinearArray{Float32,2}) === IndexLinear() -let a = CompatArray.CartesianArray(rand(2,3)), b = CompatArray.LinearArray(rand(2,3)) - @test IndexStyle(a) === IndexCartesian() - @test IndexStyle(b) === IndexLinear() -end - if VERSION < v"0.6.0-dev.1653" for (A,val) in ((zeros(1:5, Float32, 3, 2), 0), (ones(1:5, Float32, 3, 2), 1),