From a9ba3f250480af94047bbf6767120e847653839c Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Fri, 18 Oct 2024 01:17:22 +0200 Subject: [PATCH] Add warning about deprecation of adjoint syntax --- src/LightSumTypes.jl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/LightSumTypes.jl b/src/LightSumTypes.jl index a161c80..c9c3642 100644 --- a/src/LightSumTypes.jl +++ b/src/LightSumTypes.jl @@ -65,9 +65,13 @@ function sumtype_expr(typedef) constructors = [:(@inline $(namify(type))(v::Union{$(variants...)}) where {$(typeparams...)} = $(branchs(variants, variants_with_P, :(return new{$(typeparams...)}(v)))...))] - constructors_extra = [:($Base.adjoint(SumT::Type{$typename}) = $(Expr(:tuple, (:($nv = (args...; kwargs...) -> - $LightSumTypes.constructor($typename, $v, args...; kwargs...)) for (nv, v) in - zip(variants_names, variants_bounded))...)))] + 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!( @@ -77,9 +81,12 @@ function sumtype_expr(typedef) ) push!( constructors_extra, - :($Base.adjoint(SumT::Type{$type}) where {$(typeparams...)} = - $(Expr(:tuple, (:($nv = (args...; kwargs...) -> $LightSumTypes.constructor($type, $v, args...; kwargs...)) - for (nv, v) in zip(variants_names, variants))...))) + :(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