Skip to content

[CFE] computeTypeShapeCheckSufficiency is too conservative with nullability mismatches #60076

@fishythefish

Description

@fishythefish

I think returning .insufficient here is too conservative:

if (!IsSubtypeOf.basedSolelyOnNullabilities(
expressionStaticType, checkTargetType)
.inMode(subtypeCheckMode)) {
return TypeShapeCheckSufficiency.insufficient;

(I assume SubtypeCheckMode.withNullabilities throughout this issue.)

Suppose we have

class Base<T> {}

class C<T> extends Base<T> {}

and suppose the type test in question is e is C<T> where e has static type Base<T>?. Based solely on nullabilities, Base<T>? is not a subtype of C<T>, so we get .insufficient and must do the full type test. However, it seems that .interfaceShape should suffice here, since e is C would still correctly handle the case where e is null.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions