Skip to content

Commit

Permalink
add a subtyping fast path for tuple of Unions <: Vararg (#33353)
Browse files Browse the repository at this point in the history
fixes #33337
  • Loading branch information
JeffBezanson authored Sep 23, 2019
1 parent 187ee96 commit 4f17558
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,10 @@ static int subtype_tuple_tail(struct subtype_tuple_env *env, int8_t R, jl_stenv_
yi = jl_tparam0(jl_unwrap_unionall(env->vty));
if (!env->vvx && yi == (jl_value_t*)jl_any_type)
goto done; // if y ends in `Vararg{Any}` skip checking everything
// var T in Vararg{T} is diagonal; an abstract type can't be a subtype of it,
// so avoid exponential blowup when xi is a Union.
if (jl_is_typevar(yi) && jl_is_uniontype(xi) && !jl_has_free_typevars(xi))
return 0;
}
if (xi == env->lastx &&
((yi == env->lasty && !jl_has_free_typevars(xi) && !jl_has_free_typevars(yi)) ||
Expand Down
4 changes: 4 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1676,3 +1676,7 @@ c32703(::Type{<:Str{C}}, str::Str{C}) where {C<:CSE} = str
@testintersect(Tuple{Pair{Int, DataType}, Any},
Tuple{Pair{A, B} where B<:Type, Int} where A,
Tuple{Pair{Int, DataType}, Int})

# issue #33337
@test !issub(Tuple{Type{T}, T} where T<:NTuple{30, Union{Nothing, Ref}},
Tuple{Type{Tuple{Vararg{V, N} where N}}, Tuple{Vararg{V, N} where N}} where V)

4 comments on commit 4f17558

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.