Skip to content

Commit

Permalink
Fix exhaustive.jl test error
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Aug 4, 2024
1 parent 935f4b0 commit 5da14d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ function is_func_expr(@nospecialize(ex), meth::Method)
end
end
found && break
if isexpr(whereex, :(::))
typeex = whereex.args[end]
if isexpr(typeex, :curly) && typeex.args[1] === :Type
fname = typeex.args[2]
break
end
end
whereex = whereex.args[1]
isa(whereex, Expr) || return false
end
end
# match the function name
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
src, line = definition(String, m)
@test occursin("(::Type{T})(itr) where {T<:Invert}", src)
@test line == 126
m = @which MyArray1{Float64, 1}(undef, 5)
src, line = definition(String, m)
@test occursin("(self::Type{MyArray1{T,1}})(::UndefInitializer", src)
m = @which MyArray2{Float64, 1}(undef, 5)
src, line = definition(String, m)
@test occursin("(::Type{MyArray2{T,1}})(::UndefInitializer", src)

# Invalidation-insulating methods used by Revise and perhaps others
d = IdDict{Union{String,Symbol},Union{Function,Vector{Function}}}()
Expand Down
14 changes: 14 additions & 0 deletions test/script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,17 @@ only(methods(wrongline)).line = 9999 # unclear how it happened in the wild, bu
# Nested `where`s
struct Parametric{N} end
(::Type{P})(x::Int) where P<:Parametric{N} where N = P()

# `where`s that are not simply `(::Type{T})(args...) where T<:SomeSpecialType`
struct MyArray1{T,N}
data::T
end
function (self::Type{MyArray1{T,1}})(::UndefInitializer, m::Int) where {T}
return nothing
end
struct MyArray2{T,N}
data::T
end
function (::Type{MyArray2{T,1}})(::UndefInitializer, m::Int) where {T}
return nothing
end

0 comments on commit 5da14d5

Please sign in to comment.