From 41353c89fb522f4f5469172d0fdbdedfa06b5dc4 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 22 Aug 2021 05:24:28 -0500 Subject: [PATCH] Add test for #38149 No code change is needed, but the use-case in that issue doesn't appear to be tested directly. Closes #38149 --- test/precompile.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/precompile.jl b/test/precompile.jl index 51b25b8325b2a..32c596f9873ed 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -875,3 +875,18 @@ precompile_test_harness("Renamed Imports") do load_path Base.compilecache(Base.PkgId("RenameImports")) @test (@eval (using RenameImports; RenameImports.test())) isa Module end + +@testset "issue 38149" begin + M = Module() + @eval M begin + @nospecialize + f(x, y) = x + y + f(x::Int, y) = 2x + y + end + precompile(M.f, (Int, Any)) + precompile(M.f, (AbstractFloat, Any)) + mis = Base.method_instances(M.f, (Any, Any)) + @test length(mis) == 2 + @test any(mi -> mi.specTypes.parameters[2] === Any, mis) + @test all(mi -> isa(mi.cache, Core.CodeInstance), mis) +end