@@ -2264,12 +2264,18 @@ struct AliasableFields{S,T}
22642264 f1:: S
22652265 f2:: T
22662266end
2267+ struct NullableAliasableFields{S,T}
2268+ f1:: S
2269+ f2:: T
2270+ NullableAliasableFields (f1:: S , f2:: T ) where {S,T} = new {S,T} (f1, f2)
2271+ NullableAliasableFields (f1:: S ) where {S} = new {S,Union{}} (f1)
2272+ end
22672273mutable struct AliasableConstField{S,T}
22682274 const f1:: S
22692275 f2:: T
22702276end
22712277
2272- import . Compiler:
2278+ using . Compiler:
22732279 InferenceLattice, MustAliasesLattice, InterMustAliasesLattice,
22742280 BaseInferenceLattice, SimpleInferenceLattice, IPOResultLattice, typeinf_lattice, ipo_lattice, optimizer_lattice
22752281
@@ -2282,7 +2288,7 @@ Compiler.optimizer_lattice(::MustAliasInterpreter) = SimpleInferenceLattice.inst
22822288# lattice
22832289# -------
22842290
2285- import . Compiler: MustAlias, Const, PartialStruct, ⊑ , tmerge
2291+ using . Compiler: MustAlias, Const, PartialStruct, ⊑ , tmerge
22862292let 𝕃ᵢ = InferenceLattice (MustAliasesLattice (BaseInferenceLattice. instance))
22872293 ⊑ (@nospecialize (a), @nospecialize (b)) = Compiler.:⊑ (𝕃ᵢ, a, b)
22882294 tmerge (@nospecialize (a), @nospecialize (b)) = Compiler. tmerge (𝕃ᵢ, a, b)
@@ -2520,6 +2526,15 @@ jet509_hasitems(list) = length(list) >= 1
25202526 error (" list is empty" )
25212527end |> only == Vector{Int}
25222528
2529+ # don't form nested slot wrappers
2530+ @test Base. infer_return_type ((NullableAliasableFields{NullableAliasableFields},); interp= MustAliasInterpreter ()) do x
2531+ y = getfield (x, :f1 )
2532+ if isdefined (y, :f2 ) && isa (getfield (y, :f2 ), Int)
2533+ return getfield (y, :f2 )
2534+ end
2535+ return 0
2536+ end == Int
2537+
25232538# === constraint
25242539# --------------
25252540
0 commit comments