Skip to content

Front-end generates improperly typed block expressions #39566

@sjindel-google

Description

@sjindel-google

Consider this code from class_builder.dart:

      context = [
        message.withLocation(declaredMember.fileUri, fileOffset, length),
        ...?context
      ];

This gets compiled to this Kernel:

  context = block {
    final dart.core::List<_fe_analyzer_shared.messages.codes::LocatedMessage*>* #t3 = <_fe_analyzer_shared.messages.codes::LocatedMessage*>[];
    #t3.{dart.core::List::add}(message.{_fe_analyzer_shared.messages.codes::Message::withLocation}(declaredMember.{kernel.ast::Member::fileUri}, fileOffset, length));
    final dynamic #t1 = context;
    if(!#t1.{dart.core::Object::==}(null))
      for (final _fe_analyzer_shared.messages.codes::LocatedMessage* #t2 in #t1)
        #t3.{dart.core::List::add}(#t2);
  } =>#t3;

However, this Kernel is ill-typed, because the type of the iterable expression #t1 is dynamic, where it must be a subtype of Iterable to be used directly in a for-in expresion.

/cc @mkustermann @johnniwinther

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions