Skip to content

Const error when chaning method invocations #40644

Closed
@dnfield

Description

@dnfield

I'm not sure if this is a bug or not, but it seems strange to me. The following program will fail to compile:

class Foo {
  const Foo();
  
  void resolve() {
    print('resolve');
  }
}

void main() {
  const Foo foo = Foo()..resolve();
}

But final Foo foo = const Foo()..resolve(); is ok, and const Foo foo = const Foo(); foo.resolve(); are both ok. I would expect the compiler to desugar the failing version into the last version there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions