Skip to content

Commit 2dc0645

Browse files
committed
fix: try to avoid recursive type inference
1 parent f45f0a1 commit 2dc0645

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/SearchUtils.jl

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,29 @@ end
798798
guesses::Union{AbstractVector,AbstractVector{<:AbstractVector}},
799799
datasets::Vector{D},
800800
options::AbstractOptions,
801+
) where {T,L,N,P<:AbstractPopMember{T,L,N},D<:Dataset{T,L}}
802+
return _parse_guesses_impl(P, guesses, datasets, options)
803+
end
804+
805+
# Deal with non-concrete PopMember types
806+
@unstable function parse_guesses(
807+
::Type{P},
808+
guesses::Union{AbstractVector,AbstractVector{<:AbstractVector}},
809+
datasets::Vector{D},
810+
options::AbstractOptions,
811+
) where {T,L,P<:AbstractPopMember{T,L},D<:Dataset{T,L}}
812+
NodeType = with_type_parameters(options.node_type, T)
813+
N = Base.promote_op(create_expression, NodeType, typeof(options), D)
814+
N in (Any, Union{}) && error("Failed to infer expression type")
815+
ConcreteP = with_expression_type(P, N)
816+
return _parse_guesses_impl(ConcreteP, guesses, datasets, options)
817+
end
818+
819+
@inline function _parse_guesses_impl(
820+
::Type{P},
821+
guesses::Union{AbstractVector,AbstractVector{<:AbstractVector}},
822+
datasets::Vector{D},
823+
options::AbstractOptions,
801824
) where {T,L,N,P<:AbstractPopMember{T,L,N},D<:Dataset{T,L}}
802825
nout = length(datasets)
803826
out = [P[] for _ in 1:nout]
@@ -827,20 +850,6 @@ end
827850
return out
828851
end
829852

830-
# Deal with non-concrete PopMember types
831-
@unstable function parse_guesses(
832-
::Type{P},
833-
guesses::Union{AbstractVector,AbstractVector{<:AbstractVector}},
834-
datasets::Vector{D},
835-
options::AbstractOptions,
836-
) where {T,L,P<:AbstractPopMember{T,L},D<:Dataset{T,L}}
837-
NodeType = with_type_parameters(options.node_type, T)
838-
N = Base.promote_op(create_expression, NodeType, typeof(options), D)
839-
N === Any && error("Failed to infer expression type")
840-
ConcreteP = with_expression_type(P, N)
841-
return parse_guesses(ConcreteP, guesses, datasets, options)
842-
end
843-
844853
function _make_vector_vector(guesses, nout)
845854
if nout == 1
846855
if guesses isa AbstractVector{<:AbstractVector}

0 commit comments

Comments
 (0)