Commit Graph

3034 Commits

Author SHA1 Message Date
Paul Berry 5780cacbdb Don't pass null to fasta.Parser.
Fixes null safety errors arising from the migration of _fe_analyzer_shared.

Change-Id: I7da6b7f2d7c23d5d8f6ed120e03aed754aff5b82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176061
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
2020-12-14 15:55:39 +00:00
Konstantin Shcheglov 72b0d2a297 Terminate null shorting for FunctionExpressionInvocation.
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)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2      _FlowAnalysisImpl.finish (package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart:2785:12)
#3      FlowAnalysisHelper.topLevelDeclaration_exit (package:analyzer/src/dart/resolver/flow_analysis_visitor.dart:224:10)
#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)
#6      _VariableInferenceNode.computeDependencies (package:analyzer/src/summary2/top_level_inference.dart:393:5)
#7      Node.getDependencies (package:analyzer/src/summary/link.dart:148:40)
#8      DependencyWalker.walk.strongConnect (package:analyzer/src/summary/link.dart:53:40)
#9      DependencyWalker.walk (package:analyzer/src/summary/link.dart:119:18)
#10     _InferenceWalker.walkNodes (package:analyzer/src/summary2/top_level_inference.dart:254:9)
#11     _InitializerInference.perform (package:analyzer/src/summary2/top_level_inference.dart:287:13)
#12     TopLevelInference.infer (package:analyzer/src/summary2/top_level_inference.dart:111:26)
#13     Linker._performTopLevelInference (package:analyzer/src/summary2/link.dart:183:29)
#14     Linker._buildOutlines (package:analyzer/src/summary2/link.dart:93:5)
#15     Linker.link (package:analyzer/src/summary2/link.dart:76:5)
#16     link (package:analyzer/src/summary2/link.dart:33:10)
#17     LibraryContext.load2.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:227:24)
#18     LibraryContext.load2.<anonymous closure> (package:analyzer/src/dart/analysis/library_context.dart:258:17)
#19     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
#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 <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-14 08:56:08 +00:00
Konstantin Shcheglov 57fa20a8a5 Fix crash for no flow in annotation.
FAILURE: class=class<@((){x:
[NoSuchMethodError: The method 'labeledStatement_begin' was called on null.
Receiver: null
Tried calling: labeledStatement_begin(Instance of 'LabeledStatementImpl'), #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      FlowAnalysisHelper.labeledStatement_enter (package:analyzer/src/dart/resolver/flow_analysis_visitor.dart:196:10)
#2      ResolverVisitor.visitLabeledStatement (package:analyzer/src/generated/resolver.dart:1636:20)
#3      LabeledStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:6520:49)
#4      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
#5      BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1087:17)
#6      ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1749:10)
#7      UnifyingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:3143:31)
#8      ScopedVisitor.visitBlock.<anonymous closure> (package:analyzer/src/generated/resolver.dart:2473:13)
#9      ScopedVisitor._withDeclaredLocals (package:analyzer/src/generated/resolver.dart:3067:8)
#10     ScopedVisitor.visitBlock (package:analyzer/src/generated/resolver.dart:2472:5)
#11     BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1083:49)
#12     BlockFunctionBodyImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1042:13)
#13     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1749:10)
#14     UnifyingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:3146:55)
#15     ScopedVisitor.visitBlockFunctionBody (package:analyzer/src/generated/resolver.dart:2482:13)
#16     ResolverVisitor.visitBlockFunctionBody (package:analyzer/src/generated/resolver.dart:957:13)
#17     BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1038:49)
#18     FunctionExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:5010:12)
#19     FunctionExpressionResolver.resolve (package:analyzer/src/dart/resolver/function_expression_resolver.dart:65:10)
#20     ResolverVisitor.visitFunctionExpression (package:analyzer/src/generated/resolver.dart:1460:37)
#21     FunctionExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:5004:49)
#22     ResolverVisitor.visitArgumentList (package:analyzer/src/generated/resolver.dart:887:20)
#23     ArgumentListImpl.accept (package:analyzer/src/dart/ast/ast.dart:355:49)
#24     AnnotationResolver.resolve (package:analyzer/src/dart/resolver/annotation_resolver.dart:35:21)
#25     ResolverVisitor.visitAnnotation (package:analyzer/src/generated/resolver.dart:823:30)
#26     AnnotationImpl.accept (package:analyzer/src/dart/ast/ast.dart:280:49)
#27     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
#28     AnnotatedNodeImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:148:17)
#29     TypeParameterImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10298:11)
#30     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1749:10)
#31     UnifyingAstVisitor.visitTypeParameter (package:analyzer/dart/ast/visitor.dart:3475:47)
#32     TypeParameterImpl.accept (package:analyzer/src/dart/ast/ast.dart:10294:49)
#33     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
#34     TypeParameterListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10346:21)
#35     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1749:10)
#36     UnifyingAstVisitor.visitTypeParameterList (package:analyzer/dart/ast/visitor.dart:3478:55)
#37     TypeParameterListImpl.accept (package:analyzer/src/dart/ast/ast.dart:10342:49)
#38     ScopedVisitor.visitClassDeclarationInScope (package:analyzer/src/generated/resolver.dart:2533:26)
#39     ScopedVisitor.visitClassDeclaration (package:analyzer/src/generated/resolver.dart:2521:7)
#40     ResolverVisitor.visitClassDeclaration (package:analyzer/src/generated/resolver.dart:1015:13)
#41     ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1536:49)
#42     ResolverVisitor.visitCompilationUnit (package:analyzer/src/generated/resolver.dart:1091:23)
#43     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
#44     LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:706:10)
#45     LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:139:7)

Change-Id: I13a10d2c127528aa9166e82a5ae535ddbbb8a022
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175943
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-14 05:58:23 +00:00
Konstantin Shcheglov b21913b0a3 Fix for NPE when no flow for 'if' statement.
FAILURE: typedef:(:<>(s{if
[NoSuchMethodError: The method 'ifStatement_thenBegin' was called on null.
Receiver: null
Tried calling: ifStatement_thenBegin(Instance of 'SimpleIdentifierImpl'), #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      ResolverVisitor.visitIfStatement (package:analyzer/src/generated/resolver.dart:1556:26)
#2      IfStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:5705:49)
#3      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
#4      BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1087:17)
#5      ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1743:10)
#6      UnifyingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:3143:31)
#7      ScopedVisitor.visitBlock.<anonymous closure> (package:analyzer/src/generated/resolver.dart:2467:13)
#8      ScopedVisitor._withDeclaredLocals (package:analyzer/src/generated/resolver.dart:3061:8)
#9      ScopedVisitor.visitBlock (package:analyzer/src/generated/resolver.dart:2466:5)
#10     BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1083:49)
#11     BlockFunctionBodyImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1042:13)
#12     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1743:10)
#13     UnifyingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:3146:55)
#14     ScopedVisitor.visitBlockFunctionBody (package:analyzer/src/generated/resolver.dart:2476:13)
#15     ResolverVisitor.visitBlockFunctionBody (package:analyzer/src/generated/resolver.dart:954:13)
#16     BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1038:49)
#17     FunctionExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:5010:12)
#18     FunctionExpressionResolver.resolve (package:analyzer/src/dart/resolver/function_expression_resolver.dart:65:10)
#19     ResolverVisitor.visitFunctionExpression (package:analyzer/src/generated/resolver.dart:1457:37)
#20     FunctionExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:5004:49)
#21     DefaultFormalParameterImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3008:20)
#22     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1743:10)
#23     UnifyingAstVisitor.visitDefaultFormalParameter (package:analyzer/dart/ast/visitor.dart:3198:65)
#24     ResolverVisitor.visitDefaultFormalParameter (package:analyzer/src/generated/resolver.dart:1239:11)
#25     DefaultFormalParameterImpl.accept (package:analyzer/src/dart/ast/ast.dart:3003:15)
#26     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
#27     FormalParameterListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:4493:17)
#28     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1743:10)
#29     UnifyingAstVisitor.visitFormalParameterList (package:analyzer/dart/ast/visitor.dart:3258:59)
#30     ScopedVisitor.visitFormalParameterList (package:analyzer/src/generated/resolver.dart:2717:11)
#31     FormalParameterListImpl.accept (package:analyzer/src/dart/ast/ast.dart:4489:49)
#32     FunctionTypeAliasImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:5166:18)
#33     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1743:10)
#34     UnifyingAstVisitor.visitFunctionTypeAlias (package:analyzer/dart/ast/visitor.dart:3285:55)
#35     ScopedVisitor.visitFunctionTypeAliasInScope (package:analyzer/src/generated/resolver.dart:2819:11)
#36     ResolverVisitor.visitFunctionTypeAliasInScope (package:analyzer/src/generated/resolver.dart:1490:11)
#37     ScopedVisitor.visitFunctionTypeAlias (package:analyzer/src/generated/resolver.dart:2812:7)
#38     ResolverVisitor.visitFunctionTypeAlias (package:analyzer/src/generated/resolver.dart:1482:13)
#39     FunctionTypeAliasImpl.accept (package:analyzer/src/dart/ast/ast.dart:5158:49)
#40     ResolverVisitor.visitCompilationUnit (package:analyzer/src/generated/resolver.dart:1088:23)
#41     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
#42     LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:706:10)


R=brianwilkerson@google.com

Change-Id: I72bf7219d55d0bf53beae11f977f8fb840dd8e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175908
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-12 18:19:41 +00:00
Konstantin Shcheglov 3c2e851780 Fix for crash when function expression has empty body.
FAILURE: _(:<>(o;?(a(@([
[NoSuchMethodError: The getter 'contextType' was called on null.
Receiver: null
Tried calling: contextType, #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      FunctionExpressionResolver.resolve (package:analyzer/src/dart/resolver/function_expression_resolver.dart:72:35)
#2      ResolverVisitor.visitFunctionExpression (package:analyzer/src/generated/resolver.dart:1424:37)
#3      FunctionExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:5004:49)
#4      ResolverVisitor.visitConditionalExpression (package:analyzer/src/generated/resolver.dart:1068:16)
#5      ConditionalExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:2265:15)
#6      DefaultFormalParameterImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3008:20)
#7      ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1710:10)
#8      UnifyingAstVisitor.visitDefaultFormalParameter (package:analyzer/dart/ast/visitor.dart:3198:65)
#9      ResolverVisitor.visitDefaultFormalParameter (package:analyzer/src/generated/resolver.dart:1206:11)
#10     DefaultFormalParameterImpl.accept (package:analyzer/src/dart/ast/ast.dart:3003:15)
#11     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
#12     FormalParameterListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:4493:17)
#13     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1710:10)
#14     UnifyingAstVisitor.visitFormalParameterList (package:analyzer/dart/ast/visitor.dart:3258:59)
#15     ScopedVisitor.visitFormalParameterList (package:analyzer/src/generated/resolver.dart:2684:11)
#16     FormalParameterListImpl.accept (package:analyzer/src/dart/ast/ast.dart:4489:49)
#17     FunctionExpressionImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:5009:18)
#18     FunctionExpressionResolver.resolve (package:analyzer/src/dart/resolver/function_expression_resolver.dart:65:10)
#19     ResolverVisitor.visitFunctionExpression (package:analyzer/src/generated/resolver.dart:1415:35)
#20     FunctionExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:5004:49)
#21     FunctionDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:4873:26)
#22     ResolverVisitor.visitNode (package:analyzer/src/generated/resolver.dart:1710:10)
#23     UnifyingAstVisitor.visitFunctionDeclaration (package:analyzer/dart/ast/visitor.dart:3271:59)
#24     ScopedVisitor.visitFunctionDeclarationInScope (package:analyzer/src/generated/resolver.dart:2749:11)
#25     ResolverVisitor.visitFunctionDeclarationInScope (package:analyzer/src/generated/resolver.dart:1405:11)
#26     ScopedVisitor.visitFunctionDeclaration (package:analyzer/src/generated/resolver.dart:2742:7)
#27     ResolverVisitor.visitFunctionDeclaration (package:analyzer/src/generated/resolver.dart:1374:11)
#28     FunctionDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:4866:49)
#29     ResolverVisitor.visitCompilationUnit (package:analyzer/src/generated/resolver.dart:1055:23)
#30     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
#31     LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:706:10)


Change-Id: I62cde978d075bbafacb1b429e87049ca5d54d268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175907
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-12 17:13:15 +00:00
Sam Rawlins 17b7d05e72 Analyzer: prepare for null safety in tests: casts and late variables
Change-Id: I37f3663b340952b79cef0e423caf81e5950b700b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175841
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-11 19:50:39 +00:00
Sam Rawlins 69cb9f7a67 Analyzer: Remove legacy parser (replaced by Fasta).
* Replace most of the implementation of Parser with the implementation
  found in _Parser2, which uses Fasta.
* Rework Parser constructor to do exactly what the previous factory
  constructor + _Parser2 constructor did.
* Remove _Parser2 and ParserAdapter.
* Remove `useFasta` argument in several places.
* Delete tests in parser_test.dart which only used the legacy parser.
* Move ParserProxy from parser_fasta_test.dart to parser_test.dart
* Remove ~240 cases of dead code like `if (useFasta)` and `useFasta ?`
  in tests.

Change-Id: Iea29a10ff83103293902336490fbc9cd46cd20ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175560
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-10 23:47:48 +00:00
Konstantin Shcheglov 1c864b1bc7 Fix for StackOverflow in FileState.library
Change-Id: I6dd9ceefbfa8d5f457d69ae20838290b8a208c98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175329
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-08 17:26:54 +00:00
Konstantin Shcheglov 8d01debeda For interactive use case in AnalysisDriver use separately stored ASTs for files.
Change-Id: I92ee458a6c143a3164c0b5a10adf42c4dbe4878d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175282
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-08 00:58:18 +00:00
Konstantin Shcheglov ded707e265 Update latestSdkLanguageVersion to '2.12'.
Change-Id: I4b06f02dfecf9e10bca7fb0b285527c80d76166e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175281
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-07 18:40:54 +00:00
Lasse R.H. Nielsen 6e29700e16 Update List constructor documentation, deprecate constructor.
Emphasize that the operation is going away,
and mark constructor as deprecated.

TEST= Refactoring+deprecation only, covered by existing tests.

Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-12-07 16:20:28 +00:00
Sam Rawlins 56cf16887c Analyzer: Don't report on prefixed import with illegal references
Bug: TODO from https://github.com/dart-lang/sdk/issues/38784
Change-Id: I4ecdaf333c2613eb5fa0c57e4a8f8be56c35bb21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175184
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-07 01:27:25 +00:00
Sam Rawlins e0ebe30190 analyzer: Improve unused_import analysis for shared prefix names
Fixes https://github.com/dart-lang/sdk/issues/38784

Change-Id: I42b32261e9ed71018967e228d2ec731a4613205d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147336
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-03 04:00:37 +00:00
Konstantin Shcheglov 19652ae5ad Use binary format for summaries.
Change-Id: Ibf0221a3c233c958e5065b64207faf9dfae33083
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168260
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-01 21:30:35 +00:00
Konstantin Shcheglov 6c6dba54bd Replace some uses of StaticTypeAnalyzer2TestShared.
R=brianwilkerson@google.com

Change-Id: Ic3ea45d3e894b3991593a2a349909bf289743e93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174489
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-01 06:50:14 +00:00
Konstantin Shcheglov 49ca82c4e8 Move literal inference tests from StaticTypeAnalyzer2Test.
R=brianwilkerson@google.com

Change-Id: Ie08a60dcd1a0942e5e72ae3a1ed4bb76238786db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-30 20:30:03 +00:00
Konstantin Shcheglov b200c9d68d Remove functionTypeAlias tests from FunctionTypeImplTest.
These tests were passing by a wrong reason.

It is not possible to express a recursive typedef anymore.
When we try to instantiate `G` in `typedef F = G Function()`, it
will instantiate `typdef G = F Function()` right now, directly into
the corresponding FunctionType, but because we are in the process
of setting the return type of `F` right now, `G` is not yet referenced
in `F`, so is not referened by `G` itself.

Such recursion is possible during linking, but then we break it.
We still report errors, and resolved AST still has necessary references.

Change-Id: I47b18f80b00edd01268c65c3e1786892ad0d5091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174381
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-30 19:37:23 +00:00
Devon Carew 2ba123b86e [analysis server] remove the --file-read-mode cli option for the analysis server
Change-Id: I279233cd0b7ec09a7d2fdcd50837552f56f2584d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171763
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-12 21:42:50 +00:00
Devon Carew e7647f2cf2 Revert "[analysis server] remove the --file-read-mode cli option for the analysis server"
This reverts commit 1caee4d1fd.

Reason for revert: This breaks google3 - we need to update the linter's use of the analyzer API.

Original change's description:
> [analysis server] remove the --file-read-mode cli option for the analysis server
>
> Change-Id: Id07e3655cb4bcfc462ada0db8257e7cf584272f5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171101
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Devon Carew <devoncarew@google.com>

TBR=devoncarew@google.com,scheglov@google.com,brianwilkerson@google.com

Change-Id: I68294ad8b565a94aa098e65276b78e9745eec5a5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171640
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-11 20:10:41 +00:00
Devon Carew 1caee4d1fd [analysis server] remove the --file-read-mode cli option for the analysis server
Change-Id: Id07e3655cb4bcfc462ada0db8257e7cf584272f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-11 19:30:23 +00:00
Sam Rawlins dc48399320 Analyzer: Introduce explicit casts required by null safety, in generated/
Change-Id: I7c7ad0abd906caf47fe9900b09b23e24b53cd4f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171441
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-11 17:33:53 +00:00
Sam Rawlins ae4e13a0a0 Analyzer: prepare for migration, mostly with explicit casts
Change-Id: Ic7565765d67a6b07c9028ad70f285cf0ed9de855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170802
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-08 18:13:47 +00:00
Sam Rawlins 594f0fd51d Analyzer: Delete unused class in source_factory_test
Change-Id: Ia46e3cec3addc18c69259587d5186f9ec078cbfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170761
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-06 22:40:13 +00:00
Sam Rawlins 466f2fd8a7 Analyzer: prepare some generated/ tests for null safety
Change-Id: Ieca714d8b32b7b283a8dc30dd820df07d1e64655
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170600
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-06 14:34:02 +00:00
Jens Johansen 5a6129406f [parser] Consistently disallow 'late' without 'var', 'final' or type
Fixes https://github.com/dart-lang/sdk/issues/43811
Fixes https://github.com/dart-lang/sdk/issues/43812
Fixes https://github.com/dart-lang/sdk/issues/43813

Change-Id: I39de527883d33459694ec0f91b769676eb52d54b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168641
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-23 06:28:51 +00:00
Konstantin Shcheglov a669f440a6 Revert applying resolution after loading AST for summaries.
Reason: causes Flutter analysis performance regression.
https://github.com/flutter/flutter/issues/68716

We will get back to applying resolution after loading AST when
we switch to the binary format, and so recover enough performance.

WIP for it: https://dart-review.googlesource.com/c/sdk/+/168260
Unfortunately this means that it will get even bigger.


Revert "Separate AST from resolution (per declaration)."

This reverts commit 4d6fba37de.


Revert "Remove commented out code from LinkedUnitContext."

This reverts commit c4f2c8ec3e.


Revert "Issue 43890. Implement applying resolution to IndexExpression."

This reverts commit 088524efa6.


Revert "Issue 43888. Fix for applying resolution to PropertyAccess in cascade."

This reverts commit 1f660a7acf.

Change-Id: I808c1fc62161458d7544d7741e4b358c99b0b55f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-22 22:40:40 +00:00
Konstantin Shcheglov 4d6fba37de Separate AST from resolution (per declaration).
Change-Id: Ic05781f98636e992c5c51d94cde51aa8c64663a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167242
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-10-16 16:33:42 +00:00
Konstantin Shcheglov aad1a677c0 Deprecate GenericTypeAliasElement
See also https://dart-review.googlesource.com/c/sdk/+/166680

Change-Id: I6018f3bf5796dcc8ab059aab5b29d01e7336581b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167727
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-15 16:03:26 +00:00
Konstantin Shcheglov fbfc723de7 Use CompoundAssignmentExpression instead of LHS element/type.
This adds some technical debt in form of using writeOrReadElement in
clients, which can be paid incrementally by migrating these places to
handling assignment like expressions one by one. Doing it all in one
CL was too much. But now the underlaying AST resolution will be
sound.

In the next breaking change we will remove
setAssignmentBackwardCompatibility(), so stop setting elements/types
for assignment targets.

Change-Id: I11626876cfed25653edb0cc18544aba51cef5965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165622
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-14 18:45:08 +00:00
Konstantin Shcheglov 0c342ae491 Fix crash when invalid default field formal parameter has annotation.
Change-Id: Iabb329f850195be981d80b0589d9f7851596c680
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-08 15:17:05 +00:00
Konstantin Shcheglov 31e673d80c Deprecate SimpleIdentifier.auxiliaryElements
Change-Id: Ie1e92cc61b7018d503cdf44c37611ea55b4b5391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164760
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-28 16:00:44 +00:00
Konstantin Shcheglov 7ec28c3f08 Enforce await_only_futures and fix violations.
R=brianwilkerson@google.com

Change-Id: Icfc093d46562ddc7084151e76f495cc1462bb900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164257
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-24 14:28:00 +00:00
Konstantin Shcheglov 9b7c0ebd82 Extract SimpleIdentifierResolver.
The improvement is that we use PropertyElementResolver and stopped
using setReadElement() and setWriteElement().

The error reporting and type anlysis is moved as it were.

Change-Id: I808be8d0d52d4eece892be8234dd28c213dcb11c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164253
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-24 14:26:03 +00:00
Konstantin Shcheglov ac5c140f60 Extract PrefixedIdentifierResolver.
Element resolution is improved to use PropertyElementResolver.
And we don't call setReadElement() and setWriteElement() anymore.

Type analysis is kept as is for now.

Change-Id: If14a5b5690947f335e05a43f3f6166c0a228f9eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164245
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-23 21:47:59 +00:00
Konstantin Shcheglov e89279c85f Resolve IndexExpression and PropertyAcces as read only.
All writes are handled in corresponding assignment (-like) expressions.

Change-Id: Iab4220f7fce55daebd8aac1c90bf81efe3d7d8e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-22 21:59:31 +00:00
Konstantin Shcheglov 01154855d1 Make control-flow-collections, set-literals, spread-collections available since 2.0.0
See https://github.com/dart-lang/language/issues/286#issuecomment-503614115
and https://github.com/dart-lang/sdk/issues/43462

Change-Id: Ib8c37a2b5e3ce6c737e496bf285d946baf3a41d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-19 16:12:07 +00:00
Konstantin Shcheglov 5051d75bc6 Issue 43462. Compute constant values in libraries with contain them.
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/43462
Change-Id: I82200c06b1a77f634b7c7f30fd3ad7e10eb01ad4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-17 21:26:13 +00:00
Jens Johansen e6ffc0b285 [parser] Issue different warnings for missing identifier based on whether the token is used or not.
E.g. "var = 42;" now has a different error message than "var default = 42;".

Fixes #22553

Change-Id: I58affe988569d8e79190b63f7267b471a1b0ebc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162182
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-14 08:55:18 +00:00
Konstantin Shcheglov ec65869de7 Use assertNoErrorsInCode() instead of the empty list of errors where possible.
R=brianwilkerson@google.com

Change-Id: Iac17fe779fc44dec3319687d80fc97761e7332f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-11 20:22:53 +00:00
Jens Johansen b0acaea1e5 [parser] Recover written out binary operators
* Add mechanisms to try out a recovery and only perform it if is
  successful.
* Recover written out binary operators, e.g. "a xor b", "a or b" etc.
  This fixes #26810 and is also how these operators are written in e.g.
  Kotlin. This might be somewhat controversial though.
* Adds a mechanism to _replace_ a token by another token.
  This might be controversial.
  It is done because just inserting the operator causes the same rewrite
  to be attempted on the same token stream several times (at least with
  the way the token stream is parsed via the CFE) in turn causing it to
  be recovered *sometimes*. This is now avoided by actually replacing
  the token.

Change-Id: Icfa806045575d2aa2e5f35126708651b275bcf84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162003
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-10 06:23:33 +00:00
Mike Fairhurst 57a877a1a1 [analyzer] Remove dart:async imports from test cases
Change-Id: I804fd909e7c3363e78ecb90a954e17301fa77a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161470
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-09-02 23:45:12 +00:00
Mike Fairhurst 000f3135a5 [analyzer] Remove unused dart:async imports
Change-Id: If21c3a30f3bc521586ad01f8f9e241038e7aa7eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161448
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-09-02 17:14:22 +00:00
Konstantin Shcheglov d9b874c4b5 Resolve AssignmentExpression with SimpleIdentifier directly.
Change-Id: I81cc3d6b1cf31d840727300c0a22e8acfa5bf17c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-01 22:15:41 +00:00
Jens Johansen 3a1f732c0f [parser] Make begin/end events always come in pairs
This CL:
* Changes the events so beginX and endX events always comes in pairs
  (though technically not right as some specific events can be beginX
  endY --- but in those cases it is at least documented and used in code
  that actually tests it).
  -> This entails adding some events and converting something from
    "beginX" to "handleX" instead.
* Adds a utility that can generate an AST of sorts directly from the
  parser via a listener using the begin/end matching (and knowing of the
  specific ones that doesn't match directly).
* Adds a test that checks that - at least for all tested (50,000+) files
  - the AST actually generate "correctly", i.e. matches up begin/ends
  and ends up with a single top entry "CompilationUnit".
* Adds a different visualization to the parser listener events by
  displaying the "AST directly from the parser" in a UI that can be
  navigated. The visualization may not be the best, but it's certainly
  a stepping stone.

Change-Id: I9b27f7bbf3be442adc92f357c7b3c46da6f84cf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159664
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-01 09:30:43 +00:00
Konstantin Shcheglov 32ae7d9efc Switch tests for the new testing and remove ResolverTestCase.
R=brianwilkerson@google.com

Change-Id: I2bbf8a5194878389bca43d534bbf3bc116c5acbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-19 21:54:47 +00:00
Konstantin Shcheglov 2b7fc8f134 Update FeatureSet to the new rules.
Bug: https://github.com/dart-lang/sdk/issues/43032
Change-Id: I6c7d7dc56fd0d4edcc3c6f6cc6fb0422316b8f4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159187
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 18:27:37 +00:00
Konstantin Shcheglov a51f1747e0 Prepare to publish analyzer 0.40.0 and _fe_analyzer_shared 8.0.0.
Change-Id: I126207dcc47885565a3a6d7002ff15ad3cc493c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 15:12:10 +00:00
Jens Johansen 8bca93872a [parser] Better error message for annotations on type arguments
This CL changes the message given in the situation identified in
https://github.com/dart-lang/sdk/issues/22314

Fixes https://github.com/dart-lang/sdk/issues/22314

Change-Id: Ibd47dd419d52673ae0d9e32039e0a635c1e09543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158388
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-08-17 07:43:52 +00:00
Konstantin Shcheglov 302ad7ab2c Replace isNonNullableByDefaultInternal flag in LibraryElementImpl with FeatureSet.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I4fdb464df5f70ae93ccff5f06d8c99d34d3f8e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158500
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-13 17:27:04 +00:00
Paul Berry 33849927c9 External variable support: test that local variables and parameters can't be external.
Change-Id: Ib7b24b59ab7f14197f57d4b632c8462c40140c50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158372
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-13 16:11:34 +00:00