Skip to content

Flow analysis. No promotion from Object? to Null #60741

Open
@sgrekhov

Description

@sgrekhov

The following test fails.

test1() {
  Object? s = "x";
  s as String;
  if (s is Null) {} // ignore: unnecessary_type_check
  s = null;
  s.expectStaticType<Exactly<Null>>(); // COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
                                       //  'Exactly<Null>' doesn't conform to the bound 'Exactly<Object?>' of the type parameter 'R'.
}

Null is a proper subtype of Object? and the type of interest for s, so there should be a promotion.

cc @stereotype441

Metadata

Metadata

Assignees

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-flowImplementation of flow analysis in analyzer/cfe

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions