Skip to content

Analyzer 5.3.0 crashing on Flutter stable #50643

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

Closed
domesticmouse opened this issue Dec 7, 2022 · 8 comments
Closed

Analyzer 5.3.0 crashing on Flutter stable #50643

domesticmouse opened this issue Dec 7, 2022 · 8 comments

Comments

@domesticmouse
Copy link
Member

$ dart run build_runner build
Building package executable... 
Failed to build build_runner:build_runner:
../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-5.3.0/lib/src/dart/ast/ast.dart:8153:48: Error: The method 'elementAtOrNull' isn't defined for the class 'NodeListImpl<TypeAnnotationImpl>'.
 - 'NodeListImpl' is from 'package:analyzer/src/dart/ast/ast.dart' ('../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-5.3.0/lib/src/dart/ast/ast.dart').
 - 'TypeAnnotationImpl' is from 'package:analyzer/src/dart/ast/ast.dart' ('../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-5.3.0/lib/src/dart/ast/ast.dart').
Try correcting the name to the name of an existing method, or defining a method named 'elementAtOrNull'.
    var elementType = typeArguments?.arguments.elementAtOrNull(0)?.typeOrThrow;
@ahmednfwela
Copy link

had to revert to 5.2.0 because of this, I am guessing this is due to #49928 ?

@nEdAy
Copy link

nEdAy commented Dec 7, 2022

Please revert to 5.2.0

@bwilkerson
Copy link
Member

@scheglov

@scheglov
Copy link
Contributor

scheglov commented Dec 7, 2022

See flutter/engine#38114

dart-archive/collection#217 that added elementAtOrNull landed 6 months ago, and was pulled into Dart SDK soon after. I would expect that 6 months should be enough to pull package:collection into Flutter. But if it is not, the solution is to restrict package:analyzer version.

@scheglov
Copy link
Contributor

scheglov commented Dec 7, 2022

Ah, I see. package:analyzer should require at least collection: ^1.17.0.
My bad. I will fix it.

@scheglov
Copy link
Contributor

scheglov commented Dec 7, 2022

I retracted analyzer 5.3.0 from Pub.
I guess you will need to do dart pub upgrade again, maybe removing .dart_tool/package_config.json.
This should get you analyzer 5.2.0 again.
I have never done this before, so if you know better, please advise other people here.

@scheglov
Copy link
Contributor

scheglov commented Dec 7, 2022

I updated https://dart-review.googlesource.com/c/sdk/+/274086 to re-publish analyzer 5.3.1 with correct collection: ^1.17.0. I probably will not publish it until tomorrow when more people in the office.

@domesticmouse
Copy link
Member Author

In my testing this is fixed. As my testing involves building up a project from scratch I'm unsure what is required to downgrade a project that has the retracted version. I'm hoping a flutter pub upgrade will do the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants