Run more resolvers during one-phase resolution.

In two-phase resolution these resolvers aren't needed, because the AST
is partially resolved in the process of reconstituting it from the
unlinked summary.  For one-phase resolution we are just starting from
the raw unresolved AST so we need to resolve it fully.

Change-Id: I0068be592c61b6653806fa86ec30910ac8833294
Reviewed-on: https://dart-review.googlesource.com/74662
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index 77c3f54..605ed50 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -385,21 +385,33 @@
 typedef UnlinkedUnit GetUnitCallback(String absoluteUri);
 
 /// Stub implementation of [AnalysisOptions] used during linking.
-class AnalysisOptionsForLink implements AnalysisOptions {
+class AnalysisOptionsForLink implements AnalysisOptionsImpl {
   final Linker _linker;
 
   AnalysisOptionsForLink(this._linker);
 
   @override
+  bool get declarationCasts => true;
+
+  @override
   bool get hint => false;
 
   @override
+  bool get implicitCasts => true;
+
+  @override
+  List<String> get nonnullableTypes => AnalysisOptionsImpl.NONNULLABLE_TYPES;
+
+  @override
   bool get previewDart2 => true;
 
   @override
   bool get strongMode => true;
 
   @override
+  bool get strongModeHints => false;
+
+  @override
   noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
 }
 
@@ -1999,6 +2011,9 @@
   AnalysisOptionsForLink get analysisOptions => _linker.analysisOptions;
 
   @override
+  TypeProvider get typeProvider => _linker.typeProvider;
+
+  @override
   TypeSystem get typeSystem => _linker.typeSystem;
 
   @override
@@ -2197,6 +2212,12 @@
 
   final ResolverVisitor _resolverVisitor;
 
+  final TypeResolverVisitor _typeResolverVisitor;
+
+  final VariableResolverVisitor _variableResolverVisitor;
+
+  final PartialResolverVisitor _partialResolverVisitor;
+
   final Linker _linker;
 
   FunctionElementForLink_Local _functionElement;
@@ -2209,17 +2230,29 @@
     var unlinkedExecutable = functionElement.serializedExecutable;
     UnlinkedExpr unlinkedConst = unlinkedExecutable.bodyExpr;
     var errorListener = AnalysisErrorListener.NULL_LISTENER;
+    var source = unit.source;
     var astRewriteVisitor = new AstRewriteVisitor(
-        linker.typeSystem, library, unit.source, typeProvider, errorListener);
+        linker.typeSystem, library, source, typeProvider, errorListener);
     // TODO(paulberry): Do we need to pass a nameScope to
     // resolverVisitor to get type variables to resolve properly?
     var resolverVisitor = new ResolverVisitor(
-        library, unit.source, typeProvider, errorListener,
+        library, source, typeProvider, errorListener,
         propagateTypes: false, reportConstEvaluationErrors: false);
+    var typeResolverVisitor =
+        new TypeResolverVisitor(library, source, typeProvider, errorListener);
+    LibraryScope libraryScope = new LibraryScope(library);
+    var variableResolverVisitor = new VariableResolverVisitor(
+        library, source, typeProvider, errorListener,
+        nameScope: libraryScope);
+    var partialResolverVisitor = new PartialResolverVisitor(
+        library, source, typeProvider, errorListener);
     return new ExprTypeComputer._(
         unit._unitResynthesizer,
         astRewriteVisitor,
         resolverVisitor,
+        typeResolverVisitor,
+        variableResolverVisitor,
+        partialResolverVisitor,
         linker,
         errorListener,
         functionElement,
@@ -2231,6 +2264,9 @@
       UnitResynthesizer unitResynthesizer,
       this._astRewriteVisitor,
       this._resolverVisitor,
+      this._typeResolverVisitor,
+      this._variableResolverVisitor,
+      this._partialResolverVisitor,
       this._linker,
       AnalysisErrorListener _errorListener,
       this._functionElement,
@@ -2266,6 +2302,11 @@
         astFactory.expressionFunctionBody(null, null, expression, null);
     expression.accept(_astRewriteVisitor);
     expression = container.expression;
+    if (_linker.getAst != null) {
+      expression.accept(_typeResolverVisitor);
+      expression.accept(_variableResolverVisitor);
+      expression.accept(_partialResolverVisitor);
+    }
     expression.accept(_resolverVisitor);
     return expression.staticType;
   }
diff --git a/pkg/analyzer/test/src/summary/summarize_ast_one_phase_test.dart b/pkg/analyzer/test/src/summary/summarize_ast_one_phase_test.dart
index 280f5f4..9bd6dd6 100644
--- a/pkg/analyzer/test/src/summary/summarize_ast_one_phase_test.dart
+++ b/pkg/analyzer/test/src/summary/summarize_ast_one_phase_test.dart
@@ -48,30 +48,6 @@
 
   @override
   @failingTest
-  test_constExpr_makeTypedList() {
-    super.test_constExpr_makeTypedList();
-  }
-
-  @override
-  @failingTest
-  test_constExpr_makeTypedList_dynamic() {
-    super.test_constExpr_makeTypedList_dynamic();
-  }
-
-  @override
-  @failingTest
-  test_constExpr_makeTypedMap() {
-    super.test_constExpr_makeTypedMap();
-  }
-
-  @override
-  @failingTest
-  test_constExpr_makeTypedMap_dynamic() {
-    super.test_constExpr_makeTypedMap_dynamic();
-  }
-
-  @override
-  @failingTest
   test_field_final_typeParameter() {
     super.test_field_final_typeParameter();
   }
@@ -102,12 +78,6 @@
 
   @override
   @failingTest
-  test_inferred_type_keeps_leading_dynamic() {
-    super.test_inferred_type_keeps_leading_dynamic();
-  }
-
-  @override
-  @failingTest
   test_inferred_type_reference_shared_prefixed() {
     super.test_inferred_type_reference_shared_prefixed();
   }
@@ -132,8 +102,8 @@
 
   @override
   @failingTest
-  test_inferred_type_skips_trailing_dynamic() {
-    super.test_inferred_type_skips_trailing_dynamic();
+  test_inferred_type_undefined() {
+    super.test_inferred_type_undefined();
   }
 
   @override
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index 99fb334..d800094 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -7912,6 +7912,17 @@
         numTypeParameters: 1, numTypeArguments: 1);
   }
 
+  test_inferred_type_undefined() {
+    if (skipFullyLinkedData) {
+      return;
+    }
+    UnlinkedVariable v = serializeVariableText('var v = <Undefined>[];');
+    var typeRef = getTypeRefForSlot(v.inferredTypeSlot);
+    checkLinkedTypeRef(typeRef, 'dart:core', 'List',
+        numTypeArguments: 1, numTypeParameters: 1);
+    checkLinkedDynamicTypeRef(typeRef.typeArguments[0]);
+  }
+
   test_initializer_executable_with_bottom_return_type() {
     // The synthetic executable for `v` has type `() => Bottom`.
     UnlinkedVariable variable = serializeVariableText('int v = null;');