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 1.6.0 on Dart 2.13.0 fail to precompile: Getter not found: 'topLevelVariable'. Type 'dynamic' of the case expression is not a subtype of type 'TargetKind' of this switch expression. #46142

Closed
artnavsegda opened this issue May 26, 2021 · 8 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@artnavsegda
Copy link

Dart SDK version: 2.13.0 (stable) (Wed May 12 12:45:49 2021 +0200) on "macos_x64"

Failed to precompile build_runner:build_runner:
/opt/homebrew/Caskroom/flutter/2.2.0/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:1600:40: Error: Getter not found: 'topLevelVariable'.
return kinds.contains(TargetKind.topLevelVariable);
^^^^^^^^^^^^^^^^
/opt/homebrew/Caskroom/flutter/2.2.0/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Getter not found: 'topLevelVariable'.
case TargetKind.topLevelVariable:
^^^^^^^^^^^^^^^^
/opt/homebrew/Caskroom/flutter/2.2.0/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Type 'dynamic' of the case expression is not a subtype of type 'TargetKind' of this switch expression.

  • 'TargetKind' is from 'package:meta/meta_meta.dart' ('/opt/homebrew/Caskroom/flutter/2.2.0/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/meta_meta.dart').
    case TargetKind.topLevelVariable:
    ^
    /opt/homebrew/Caskroom/flutter/2.2.0/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2001:13: Context: The switch expression is here.
    switch (this) {
    ^
    pub finished with exit code 1
@arnoutvandervorst
Copy link

arnoutvandervorst commented May 26, 2021

Same, started happening after upgrading to build_runner 2.0.4 and analyzer 1.6.0

Forcing to use analyzer 1.5.0 seems to work.

@kluverua
Copy link

*for forced use of a specific version of the analyzer, you can add this block to pubspec.yaml

dependency_overrides:
  analyzer: '1.5.0'

@vsmenon vsmenon added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 26, 2021
@vsmenon
Copy link
Member

vsmenon commented May 26, 2021

@pq - perhaps a versioning issue with your recent change - https://dart-review.googlesource.com/c/sdk/+/200900 ?

@pq
Copy link
Member

pq commented May 26, 2021

@vsmenon: quite right. 1.6.0 has a dependency on a change to a newer package:meta. I was out yesterday but it looks like there was a scramble to address this by @scheglov, @jcollins-g, @bwilkerson and others and I believe we're out of the woods with analyzer 1.7.0. There's also been some conversation about what we can do to harden the CI/release process to avoid this kind of issue in the future. Not sure there's resolution yet. (If there are open issues, maybe someone could link here?)

/fyi @devoncarew

Sorry for the inconvenience @artnavsegda !

@flutterfromscratch
Copy link

flutterfromscratch commented May 26, 2021

Just FYI, this breaks usage of build_runner with packages like hive. I expect that this will break a lot of people's development setup and I wasted hours on this today trying to solve it before finding this issue.

In my case, I'm using Flutter 2.2, on the "stable" branch. Clearly when my install can be nerfed by a very distant change in the meta package, then something is very wrong.

EDIT: Should this not be higher priority? It's causing build_runner to break for people who would have no idea about this issue, for users' who have a stable install of Flutter.

@jcollins-g
Copy link
Contributor

@flutterfromscratch Eeeep. pubspec.yaml in Flutter pins meta to a specific version (1.3.0), forcing any package that uses Flutter and analyzer (even indirectly, e.g. through package test or build_runner) to prefer analyzer 1.6.0.

Reopened #46136 and closing this as duplicate.

@devoncarew
Copy link
Member

cc @jakemac53 as I know he's thought about flutter package pinning and the implications. I hadn't realized that it means that a flutter stable release (pinning meta) will effectively also pin the analyzer version, and transitively all build related packages.

@jakemac53
Copy link
Contributor

Oh right 🤕 ... ya this is very problematic for this case in particular. Flutter users can override meta to the latest but that isn't a good solution.

ramsestom pushed a commit to ramsestom/floor that referenced this issue Jun 4, 2021
regenvanwalbeek-wf added a commit to Workiva/dart_dev that referenced this issue Jul 14, 2022
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

9 participants