Skip to content

asA generates code which prevents an expression from being an arrow function #941

Closed
dart-archive/code_builder
#322
@srawlins

Description

@srawlins

I added this test case to test/specs/code/expression_test.dart around line 470:

test('should emit an explicit cast in an arrow function', () {
    expect(
      refer('callback').call([
        Method((b) => b..body = refer('foo').asA(refer('String')).code).closure
      ]),
      equalsDart('callback(() => ( foo as String ))'),
    );
  });

The test fails because the output is actually callback(() { ( foo as String )... which

a. does not have the expected =>, and
b. does not include a semi-colon, so the output is not even parseable Dart.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions