Skip to content

DDC function type typeTest throws #29913

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
eernstg opened this issue Jun 16, 2017 · 1 comment
Closed

DDC function type typeTest throws #29913

eernstg opened this issue Jun 16, 2017 · 1 comment

Comments

@eernstg
Copy link
Member

eernstg commented Jun 16, 2017

DDC in some cases generates code where a typeTest throws rather than returning false when the subtype relationship does not hold. The program is accepted by dartanalyzer --strong n016.dart with no issues.

class A {}
class B extends A {}
class C extends B {}

typedef B F(B b);

C foo(A a) => null;
A bar(C c) => null;

main() {
  print(foo is F); // 'true'.
  print(bar is F); // Throws!
}

When compiling and executing the program using dartdevc.dart from 5982ace, 2017-06-15 14:18:09, ddc n016.dart, the resulting output is as follows:

true

/usr/local/google/home/eernst/devel/dart/work/sdk/pkg/dev_compiler/lib/js/common/dart_sdk.js:9877
          throw e;
          ^
Strong mode is-check failure: (C) -> A does not soundly subtype F((B) -> B)

I would expect bar is F to evaluate to false rather than throwing.

@vsmenon
Copy link
Member

vsmenon commented Jun 19, 2017

This is a dup of #28988 - note, it's currently working as intended. Once dart2js implements strong mode, intent is to of course return false.

@vsmenon vsmenon closed this as completed Jun 19, 2017
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

3 participants