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 doesn't recognize upgrading language version for existing classes/extensions #40609

Closed
jakemac53 opened this issue Feb 12, 2020 · 3 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@jakemac53
Copy link
Contributor

jakemac53 commented Feb 12, 2020

The repro here is a bit weird, but you can do the following:

  1. Create a new package with the following pubspec.yaml file, and open it in vscode (probably works with anything using analysis server):
name: hello
environment:
  sdk: '>=2.0.0 <3.0.0'
  1. Run pub get (you must do this first).

  2. Create lib/dog.dart with these contents

class Dog {}

extension Bark on Dog {
  void bark() => print('woof');
}

This correctly shows an error - our min SDK does not support extension methods.

  1. Update sdk constraint in the pubspec to >=2.7.0 <3.0.0

The analyzer will still say that the experiment is not enabled.

I also tried re-running pub get (to update the packag_config.json language version), as well as reloading the window to restart the analyzer (ctrl+shift+p then search for reload window).

I can create new classes and use extensions, but any pre-existing extensions will complain no matter what I do, so it seems that the error is cached somewhere.

EDIT: it appears making any actual edit to the file will resolve the issue as well - but undoing that edit will get me back to the old error. So likely some cache by content hash of the file is not getting invalidated?

@jakemac53 jakemac53 added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Feb 12, 2020
@jakemac53
Copy link
Contributor Author

cc @scheglov @stereotype441

@scheglov
Copy link
Contributor

Coincidentally @kevmoo also ran into this issue.
https://dart-review.googlesource.com/c/sdk/+/135500 should fix it.

@scheglov scheglov self-assigned this Feb 12, 2020
@scheglov
Copy link
Contributor

The CL landed.

dart-bot pushed a commit that referenced this issue Feb 12, 2020
BUG=#40609

Change-Id: I4f333c802d1ba086354701aa41a75dadca8099a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
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.
Projects
None yet
Development

No branches or pull requests

2 participants