diff --git a/Project.toml b/Project.toml index 00abd5ae6..6f8cd3339 100644 --- a/Project.toml +++ b/Project.toml @@ -40,6 +40,7 @@ Preferences = "1.4" Random = "1.10" Revise = "3.3" StaticArrays = "1.7.0" +TOML = "1.0.3" Test = "1.10" julia = "1.10" @@ -53,7 +54,8 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BenchmarkTools", "Cthulhu", "Example", "Libdl", "Logging", "Random", "Revise", "StaticArrays", "Test"] +test = ["Aqua", "BenchmarkTools", "Cthulhu", "Example", "Libdl", "Logging", "Random", "Revise", "StaticArrays", "TOML", "Test"] diff --git a/src/JET.jl b/src/JET.jl index 9f2d60e39..3df042ec9 100644 --- a/src/JET.jl +++ b/src/JET.jl @@ -618,6 +618,9 @@ General users should use high-level entry points like [`report_call`](@ref) and """ function analyze_and_report_call!(analyzer::AbstractAnalyzer, @nospecialize(f), @nospecialize(types = Base.default_tt(f)); jetconfigs...) + if f isa Core.OpaqueClosure + return analyze_and_report_opaque_closure!(analyzer, f, types; jetconfigs...) + end tt = Base.signature_type(f, types) return analyze_and_report_call!(analyzer, tt::Type{<:Tuple}; jetconfigs...) end @@ -675,6 +678,19 @@ function analyze_method_signature!(analyzer::AbstractAnalyzer, m::Method, @nospe return analyze_method_instance!(analyzer, mi) end +function analyze_and_report_opaque_closure!(analyzer::AbstractAnalyzer, oc::Core.OpaqueClosure, @nospecialize(types); + jetconfigs...) + validate_configs(analyzer, jetconfigs) + env = Base.to_tuple_type(Any[Core.Typeof(x) for x in oc.captures]) + tt = Tuple{env, #=sig=#(Base.to_tuple_type(types)::DataType).parameters...} + mi = specialize_method(oc.source::Method, tt, svec()) + analyzer, result = analyze_method_instance!(analyzer, mi) + analyzername = nameof(typeof(analyzer)) + sig = LazyPrinter(io->Base.show_tuple_as_call(io, Symbol(""), tt)) + source = lazy"$analyzername: $sig" + return JETCallResult(result, analyzer, source; jetconfigs...) +end + function analyze_method_instance!(analyzer::AbstractAnalyzer, mi::MethodInstance) result = InferenceResult(mi) diff --git a/test/test_misc.jl b/test/test_misc.jl index de99171d7..1391b7e99 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -49,8 +49,12 @@ end end end -using Base.TOML using JET: process_config_dict +@static if VERSION ≥ v"1.11-" + using TOML: TOML +else + using Base.TOML: TOML +end macro toml_str(s); TOML.parse(TOML.Parser(s)); end @testset "`process_config_dict`" begin