diff --git a/Compiler/src/typeinfer.jl b/Compiler/src/typeinfer.jl index 2ae0c627b1b4d..1b339d5514e25 100644 --- a/Compiler/src/typeinfer.jl +++ b/Compiler/src/typeinfer.jl @@ -1642,6 +1642,12 @@ function collectinvokes!(workqueue::CompilationQueue, ci::CodeInfo, sptypes::Vec push!(argtypes, sp_type_rewrap(at[i], linfo, #= isreturn =# false)) end atype = argtypes_to_type(argtypes) + elseif isexpr(stmt, :new) + # When creating a struct of Function type, check to see if we should + # proactively compile the lambda + t, _, _, _ = instanceof_tfunc(argextype(stmt.args[1], ci, sptypes)) + t <: Function || continue + atype = Tuple{t, Vararg} else # TODO: handle other StmtInfo like OpaqueClosure? continue