Fix summarization of unknown types.

Also fix a bug which was preventing type inference from being
performed on initializers that couldn't successfully be serialized to
the unlinked summary.

Change-Id: I270eaf6f1ff4140408353f24935c9eb60bfa9ee1
Reviewed-on: https://dart-review.googlesource.com/74671
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 27c379a..14966b9 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -160,7 +160,7 @@
     _storeTypeArguments(
         type.typeArguments, result, compilationUnit, typeParameterContext);
     return result;
-  } else if (type is DynamicTypeImpl) {
+  } else if (type.isDynamic) {
     result.reference = compilationUnit.addRawReference('dynamic');
     return result;
   } else if (type is VoidTypeImpl) {
@@ -4907,12 +4907,14 @@
 
   VariableElementForLink(this.unlinkedVariable, this.compilationUnit,
       this._initializerForInference) {
-    if (compilationUnit.isInBuildUnit &&
-        unlinkedVariable.initializer?.bodyExpr != null) {
+    if (!compilationUnit.isInBuildUnit) return;
+    if (unlinkedVariable.initializer?.bodyExpr == null) {
+      if (_initializerForInference == null) return;
+    } else {
       _constNode = new ConstVariableNode(this);
-      if (unlinkedVariable.type == null) {
-        _typeInferenceNode = initializer.asTypeInferenceNode;
-      }
+    }
+    if (unlinkedVariable.type == null) {
+      _typeInferenceNode = initializer.asTypeInferenceNode;
     }
   }
 
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 7b6f960..87e1d73 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
@@ -24,6 +24,12 @@
 
   @override
   @failingTest
+  test_constExpr_makeTypedList_functionType_withTypeParameters() {
+    super.test_constExpr_makeTypedList_functionType_withTypeParameters();
+  }
+
+  @override
+  @failingTest
   test_closure_executable_with_bottom_return_type() {
     super.test_closure_executable_with_bottom_return_type();
   }
@@ -48,36 +54,12 @@
 
   @override
   @failingTest
-  test_field_inferred_type_nonstatic_implicit_initialized() {
-    super.test_field_inferred_type_nonstatic_implicit_initialized();
-  }
-
-  @override
-  @failingTest
-  test_field_inferred_type_static_implicit_initialized() {
-    super.test_field_inferred_type_static_implicit_initialized();
-  }
-
-  @override
-  @failingTest
-  test_fully_linked_references_follow_other_references() {
-    super.test_fully_linked_references_follow_other_references();
-  }
-
-  @override
-  @failingTest
   test_implicit_dependencies_follow_other_dependencies() {
     super.test_implicit_dependencies_follow_other_dependencies();
   }
 
   @override
   @failingTest
-  test_inferred_type_reference_shared_prefixed() {
-    super.test_inferred_type_reference_shared_prefixed();
-  }
-
-  @override
-  @failingTest
   test_inferred_type_refers_to_function_typed_param_of_typedef() {
     super.test_inferred_type_refers_to_function_typed_param_of_typedef();
   }
@@ -96,12 +78,6 @@
 
   @override
   @failingTest
-  test_inferred_type_undefined() {
-    super.test_inferred_type_undefined();
-  }
-
-  @override
-  @failingTest
   test_initializer_executable_with_bottom_return_type() {
     super.test_initializer_executable_with_bottom_return_type();
   }
@@ -132,18 +108,6 @@
 
   @override
   @failingTest
-  test_linked_reference_reuse() {
-    super.test_linked_reference_reuse();
-  }
-
-  @override
-  @failingTest
-  test_linked_type_dependency_reuse() {
-    super.test_linked_type_dependency_reuse();
-  }
-
-  @override
-  @failingTest
   test_syntheticFunctionType_genericClosure() {
     super.test_syntheticFunctionType_genericClosure();
   }
@@ -156,19 +120,7 @@
 
   @override
   @failingTest
-  test_unused_type_parameter() {
-    super.test_unused_type_parameter();
-  }
-
-  @override
-  @failingTest
   test_variable_final_top_level_untyped() {
     super.test_variable_final_top_level_untyped();
   }
-
-  @override
-  @failingTest
-  test_variable_inferred_type_implicit_initialized() {
-    super.test_variable_inferred_type_implicit_initialized();
-  }
 }