diff --git a/src/subtype.c b/src/subtype.c index b71aa76609d56..5799ef59aa346 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -2227,8 +2227,10 @@ static int sub_msp(jl_value_t *a, jl_value_t *b, jl_typeenv_t *env) { JL_GC_PUSH2(&a, &b); while (env != NULL) { - a = jl_type_unionall(env->var, a); - b = jl_type_unionall(env->var, b); + if (jl_is_type(a) || jl_is_typevar(a)) + a = jl_type_unionall(env->var, a); + if (jl_is_type(b) || jl_is_typevar(b)) + b = jl_type_unionall(env->var, b); env = env->prev; } int sub = jl_subtype(a, b); diff --git a/test/specificity.jl b/test/specificity.jl index 0273a93b2d582..491b1c3c27660 100644 --- a/test/specificity.jl +++ b/test/specificity.jl @@ -194,3 +194,8 @@ let A = Tuple{Vector, AbstractVector}, @test args_morespecific(B, C) @test args_morespecific(A, C) end + +# issue #27361 +f27361(::M) where M <: Tuple{2} = nothing +f27361(::M) where M <: Tuple{3} = nothing +@test length(methods(f27361)) == 2