@@ -586,21 +586,19 @@ end
586
586
# compute typeintersect over the extended inference lattice
587
587
# where v is in the extended lattice, and t is a Type
588
588
function tmeet (@nospecialize (v), @nospecialize (t))
589
- if isa (v, Const)
590
- if ! has_free_typevars (t) && ! isa (v. val, t)
591
- return Bottom
592
- end
589
+ if isa (v, Type)
590
+ return typeintersect (v, t)
591
+ end
592
+ has_free_typevars (t) && return v
593
+ widev = widenconst (v)
594
+ if widev <: t
593
595
return v
594
- elseif isa (v, PartialStruct)
595
- has_free_typevars (t) && return v
596
- widev = widenconst (v)
597
- if widev <: t
598
- return v
599
- end
600
- ti = typeintersect (widev, t)
601
- if ti === Bottom
602
- return Bottom
603
- end
596
+ end
597
+ ti = typeintersect (widev, t)
598
+ if ti === Bottom
599
+ return Bottom
600
+ end
601
+ if isa (v, PartialStruct)
604
602
@assert widev <: Tuple
605
603
if isa (ti, DataType) && ti. name === Tuple. name
606
604
num_fields = length (ti. parameters)
@@ -612,7 +610,7 @@ function tmeet(@nospecialize(v), @nospecialize(t))
612
610
end
613
611
new_fields = Vector {Any} (undef, num_fields)
614
612
for i = 1 : num_fields
615
- new_fields[i] = tmeet (getfield_tfunc (v, Const (i) ), widenconst (getfield_tfunc (ti, Const (i))))
613
+ new_fields[i] = tmeet (unwrapva (v . fields[ min (i, end )] ), widenconst (getfield_tfunc (ti, Const (i))))
616
614
if new_fields[i] === Bottom
617
615
return Bottom
618
616
end
@@ -621,11 +619,7 @@ function tmeet(@nospecialize(v), @nospecialize(t))
621
619
new_fields[end ] = Vararg{new_fields[end ]}
622
620
end
623
621
return tuple_tfunc (new_fields)
624
- elseif isa (v, Conditional)
625
- if ! (Bool <: t )
626
- return Bottom
627
- end
628
- return v
629
622
end
630
- return typeintersect (widenconst (v), t)
623
+ # v is a Const or Conditional and its type is compatible with t
624
+ return v
631
625
end
0 commit comments