Skip to content

Commit e1aaad6

Browse files
committed
Restructure tmeet based on feedback
1 parent b6ce8b1 commit e1aaad6

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

base/compiler/typelimits.jl

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -543,21 +543,19 @@ end
543543
# compute typeintersect over the extended inference lattice
544544
# where v is in the extended lattice, and t is a Type
545545
function tmeet(@nospecialize(v), @nospecialize(t))
546-
if isa(v, Const)
547-
if !has_free_typevars(t) && !isa(v.val, t)
548-
return Bottom
549-
end
546+
if isa(v, Type)
547+
return typeintersect(v, t)
548+
end
549+
has_free_typevars(t) && return v
550+
widev = widenconst(v)
551+
if widev <: t
550552
return v
551-
elseif isa(v, PartialStruct)
552-
has_free_typevars(t) && return v
553-
widev = widenconst(v)
554-
if widev <: t
555-
return v
556-
end
557-
ti = typeintersect(widev, t)
558-
if ti === Bottom
559-
return Bottom
560-
end
553+
end
554+
ti = typeintersect(widev, t)
555+
if ti === Bottom
556+
return Bottom
557+
end
558+
if isa(v, PartialStruct)
561559
@assert widev <: Tuple
562560
if isa(ti, DataType) && ti.name === Tuple.name
563561
num_fields = length(ti.parameters)
@@ -578,11 +576,7 @@ function tmeet(@nospecialize(v), @nospecialize(t))
578576
new_fields[end] = Vararg{new_fields[end]}
579577
end
580578
return tuple_tfunc(new_fields)
581-
elseif isa(v, Conditional)
582-
if !(Bool <: t)
583-
return Bottom
584-
end
585-
return v
586579
end
587-
return typeintersect(widenconst(v), t)
580+
# v is a Const or Conditional and its type is compatible with t
581+
return v
588582
end

0 commit comments

Comments
 (0)