dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.25k stars 1.58k forks source link

Analyzer crashes on for element with NNBD #39380

Closed munificent closed 5 years ago

munificent commented 5 years ago

If I run:

$ dartanalyzer tests/language_2/control_flow_collections/

It completes successfully and prints lots of stuff. If I run:

$ dartanalyzer --enable-experiment=non-nullable tests/language_2/control_flow_collections/

It instead dies with:

Analyzing tests/language_2/control_flow_collections...
Unhandled exception:
NoSuchMethodError: The getter 'declaredElement' was called on null.
Receiver: null
Tried calling: declaredElement
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      ResolverVisitor.visitForElementInScope (package:analyzer/src/generated/resolver.dart:3543:30)
#2      ScopedVisitor.visitForElement (package:analyzer/src/generated/resolver.dart:5149:7)
#3      ForElementImpl.accept (package:analyzer/src/dart/ast/ast.dart:4283:49)
#4      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7511:20)
#5      ListLiteralImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:6666:15)
#6      ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:3969:10)
#7      UnifyingAstVisitor.visitListLiteral (package:analyzer/dart/ast/visitor.dart:3330:43)
#8      ResolverVisitor.visitListLiteral (package:analyzer/src/generated/resolver.dart:3886:11)
#9      ListLiteralImpl.accept (package:analyzer/src/dart/ast/ast.dart:6661:49)
#10     ResolverVisitor.visitAssignmentExpression (package:analyzer/src/generated/resolver.dart:3028:12)
#11     AssignmentExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:727:49)
#12     ExpressionStatementImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3666:18)
#13     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:3969:10)
#14     UnifyingAstVisitor.visitExpressionStatement (package:analyzer/dart/ast/visitor.dart:3214:59)
#15     ExpressionStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:3662:49)
#16     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7511:20)
#17     BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1087:17)
#18     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:3969:10)
#19     UnifyingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:3128:31)
#20     ScopedVisitor.visitBlock (package:analyzer/src/generated/resolver.dart:4899:13)
#21     BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1083:49)
#22     BlockFunctionBodyImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1042:13)
#23     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:3969:10)
#24     UnifyingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:3131:55)
#25     ScopedVisitor.visitBlockFunctionBody (package:analyzer/src/generated/resolver.dart:4910:13)
#26     ResolverVisitor.visitBlockFunctionBody (package:analyzer/src/generated/resolver.dart:3142:13)
#27     BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1038:49)
#28     MethodDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:6947:12)
#29     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:3969:10)
#30     UnifyingAstVisitor.visitMethodDeclaration (package:analyzer/dart/ast/visitor.dart:3336:55)
#31     ScopedVisitor.visitMethodDeclarationInScope (package:analyzer/src/generated/resolver.dart:5396:11)
#32     ResolverVisitor.visitMethodDeclarationInScope (package:analyzer/src/generated/resolver.dart:3912:11)
#33     ScopedVisitor.visitMethodDeclaration (package:analyzer/src/generated/resolver.dart:5389:7)
#34     ResolverVisitor.visitMethodDeclaration (package:analyzer/src/generated/resolver.dart:3901:13)
#35     MethodDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:6938:49)
#36     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7511:20)
#37     ScopedVisitor.visitClassMembersInScope (package:analyzer/src/generated/resolver.dart:4977:18)
#38     ScopedVisitor.visitClassDeclaration (package:analyzer/src/generated/resolver.dart:4955:11)
#39     ResolverVisitor.visitClassDeclaration (package:analyzer/src/generated/resolver.dart:3185:13)
#40     ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1522:49)
#41     ResolverVisitor.visitCompilationUnit (package:analyzer/src/generated/resolver.dart:3227:23)
#42     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2091:49)
#43     LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:709:10)
#44     LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:154:7)
#45     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#46     LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:153:11)
#47     LibraryAnalyzer.analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:116:14)
#48     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#49     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:115:43)
#50     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1261:63)
#51     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#52     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1237:20)
#53     AnalysisDriver.getErrors (package:analyzer/src/dart/analysis/driver.dart:548:41)
<asynchronous suspension>
#54     AnalyzerImpl.prepareErrors (package:analyzer_cli/src/analyzer_impl.dart:129:58)
<asynchronous suspension>
#55     AnalyzerImpl._analyze (package:analyzer_cli/src/analyzer_impl.dart:168:11)
<asynchronous suspension>
#56     AnalyzerImpl.analyze (package:analyzer_cli/src/analyzer_impl.dart:105:18)
<asynchronous suspension>
#57     Driver._runAnalyzer (package:analyzer_cli/src/driver.dart:705:21)
#58     Driver._analyzeAllImpl (package:analyzer_cli/src/driver.dart:364:40)
<asynchronous suspension>
#59     Driver._analyzeAll (package:analyzer_cli/src/driver.dart:195:20)
<asynchronous suspension>
#60     Driver.start (package:analyzer_cli/src/driver.dart:156:38)
<asynchronous suspension>
#61     main (file:///Users/rnystrom/dev/dart/sdk/pkg/analyzer_cli/bin/analyzer.dart:18:17)
<asynchronous suspension>
#62     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:32)
#63     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

#0      AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1297:9)
#1      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#2      AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1237:20)
#3      AnalysisDriver.getErrors (package:analyzer/src/dart/analysis/driver.dart:548:41)
<asynchronous suspension>
#4      AnalyzerImpl.prepareErrors (package:analyzer_cli/src/analyzer_impl.dart:129:58)
<asynchronous suspension>
#5      AnalyzerImpl._analyze (package:analyzer_cli/src/analyzer_impl.dart:168:11)
<asynchronous suspension>
#6      AnalyzerImpl.analyze (package:analyzer_cli/src/analyzer_impl.dart:105:18)
<asynchronous suspension>
#7      Driver._runAnalyzer (package:analyzer_cli/src/driver.dart:705:21)
#8      Driver._analyzeAllImpl (package:analyzer_cli/src/driver.dart:364:40)
<asynchronous suspension>
#9      Driver._analyzeAll (package:analyzer_cli/src/driver.dart:195:20)
<asynchronous suspension>
#10     Driver.start (package:analyzer_cli/src/driver.dart:156:38)
<asynchronous suspension>
#11     main (file:///Users/rnystrom/dev/dart/sdk/pkg/analyzer_cli/bin/analyzer.dart:18:17)
<asynchronous suspension>
#12     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:32)
#13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
bwilkerson commented 5 years ago

@scheglov

scheglov commented 5 years ago

https://dart-review.googlesource.com/c/sdk/+/125065