Skip to content

[ddc] Generic callable leads to "NoSuchMethodError" #54461

@srujzs

Description

@srujzs

Originally reported here: #54342 (comment)

class CallableObject {
  const CallableObject();

  void call() {
    print("CallableObject called");
  }
}

class ValueContainer<T> {
  ValueContainer(this.value);
  final T value;
  final value2 = const CallableObject();
}

void main() {
  final b = ValueContainer(const CallableObject());
  b.value2(); // Runs correctly and calls the "call" function
  b.value.call(); // Also runs correctly
  b.value(); // NoSuchMethodError: tried to call a non-function, such as null: 'b.value'
}

It looks like DDC interprets b.value() as a method call and not a property get + call. This passes in dart2js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dart2js-ddc-discrepancyWhen dev and production compilations have different semanticsweb-dev-compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions