Skip to content
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] Implement FutureOr related rules of least upper bound #43720

Closed
eernstg opened this issue Oct 8, 2020 · 3 comments
Closed

[analyzer] Implement FutureOr related rules of least upper bound #43720

eernstg opened this issue Oct 8, 2020 · 3 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release

Comments

@eernstg
Copy link
Member

eernstg commented Oct 8, 2020

This is the analyzer specific issue for #43719, which has the details.

@eernstg eernstg added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release labels Oct 8, 2020
@scheglov scheglov self-assigned this Oct 8, 2020
@scheglov
Copy link
Contributor

scheglov commented Oct 8, 2020

The test below fails because UP(FutureOr<void>, dynamic) is dynamic. We apply UP(T1, T2) where TOP(T1) and TOP(T2) and MORETOP(FutureOr<void>, dynamic) is false, so the result is T2 which is dynamic.

  void f20(dynamic a, FutureOr<void> b) {
    var x = condition ? a : b;
    x.expectStaticType<Exactly<FutureOr<void>>>();
    if (x is Future) throw 0;
    /**/ x.toString();
    //   ^
    // [analyzer] COMPILE_TIME_ERROR.USE_OF_VOID_RESULT
    // [cfe] This expression has type 'void' and can't be used.

    var y = condition ? b : a;
    y.expectStaticType<Exactly<FutureOr<void>>>();
    if (y is Future) throw 0;
    /**/ y.toString();
    //   ^
    // [analyzer] COMPILE_TIME_ERROR.USE_OF_VOID_RESULT
    // [cfe] This expression has type 'void' and can't be used.
  }

@scheglov
Copy link
Contributor

scheglov commented Oct 8, 2020

dart-bot pushed a commit that referenced this issue Oct 9, 2020
Bug: #43720
Change-Id: I9decd3a3b430f82e3e4bd0c4e6963cd3069f9adf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166786
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
dart-bot pushed a commit that referenced this issue Oct 9, 2020
The tests least_upper_bound_{futureor,function}_test.dart are corrected:
The expected least upper bound was changed in one case in each test,
because the case matches a rule earlier in the ruleset, so the new rules
are not used in these cases.

Change-Id: I1f5f303ccde10af6084771a90d92d81d636909d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166635
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
@eernstg
Copy link
Member Author

eernstg commented Oct 9, 2020

@scheglov wrote:

.. the result is T2 which is dynamic.

Indeed, thanks for catching that! Fixed in a369992.

@scheglov scheglov closed this as completed Oct 9, 2020
kangwang1988 added a commit to XianyuTech/sdk that referenced this issue Oct 10, 2020
* 'master' of https://dart.googlesource.com/sdk: (293 commits)
  [co19] Instantiate to bound typedef static tests enabled
  Revert "Switch wasmer FFI boilerplate to new API"
  Remove remaining tests for bytecode mode
  Ensure that flow analysis sees the correct type of late-lowered local variables.
  [dart2js] Port deferred_loading_test to features.
  Update flow analysis properly when desugaring late local variables.
  Update package_config.json
  refactor AnalysisServer wrapper class
  Switch wasmer FFI boilerplate to new API
  Update dartdoc to head to help analyzer.
  Fix the issue with reusing LinkedElementFactory and supertype for Object.
  [vm/ffi] Fix alignment of Uint64 fields in structs on some ABIs
  Support latest analyzer in analyzer_plugin
  [cfe] Add tests for dart-lang#43716
  [infra] Update checked-in SDKs to 2.11.0-190.0.dev
  [cfe] Share override dependencies between getters and setters
  [cfe] Implement the update in UP for FutureOr types
  [co19] Roll co19 to 0d84277b464e91f09326292b2943381dfa6056ed
  [infra] Use Cq-Include-Trybots instead of git cl try for co19 rolls
  Corrections in lub tests, cf. dart-lang#43717, dart-lang#43720.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release
Projects
None yet
Development

No branches or pull requests

2 participants