-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Analyzer does not warn on function calls on Object #31509
Comments
Does |
@bwilkerson Taking a quick glance through the code, I believe you may be right. So I guess this task may be a little more involved than just switching on the flag. |
I believe the desired end-state is to remove the |
The good language folks confirmed that this is the expected behavior: void test(dynamic d, Object o, Function f) {
d(); //# 01: ok
o(); //# 02: compile-time error
f(); //# 03: ok
d.call; //# 04: ok
o.call; //# 05: compile-time error
f.call; //# 06: ok
d.call(); //# 07: ok
o.call(); //# 08: compile-time error
f.call(); //# 09: ok
} |
Hi @bwilkerson, any update on this issue? |
@mit-mit looking at tests/language_2/language_2_analyzer.status, it looks like the analyzer currently fails test case 2 (it allows |
I'm working on this. |
In Dart 2.0, it will become a compile-time error to try to perform a function invocation on a variable whose static type is `Object` (see dart-lang/sdk#31509). Since `value` is changed inside the `if` block, it is not type promoted, so its type is considered to be `Object`. Therefore, to avoid a compile-time error, we need to use an intermediate variable of type Function.
This reverts commit 6837daf. Reason for revert: Broke analyzer bots. Original change's description: > Implement proper checking for callability of Function class. > > There was some old (incorrect) logic for doing this, behind the flag > enableStrictCallChecks. This flag has been removed, since the new > behavior is now standard in Dart 2.0. > > Fixes #31509 > > Change-Id: I4a6da34a4b85ea8409f6e0d14c377a586546056a > Reviewed-on: https://dart-review.googlesource.com/40509 > Commit-Queue: Paul Berry <paulberry@google.com> > Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> > Reviewed-by: Konstantin Shcheglov <scheglov@google.com> > Reviewed-by: Mike Fairhurst <mfairhurst@google.com> TBR=paulberry@google.com,scheglov@google.com,brianwilkerson@google.com,mfairhurst@google.com Change-Id: Ib631ad16bc5e937ff914127d1c5330f3fcaff2c9 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/40980 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
Reopening issue since the fix was reverted |
In Dart 2.0, it will become a compile-time error to try to perform a function invocation on a variable whose static type is `Object` (see dart-lang/sdk#31509). Since `value` is changed inside the `if` block, it is not type promoted, so its type is considered to be `Object`. Therefore, to avoid a compile-time error, we need to use an intermediate variable of type Function.
This is the analyzer version of #21938.
For the analyzer, the change should be fairly straightforward: we just need to hardcode the
enableStrictCallChecks
option totrue
.The text was updated successfully, but these errors were encountered: