@@ -956,6 +956,17 @@ precompile_test_harness("code caching") do dir
956
956
use_stale(c) = stale(c[1]) + not_stale("hello")
957
957
build_stale(x) = use_stale(Any[x])
958
958
959
+ # bindings
960
+ struct InvalidatedBinding
961
+ x::Int
962
+ end
963
+ struct Wrapper
964
+ ib::InvalidatedBinding
965
+ end
966
+ makewib(x) = Wrapper(InvalidatedBinding(x))
967
+ const gib = makewib(1)
968
+ fib() = gib.ib.x
969
+
959
970
# force precompilation
960
971
build_stale(37)
961
972
stale('c')
@@ -985,6 +996,7 @@ precompile_test_harness("code caching") do dir
985
996
Base.Experimental.@force_compile
986
997
useA2()
987
998
end
999
+ precompile($StaleA .fib, ())
988
1000
989
1001
## Reporting tests
990
1002
call_nbits(x::Integer) = $StaleA .nbits(x)
@@ -1014,6 +1026,15 @@ precompile_test_harness("code caching") do dir
1014
1026
@eval using $ StaleA
1015
1027
MA = invokelatest (getfield, @__MODULE__ , StaleA)
1016
1028
Base. eval (MA, :(nbits (:: UInt8 ) = 8 ))
1029
+ Base. eval (MA, quote
1030
+ struct InvalidatedBinding
1031
+ x:: Float64
1032
+ end
1033
+ struct Wrapper
1034
+ ib:: InvalidatedBinding
1035
+ end
1036
+ const gib = makewib (2.0 )
1037
+ end )
1017
1038
@eval using $ StaleC
1018
1039
invalidations = Base. StaticData. debug_method_invalidation (true )
1019
1040
@eval using $ StaleB
@@ -1044,6 +1065,11 @@ precompile_test_harness("code caching") do dir
1044
1065
m = only (methods (MC. call_buildstale))
1045
1066
mi = m. specializations:: Core.MethodInstance
1046
1067
@test hasvalid (mi, world) # was compiled with the new method
1068
+ m = only (methods (MA. fib))
1069
+ mi = m. specializations:: Core.MethodInstance
1070
+ @test isdefined (mi, :cache ) # it was precompiled by StaleB
1071
+ @test_broken ! hasvalid (mi, world) # invalidated by redefining `gib` before loading StaleB
1072
+ @test_broken MA. fib () === 2.0
1047
1073
1048
1074
# Reporting test (ensure SnoopCompile works)
1049
1075
@test all (i -> isassigned (invalidations, i), eachindex (invalidations))
0 commit comments