Skip to content

Commit

Permalink
Prepare v5 (which only removes deprecated code)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Nov 1, 2024
1 parent 29a2e0a commit 5087934
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/LightSumTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,20 @@ function sumtype_expr(typedef)

constructors = [:(@inline $(namify(type))(v::Union{$(variants...)}) where {$(typeparams...)} =
$(branchs(variants, variants_with_P, :(return new{$(typeparams...)}(v)))...))]
constructors_extra = [:(function $Base.adjoint(SumT::Type{$typename})
@warn "Using A'.B syntax is deprecated in favour of the native A∘B syntax; \
the functionality will be removed in a future release of the package"
return $(Expr(:tuple, (:($nv = (args...; kwargs...) ->
$LightSumTypes.constructor($typename, $v, args...; kwargs...)) for (nv, v) in
zip(variants_names, variants_bounded))...))
end)]

if type isa Expr
push!(
constructors,
:(@inline $type(v::Union{$(variants...)}) where {$(typeparams...)} =
$(branchs(variants, variants_with_P, :(return new{$(typeparams...)}(v)))...))
)
push!(
constructors_extra,
:(function $Base.adjoint(SumT::Type{$type}) where {$(typeparams...)}
@warn "Using A'.B syntax is deprecated in favour of the native A∘B syntax; \
the functionality will be removed in a future release of the package"
return $(Expr(:tuple, (:($nv = (args...; kwargs...) -> $LightSumTypes.constructor($type, $v, args...; kwargs...))
for (nv, v) in zip(variants_names, variants))...))
end)
)
end

quote
struct $type <: $(abstract_type)
variants::Union{$(variants...)}
$(constructors...)
end
$(constructors_extra...)
@inline function $Base.getproperty(sumt::$typename, s::Symbol)
v = $LightSumTypes.unwrap(sumt)
$(branchs(variants, variants_with_P, :(return $Base.getproperty(v, s)))...)
Expand Down

0 comments on commit 5087934

Please sign in to comment.