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