Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jun 8, 2021
1 parent 5f6fb30 commit 52d13f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ function parametric_type_to_expr(@nospecialize(t::Type))
if Base.isvarargtype(t)
return Expr(:(...), t.parameters[1])
end
if t.hasfreetypevars
if Base.has_free_typevars(t)
params = map(t.parameters) do @nospecialize(p)
isa(p, TypeVar) ? p.name :
isa(p, DataType) && p.hasfreetypevars ? parametric_type_to_expr(p) : p
isa(p, DataType) && Base.has_free_typevars(p) ? parametric_type_to_expr(p) : p
end
return Expr(:curly, scopename(t.name), params...)::Expr
end
Expand Down
13 changes: 13 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -791,3 +791,16 @@ end
end
@test @interpret(f()) === 3
end

@testset "https://github.com/JuliaLang/julia/pull/41018" begin
m = Module()
@eval m begin
struct Foo
foo::Int
bar
end
end
# this shouldn't throw "type DataType has no field hasfreetypevars"
# even after https://github.com/JuliaLang/julia/pull/41018
@test Int === @interpret Core.Compiler.getfield_tfunc(m.Foo, Core.Compiler.Const(:foo))
end

0 comments on commit 52d13f6

Please sign in to comment.