Skip to content

Commit

Permalink
Terminate null shorting for FunctionExpressionInvocation.
Browse files Browse the repository at this point in the history
FAILURE: (:s=0?.1(I
['package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart': Failed assertion: line 2785 pos 12: '_stack.isEmpty': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
flutter#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
flutter#2      _FlowAnalysisImpl.finish (package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart:2785:12)
flutter#3      FlowAnalysisHelper.topLevelDeclaration_exit (package:analyzer/src/dart/resolver/flow_analysis_visitor.dart:224:10)
flutter#4      AstResolver.resolve (package:analyzer/src/summary2/ast_resolver.dart:88:21)
#5      _VariableInferenceNode._resolveInitializer (package:analyzer/src/summary2/top_level_inference.dart:466:17)
flutter#6      _VariableInferenceNode.computeDependencies (package:analyzer/src/summary2/top_level_inference.dart:393:5)
flutter#7      Node.getDependencies (package:analyzer/src/summary/link.dart:148:40)
flutter#8      DependencyWalker.walk.strongConnect (package:analyzer/src/summary/link.dart:53:40)
flutter#9      DependencyWalker.walk (package:analyzer/src/summary/link.dart:119:18)
flutter#10     _InferenceWalker.walkNodes (package:analyzer/src/summary2/top_level_inference.dart:254:9)
flutter#11     _InitializerInference.perform (package:analyzer/src/summary2/top_level_inference.dart:287:13)
flutter#12     TopLevelInference.infer (package:analyzer/src/summary2/top_level_inference.dart:111:26)
flutter#13     Linker._performTopLevelInference (package:analyzer/src/summary2/link.dart:183:29)
flutter#14     Linker._buildOutlines (package:analyzer/src/summary2/link.dart:93:5)
flutter#15     Linker.link (package:analyzer/src/summary2/link.dart:76:5)
flutter#16     link (package:analyzer/src/summary2/link.dart:33:10)
flutter#17     LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:227:24)
flutter#18     LibraryContext.load2.<anonymous closure> (package:analyzer/src/dart/analysis/library_context.dart:258:17)
flutter#19     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
flutter#20     LibraryContext.load2 (package:analyzer/src/dart/analysis/library_context.dart:256:12)
#21     new LibraryContext (package:analyzer/src/dart/analysis/library_context.dart:78:5)
#22     AnalysisDriver._createLibraryContext.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1538:27)
#23     _rootRun (dart:async/zone.dart:1186:13)
#24     _CustomZone.run (dart:async/zone.dart:1090:19)
#25     _runZoned (dart:async/zone.dart:1626:10)
#26     runZoned (dart:async/zone.dart:1546:10)
#27     NullSafetyUnderstandingFlag.enableNullSafetyTypes (package:analyzer/dart/element/null_safety_understanding_flag.dart:42:12)
#28     AnalysisDriver._createLibraryContext (package:analyzer/src/dart/analysis/driver.dart:1536:33)
#29     AnalysisDriver._computeResolvedLibrary2.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1402:28)


Change-Id: I6b91c6bd89d6e0430a36ded992d8dca82bfedbff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175961
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
scheglov authored and [email protected] committed Dec 14, 2020
1 parent 4a93b79 commit 72b0d2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/analyzer/lib/src/generated/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@ class ResolverVisitor extends ScopedVisitor {
node.function?.accept(this);
_functionExpressionInvocationResolver
.resolve(node as FunctionExpressionInvocationImpl);
nullShortingTermination(node);
}

@override
Expand Down
8 changes: 8 additions & 0 deletions pkg/analyzer/test/generated/invalid_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ var v = <T>();
''');
}

test_functionExpressionInvocation_mustBeNullShortingTerminated() async {
// It looks like MethodInvocation, but because `8` is not SimpleIdentifier,
// we parse it as FunctionExpressionInvocation.
await _assertCanBeAnalyzed(r'''
var v = a?.8(b);
''');
}

test_inAnnotation_noFlow_labeledStatement() async {
await _assertCanBeAnalyzed('''
@A(() { label: })
Expand Down

0 comments on commit 72b0d2a

Please sign in to comment.