Skip to content

resolution does not understand function types as generic bounds #27458

Closed
@jmesserly

Description

@jmesserly

Consider:

typedef T Func1<T>();

// NOTE: return T here just so we can see what inferred type is.
// The actual expectAsync returns F.
T expectAsync<T, F extends Func1<T>>(F callback) {
  // BUG: this is an implicit cast, but we should know it returns a T.
  // BUG: this is a dynamic call but it shouldn't be.
  return callback();
}

main() {
  var y = expectAsync(() => 123);
  // this inference seems to work.
  int z = y;
  print(z);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work ondart-model-analyzer-specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions