Skip to content

Commit e3e240c

Browse files
committed
1 parent 9a8c427 commit e3e240c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/Static.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export StaticInt, StaticFloat64, StaticSymbol, True, False, StaticBool, NDIndex
77
export dynamic, is_static, known, static
88

99
@static if VERSION >= v"1.7.0-DEV.421"
10-
using Base: @aggressive_constprop
10+
using Base: @constprop
1111
else
12-
macro aggressive_constprop(ex)
12+
macro constprop(_, ex)
1313
ex
1414
end
1515
end
@@ -30,7 +30,7 @@ Returns the known value corresponding to a static type `T`. If `T` is not a stat
3030
See also: [`static`](@ref), [`is_static`](@ref)
3131
"""
3232
known
33-
@aggressive_constprop known(x) = known(typeof(x))
33+
@constprop :aggressive known(x) = known(typeof(x))
3434
known(::Type{T}) where {T} = nothing
3535
known(::Type{StaticInt{N}}) where {N} = N::Int
3636
known(::Type{StaticFloat64{N}}) where {N} = N::Float64
@@ -67,19 +67,19 @@ static(:x)
6767
```
6868
"""
6969
static
70-
@aggressive_constprop static(x::X) where {X} = ifelse(is_static(X), identity, _no_static_type)(x)
71-
@aggressive_constprop static(x::Int) = StaticInt(x)
72-
@aggressive_constprop static(x::Union{Int8,UInt8,Int16,UInt16}) = StaticInt(x % Int)
70+
@constprop :aggressive static(x::X) where {X} = ifelse(is_static(X), identity, _no_static_type)(x)
71+
@constprop :aggressive static(x::Int) = StaticInt(x)
72+
@constprop :aggressive static(x::Union{Int8,UInt8,Int16,UInt16}) = StaticInt(x % Int)
7373
@static if sizeof(Int) == 8
74-
@aggressive_constprop static(x::Union{Int32,UInt32}) = StaticInt(x % Int)
75-
@aggressive_constprop static(x::UInt64) = StaticInt(Int(x))
74+
@constprop :aggressive static(x::Union{Int32,UInt32}) = StaticInt(x % Int)
75+
@constprop :aggressive static(x::UInt64) = StaticInt(Int(x))
7676
else
77-
@aggressive_constprop static(x::UInt32) = StaticInt(Int(x))
77+
@constprop :aggressive static(x::UInt32) = StaticInt(Int(x))
7878
end
79-
@aggressive_constprop static(x::Float64) = StaticFloat64(x)
80-
@aggressive_constprop static(x::Bool) = StaticBool(x)
81-
@aggressive_constprop static(x::Symbol) = StaticSymbol(x)
82-
@aggressive_constprop static(x::Tuple{Vararg{Any}}) = map(static, x)
79+
@constprop :aggressive static(x::Float64) = StaticFloat64(x)
80+
@constprop :aggressive static(x::Bool) = StaticBool(x)
81+
@constprop :aggressive static(x::Symbol) = StaticSymbol(x)
82+
@constprop :aggressive static(x::Tuple{Vararg{Any}}) = map(static, x)
8383
@generated static(::Val{V}) where {V} = static(V)
8484
function _no_static_type(@nospecialize(x))
8585
error("There is no static alternative for type $(typeof(x)).")
@@ -102,7 +102,7 @@ is_static(@nospecialize(x::Type{<:Val})) = True()
102102
is_static(@nospecialize(x::Type{<:StaticFloat64})) = True()
103103
is_static(x::Type{T}) where {T} = False()
104104

105-
@aggressive_constprop _tuple_static(::Type{T}, i) where {T} = is_static(_get_tuple(T, i))
105+
@constprop :aggressive _tuple_static(::Type{T}, i) where {T} = is_static(_get_tuple(T, i))
106106
function is_static(::Type{T}) where {N,T<:Tuple{Vararg{Any,N}}}
107107
if all(eachop(_tuple_static, nstatic(Val(N)), T))
108108
return True()
@@ -119,7 +119,7 @@ Returns the "dynamic" or non-static form of `x`.
119119
dynamic(x::X) where {X} = _dynamic(is_static(X), x)
120120
_dynamic(::True, x::X) where {X} = known(X)
121121
_dynamic(::False, x::X) where {X} = x
122-
@aggressive_constprop dynamic(x::Tuple) = map(dynamic, x)
122+
@constprop :aggressive dynamic(x::Tuple) = map(dynamic, x)
123123
dynamic(x::NDIndex) = CartesianIndex(dynamic(Tuple(x)))
124124

125125
end

0 commit comments

Comments
 (0)