Skip to content

Commit

Permalink
Merge pull request JuliaLang#21407 from JuliaLang/jb/fix21397
Browse files Browse the repository at this point in the history
fix JuliaLang#21397, `Nullable(Tuple)` method error
  • Loading branch information
JeffBezanson committed Apr 16, 2017
2 parents 05536c3 + 8b287ad commit 243d218
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ static void jl_cacheable_sig(
// avoid specializing on an argument of type Tuple
// unless matching a declared type of `::Type`
if (jl_is_type_type(elt) && jl_is_tuple_type(jl_tparam0(elt)) &&
!jl_has_free_typevars(decl_i) &&
(!jl_subtype(decl_i, (jl_value_t*)jl_type_type) || jl_is_kind(decl_i))) { // Type{Tuple{...}}
elt = (jl_value_t*)jl_anytuple_type_type; // Type{T} where T<:Tuple
if (!*newparams) *newparams = jl_svec_copy(type->parameters);
Expand Down Expand Up @@ -738,6 +739,7 @@ JL_DLLEXPORT int jl_is_cacheable_sig(
// avoid specializing on an argument of type Tuple
// unless matching a declared type of `::Type`
if (jl_is_type_type(elt) && jl_is_tuple_type(jl_tparam0(elt)) &&
!jl_has_free_typevars(decl_i) &&
(!jl_subtype(decl_i, (jl_value_t*)jl_type_type) || jl_is_kind(decl_i))) { // Type{Tuple{...}}
if (!jl_types_equal(elt, (jl_value_t*)jl_anytuple_type_type))
return 0;
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4820,3 +4820,8 @@ f21271() = convert(Tuple{Type{Int}, Type{Float64}}, (Int, Float64))::Tuple{Type{
f21271(x) = x::Tuple{Type{Int}, Type{Float64}}
@test_throws TypeError f21271()
@test_throws TypeError f21271((Int, Float64))

# issue #21397
bar21397(x::T) where {T} = T
foo21397(x) = bar21397(x)
@test foo21397(Tuple) == DataType
3 changes: 3 additions & 0 deletions test/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,6 @@ end
let f19270{S,T}(x::S, y::T) = Base.promote_op(^, S, T)
@test f19270(Nullable(0.0f0), Nullable(BigInt(0))) == Nullable{Float32}
end

# issue #21397
@test Nullable(Tuple) === Nullable{DataType}(Tuple)

0 comments on commit 243d218

Please sign in to comment.