@@ -433,6 +433,8 @@ function tmerge(lattice::ConditionalsLattice, @nospecialize(typea), @nospecializ
433
433
end
434
434
return Bool
435
435
end
436
+ typea = widenconditional (typea)
437
+ typeb = widenconditional (typeb)
436
438
return tmerge (widenlattice (lattice), typea, typeb)
437
439
end
438
440
471
473
472
474
function tmerge (lattice:: PartialsLattice , @nospecialize (typea), @nospecialize (typeb))
473
475
# type-lattice for Const and PartialStruct wrappers
474
- if ((isa (typea, PartialStruct) || isa (typea, Const)) &&
475
- (isa (typeb, PartialStruct) || isa (typeb, Const)))
476
+ acp = isa (typea, Const) || isa (typea, PartialStruct)
477
+ bcp = isa (typeb, Const) || isa (typeb, PartialStruct)
478
+ if acp && bcp
476
479
aty = widenconst (typea)
477
480
bty = widenconst (typeb)
478
481
if aty === bty
@@ -521,22 +524,40 @@ function tmerge(lattice::PartialsLattice, @nospecialize(typea), @nospecialize(ty
521
524
return anyrefine ? PartialStruct (aty, fields) : aty
522
525
end
523
526
end
527
+ # Don't widen const here - external AbstractInterpreter might insert lattice
528
+ # layers between us and `ConstsLattice`.
529
+ isa (typea, PartialStruct) && (typea = widenconst (typea))
530
+ isa (typeb, PartialStruct) && (typeb = widenconst (typeb))
524
531
525
532
# type-lattice for PartialOpaque wrapper
526
- if isa (typea, PartialOpaque) && isa (typeb, PartialOpaque) && widenconst (typea) == widenconst (typeb)
527
- if ! (typea. source === typeb. source &&
528
- typea. parent === typeb. parent)
529
- return widenconst (typea)
533
+ apo = isa (typea, PartialOpaque)
534
+ bpo = isa (typeb, PartialOpaque)
535
+ if apo && bpo
536
+ aty = widenconst (typea)
537
+ bty = widenconst (typeb)
538
+ if aty == bty
539
+ if ! (typea. source === typeb. source &&
540
+ typea. parent === typeb. parent)
541
+ return widenconst (typea)
542
+ end
543
+ return PartialOpaque (typea. typ, tmerge (typea. env, typeb. env),
544
+ typea. parent, typea. source)
530
545
end
531
- return PartialOpaque (typea. typ, tmerge (typea. env, typeb. env),
532
- typea. parent, typea. source)
546
+ typea = aty
547
+ typeb = bty
548
+ elseif apo
549
+ typea = widenconst (typea)
550
+ elseif bpo
551
+ typeb = widenconst (typeb)
533
552
end
534
553
535
- # no special type-inference lattice, join the types
536
- typea, typeb = widenconst (typea), widenconst (typeb)
537
- @assert isa (typea, Type); @assert isa (typeb, Type)
554
+ return tmerge (widenlattice (lattice), typea, typeb)
555
+ end
538
556
539
- return tmerge (JLTypeLattice (), typea, typeb)
557
+ function tmerge (lattice:: ConstsLattice , @nospecialize (typea), @nospecialize (typeb))
558
+ # the equality of the constants can be checked here, but the equivalent check is usually
559
+ # done by `tmerge_fast_path` at earlier lattice stage
560
+ return tmerge (widenlattice (lattice), widenconst (typea), widenconst (typeb))
540
561
end
541
562
542
563
function tmerge (:: JLTypeLattice , @nospecialize (typea:: Type ), @nospecialize (typeb:: Type ))
0 commit comments