Skip to content

Inconsistent runtime type errors for certain dynamic generic function invocations. #37704

Closed
@Markzipan

Description

@Markzipan
class Foo<T> {
  Foo();
}

typedef Foo FooOperation<T>([T value]);

class FooOperator<T> {
  FooOperation<T> op;
  FooOperator(this.op);
}

Foo<String> start() {
  FooOperator operation = FooOperator<String>(
    ([_]) => Foo<String>()
  );
  return operation.op();
}

main() {
  start();
}

The above snippet passes in DDC but fails in CFE with:

Unhandled exception:
type '([String]) => Foo<String>' is not a subtype of type '([dynamic]) => Foo<dynamic>'

It seems that DDC is missing the function type check (i.e., dynamicToFooOfString._check()).

What's the expected behavior here? This pattern's being used quite a bit internally, so making this stricter will require some cleanup.

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