@@ -241,7 +241,29 @@ ci = code_lowered(f, Tuple{Int})[1]
241
241
242
242
g (:: Val{x} ) where {x} = x ? 1 : 0
243
243
ci = code_lowered (g, Tuple{Val{true }})[1 ]
244
- @test Meta. partially_inline! (ci. code, [], Tuple{typeof (g),Val{true }}, Any[Val{true }], 0 , 0 , :propagate )[1 ] ==
245
- Core. GotoIfNot (QuoteNode (Val{true }), 3 )
246
- @test Meta. partially_inline! (ci. code, [], Tuple{typeof (g),Val{true }}, Any[Val{true }], 0 , 2 , :propagate )[1 ] ==
247
- Core. GotoIfNot (QuoteNode (Val{true }), 5 )
244
+ @test Meta. partially_inline! (ci. code, [], Tuple{typeof (g),Val{true }}, Any[true ], 0 , 0 , :propagate )[1 ] ==
245
+ Core. GotoIfNot (QuoteNode (true ), 3 )
246
+ @test Meta. partially_inline! (ci. code, [], Tuple{typeof (g),Val{true }}, Any[true ], 0 , 2 , :propagate )[1 ] ==
247
+ Core. GotoIfNot (QuoteNode (true ), 5 )
248
+
249
+ @testset " inlining with isdefined" begin
250
+ isdefined_slot (x) = @isdefined (x)
251
+ ci = code_lowered (isdefined_slot, Tuple{Int})[1 ]
252
+ @test Meta. partially_inline! (copy (ci. code), [], Tuple{typeof (isdefined_slot), Int},
253
+ [], 0 , 0 , :propagate )[1 ] == Expr (:isdefined , Core. SlotNumber (2 ))
254
+ @test Meta. partially_inline! (copy (ci. code), [isdefined_slot, 1 ], Tuple{typeof (isdefined_slot), Int},
255
+ [], 0 , 0 , :propagate )[1 ] == true
256
+
257
+ isdefined_sparam (:: T ) where {T} = @isdefined (T)
258
+ ci = code_lowered (isdefined_sparam, Tuple{Int})[1 ]
259
+ @test Meta. partially_inline! (copy (ci. code), [], Tuple{typeof (isdefined_sparam), Int},
260
+ Any[Int], 0 , 0 , :propagate )[1 ] == true
261
+ @test Meta. partially_inline! (copy (ci. code), [], Tuple{typeof (isdefined_sparam), Int},
262
+ [], 0 , 0 , :propagate )[1 ] == Expr (:isdefined , Expr (:static_parameter , 1 ))
263
+
264
+ @eval isdefined_globalref (x) = $ (Expr (:isdefined , GlobalRef (Base, :foo )))
265
+ ci = code_lowered (isdefined_globalref, Tuple{Int})[1 ]
266
+ @test Meta. partially_inline! (copy (ci. code), Any[isdefined_globalref, 1 ], Tuple{typeof (isdefined_globalref), Int},
267
+ [], 0 , 0 , :propagate )[1 ] == Expr (:isdefined , GlobalRef (Base, :foo ))
268
+
269
+ end
0 commit comments