From 79b32587ca9af7d3f8894e42d9ce8f05603d3fb4 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 4 Jun 2018 22:19:53 -0400 Subject: [PATCH] fix #27361, error adding method using e.g. `Tuple{3}` (#27404) (cherry picked from commit f89921fb36c34addee47b1ab93cb49d9d7b3d934) --- src/subtype.c | 6 ++++-- test/specificity.jl | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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