Skip to content

Missing covariant check on type param #27269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vsmenon opened this issue Sep 6, 2016 · 1 comment
Closed

Missing covariant check on type param #27269

vsmenon opened this issue Sep 6, 2016 · 1 comment

Comments

@vsmenon
Copy link
Member

vsmenon commented Sep 6, 2016

The following gives no strong mode errors and prints 'hello1' in DDC - adding a string and int without error.

Where is the missing runtime check? :-) @leafpetersen @jmesserly

typedef T Callback<T>(T val);

class Foo<T> {
  T x;

  Callback<T> _callback;

  Callback<T> get callback => _callback;
  void set callback(Callback<T> f) { _callback = f; }
}

void main() {
  Foo<int> f = new Foo<int>();
  f.callback = (x) => x + 1;

  Foo<Object> f2 = f;
  var result = f2.callback('hello');
  print(result);
}
@jmesserly
Copy link

I believe this is a dupe of #27259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants