-
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
Static checker warns on optional arguments with default values assigned, when using explicit interface. #3426
Comments
This comment was originally written by [email protected] Sorry, forgot to mention: Build 8394. |
Added Area-Analyzer, Triaged labels. |
Actually, methods defined in an interface are allowed to specify a default value. According to the spec: It is a static warning if an instance method m1 overrides an instance member m2, the signature of m2 explicitly specifies a default value for a formal parameter p and the signature of m1 specifies a different default value for p. and: It is a static warning if an interface method m1 overrides an interface method m2, the signature of m2 explicitly specifies a default value for a formal parameter p and the signature of m1 specifies a different default value for p. The problem is that we are creating a warning when a default value was not explicitly provided. Added this to the M1 milestone. |
https://chromiumcodereview.appspot.com/10534084 Added Started label. |
https://code.google.com/p/dart/source/detail?r=8496 Added Fixed label. |
Changes: ``` > git log --format="%C(auto) %h %s" 51435ef..c4e9ddc https://dart.googlesource.com/pub.git/+/c4e9ddc8 Extend retries for file-ops on windows (#3451) https://dart.googlesource.com/pub.git/+/6aeb1795 Upgrade package:lints to 2.0.0 (#3445) https://dart.googlesource.com/pub.git/+/73ea9a98 Roll tar to 0.5.5+1 (#3447) https://dart.googlesource.com/pub.git/+/2dc887fe Add env var for writing golden files (#3222) https://dart.googlesource.com/pub.git/+/764500b8 List all files in pub publish (#3440) https://dart.googlesource.com/pub.git/+/0b52e6a8 Remove debug print (#3441) https://dart.googlesource.com/pub.git/+/ea070238 Merge pull request #3443 from jonasfj/master https://dart.googlesource.com/pub.git/+/bffd1267 Merge branch 'cherry-pick-for-2.17.2' https://dart.googlesource.com/pub.git/+/c66381c5 Make `name` field of `_UserInfo` nullable. Fix #3424 (#3442) https://dart.googlesource.com/pub.git/+/cecc8e3c Handle broken response from userinfo_endpoint (#3427) https://dart.googlesource.com/pub.git/+/6c635040 Make `name` field of `_UserInfo` nullable. Fix #3424 (#3442) https://dart.googlesource.com/pub.git/+/6f20a94b Handle missing pubspec.lock in dependency_services list (#3439) https://dart.googlesource.com/pub.git/+/0ad17e84 Handle broken response from userinfo_endpoint (#3427) https://dart.googlesource.com/pub.git/+/153ef061 `pub add` create top-level attribute in block-style if possible. (#3423) https://dart.googlesource.com/pub.git/+/3b96f910 Handle error code 183 on windows (#3426) https://dart.googlesource.com/pub.git/+/9eb6428c Ignore `pubspec_overrides.yaml` for `publish` command (#3419) ``` Diff: https://dart.googlesource.com/pub.git/+/51435efcd574b7bc18d47a5dd620cb9759dea8f8~..c4e9ddc888c3aa89ef4462f0c4298929191e32b9/ Change-Id: I6dacb3e95c6399d3fb5cf340b5d0e5cded270684 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247962 Commit-Queue: Sigurd Meldgaard <[email protected]> Reviewed-by: Jonas Jensen <[email protected]>
…native, protobuf, pub_semver, shelf, stack_trace, tools, vector_math, webdev Revisions updated by `dart tools/rev_sdk_deps.dart`. args (https://github.com/dart-lang/args/compare/f0f6cd2..a9543c0): a9543c0 2023-05-31 Devon Carew switch to using package:dart_flutter_team_lints (#247) 36407ea 2023-05-31 Devon Carew adjust the validation of mandatory options (#246) bazel_worker (https://github.com/dart-lang/bazel_worker/compare/d9b389f..c14a268): c14a268 2023-05-31 Kevin Moore Bump lints, regenerate proto file, fix script (#74) dartdoc (https://github.com/dart-lang/dartdoc/compare/950898f..39fe1a8): 39fe1a8a 2023-05-31 Parker Lougheed Update highlight.js to 11.8.0 for Dart 3 syntax highlighting (#3416) 4574e819 2023-05-30 Sam Rawlins Convert kind to an enum (#3426) http (https://github.com/dart-lang/http/compare/18a43a2..8834aec): 8834aec 2023-05-31 Brian Quinlan Update readme and prepare for a new release (#954) aca7f0e 2023-05-31 dependabot[bot] Bump futureware-tech/simulator-action from 1 to 2 (#936) 7a238a9 2023-05-31 dependabot[bot] Bump actions/labeler from 4.0.2 to 4.0.4 (#952) 4c0eb48 2023-05-30 Brian Quinlan Prepare to publish cupertino_http 1.0.0 (#951) leak_tracker (https://github.com/dart-lang/leak_tracker/compare/7f2cab3..cbbdeca): cbbdeca 2023-05-31 Polina Cherkasova Improve getting retaining path. (#69) mockito (https://github.com/dart-lang/mockito/compare/40fe2ca..924f65c): 924f65c 2023-06-01 Ilya Yanok Add support for records native (https://github.com/dart-lang/native/compare/76bc55e..c851e69): c851e69 2023-06-01 dependabot[bot] Bump nttld/setup-ndk (#57) 0df0cad 2023-06-01 dependabot[bot] Bump actions/labeler from 4.0.3 to 4.0.4 (#58) c30faa2 2023-05-31 Daco Harkes [c_compiler] test install_name_tool behavior (#56) 45ef2e7 2023-05-31 Daco Harkes [c_compiler] Support setting the install name of dylibs (#55) protobuf (https://github.com/dart-lang/protobuf/compare/346a72d..da6953c): da6953c 2023-05-31 Kevin Moore Update to latest lints and Dart SDK (#828) pub_semver (https://github.com/dart-lang/pub_semver/compare/c034352..3930557): 3930557 2023-05-31 Kevin Moore Bump lints, require Dart 3.0 (#89) shelf (https://github.com/dart-lang/shelf/compare/a404b6a..ce379aa): ce379aa 2023-06-01 dependabot[bot] Bump actions/labeler from 4.0.3 to 4.0.4 (#363) stack_trace (https://github.com/dart-lang/stack_trace/compare/86f7e30..8b2046e): 8b2046e 2023-05-31 Devon Carew blast_repo fixes (#134) tools (https://github.com/dart-lang/tools/compare/d723a55..389925f): 389925f 2023-06-01 Elias Yishak Utility function added to check permissions on directory (#95) a436fee 2023-05-31 Elias Yishak Asserts added to check all relevant GA4 limitations (#96) vector_math (https://github.com/google/vector_math.dart/compare/cd87f57..a3aca09): a3aca09 2023-05-31 Lukas Klingsbo fix: Revert negation change for Vector2 (#296) webdev (https://github.com/dart-lang/webdev/compare/d442fa8..f565d7f): f565d7f1 2023-05-31 Anna Gringauze Disable flaky test on windows (#2127) 6eed300e 2023-05-31 Anna Gringauze Cleanup expression evalaluation tests (#2125) Change-Id: Ia568db23bbc923f764cdf323e249175b609d57ee Tested: affected files are regenerated test goldens Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306903 Reviewed-by: Konstantin Shcheglov <[email protected]> Auto-Submit: Devon Carew <[email protected]> Commit-Queue: Devon Carew <[email protected]>
This issue was originally filed by [email protected]
What steps will reproduce the problem?
interface Foo{
myFunction(int argA, [int argB]);
}
class Bar implements Foo{
//static warning here:
//"cannot override default method 'myFunction', default value doesn't match 'null'"
myFunction(int argA, [int argB = 0]){ ... }
}
What is the expected output? What do you see instead?
I think this should not warn. Setting default value of optional args in the interface is not allowed.
The text was updated successfully, but these errors were encountered: