@@ -1062,23 +1062,31 @@ static std::pair<Value*, bool> emit_isa(jl_codectx_t &ctx, const jl_cgval_t &x,
1062
1062
{
1063
1063
jl_value_t *intersected_type = type;
1064
1064
1065
- // TODO: The commented-out part of this optimization suffers from incorrectness issues
1066
- // due to broken subtyping for kind types (see
1067
- // https://github.com/JuliaLang/julia/issues/27078). For actual `isa` calls, this
1068
- // optimization should already have been performed upstream anyway, but having this
1069
- // optimization in codegen might still be beneficial for `typeassert`s if we can make it
1070
- // correct.
1071
1065
Optional<bool > known_isa;
1072
1066
if (x.constant ) {
1073
1067
known_isa = jl_isa (x.constant , type);
1068
+ } else {
1069
+ intersected_type = jl_type_intersection (x.typ , type);
1070
+ if (intersected_type == (jl_value_t *)jl_bottom_type)
1071
+ known_isa = false ;
1074
1072
}
1073
+
1074
+ // TODO: This commented-out version of the above check suffers from incorrectness
1075
+ // issues due to broken subtyping for kind types (see
1076
+ // https://github.com/JuliaLang/julia/issues/27078). For actual `isa` calls, this
1077
+ // optimization should already have been performed upstream anyway, but having this
1078
+ // optimization in codegen might still be beneficial for `typeassert`s if we can make it
1079
+ // correct.
1080
+ // if (x.constant) {
1081
+ // known_isa = jl_isa(x.constant, type);
1075
1082
// else if (jl_subtype(x.typ, type))
1076
1083
// known_isa = true;
1077
1084
// else {
1078
1085
// intersected_type = jl_type_intersection(x.typ, type);
1079
1086
// if (intersected_type == (jl_value_t*)jl_bottom_type)
1080
1087
// known_isa = false;
1081
1088
// }
1089
+
1082
1090
if (known_isa) {
1083
1091
if (!*known_isa && msg) {
1084
1092
emit_type_error (ctx, x, literal_pointer_val (ctx, type), *msg);
0 commit comments