Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1360)

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1624853002: Store the result of type inference in summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index 32b74a81b69d0ec7c66956b3d9dd2195303b5d3d..71c1db5d585b0c7e12959e001d5b8ffe192740a6 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -46,6 +46,12 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
final TypeProvider typeProvider;
/**
+ * Indicates whether the summary should be resynthesized assuming strong mode
+ * semantics.
+ */
+ final bool strongMode;
+
+ /**
* Map of top level elements resynthesized from summaries. The three map
* keys are the first three elements of the element's location (the library
* URI, the compilation unit URI, and the name of the top level declaration).
@@ -61,7 +67,7 @@ abstract class SummaryResynthesizer extends ElementResynthesizer {
<String, LibraryElement>{};
SummaryResynthesizer(this.parent, AnalysisContext context, this.typeProvider,
- this.sourceFactory)
+ this.sourceFactory, this.strongMode)
: super(context);
/**
@@ -516,7 +522,8 @@ class _LibraryResynthesizer {
executableElement.static = serializedExecutable.isStatic;
executableElement.abstract = serializedExecutable.isAbstract;
}
- buildExecutableCommonParts(executableElement, serializedExecutable);
+ buildExecutableCommonParts(executableElement, serializedExecutable,
+ isSetter: kind == UnlinkedExecutableKind.setter);
DartType type;
if (kind == UnlinkedExecutableKind.getter) {
executableElement.getter = true;
@@ -559,7 +566,8 @@ class _LibraryResynthesizer {
* functions, methods, getters, and setters.
*/
void buildExecutableCommonParts(ExecutableElementImpl executableElement,
- UnlinkedExecutable serializedExecutable) {
+ UnlinkedExecutable serializedExecutable,
+ {bool isSetter: false}) {
scheglov 2016/01/23 18:00:54 Why not use `serializedExecutable.kind == Unlinked
Paul Berry 2016/01/25 12:59:41 Done.
List<TypeParameterType> oldTypeArguments = currentTypeArguments;
int oldTypeParametersLength = currentTypeParameters.length;
if (serializedExecutable.typeParameters.isNotEmpty) {
@@ -573,7 +581,10 @@ class _LibraryResynthesizer {
// Caller handles setting the return type.
assert(serializedExecutable.returnType == null);
} else {
- executableElement.returnType = buildType(serializedExecutable.returnType);
+ executableElement.returnType =
+ buildLinkedType(serializedExecutable.inferredReturnTypeSlot) ??
+ buildType(serializedExecutable.returnType,
+ defaultVoid: isSetter && summaryResynthesizer.strongMode);
executableElement.hasImplicitReturnType =
serializedExecutable.returnType == null;
}
@@ -915,7 +926,9 @@ class _LibraryResynthesizer {
parameterElement.type = fields[serializedParameter.name]?.type ??
summaryResynthesizer.typeProvider.dynamicType;
} else {
- parameterElement.type = buildType(serializedParameter.type);
+ parameterElement.type =
+ buildLinkedType(serializedParameter.inferredTypeSlot) ??
+ buildType(serializedParameter.type);
}
parameterElement.hasImplicitType = serializedParameter.type == null;
}
@@ -957,9 +970,13 @@ class _LibraryResynthesizer {
* deserialized, so handles are used to avoid having to deserialize other
* libraries in the process.
*/
- DartType buildType(EntityRef type) {
+ DartType buildType(EntityRef type, {bool defaultVoid: false}) {
if (type == null) {
- return summaryResynthesizer.typeProvider.dynamicType;
+ if (defaultVoid) {
+ return VoidTypeImpl.instance;
+ } else {
+ return summaryResynthesizer.typeProvider.dynamicType;
+ }
}
if (type.paramReference != 0) {
// TODO(paulberry): make this work for generic methods.
@@ -1112,7 +1129,8 @@ class _LibraryResynthesizer {
*/
void buildVariableCommonParts(PropertyInducingElementImpl element,
UnlinkedVariable serializedVariable) {
- element.type = buildType(serializedVariable.type);
+ element.type = buildLinkedType(serializedVariable.inferredTypeSlot) ??
+ buildType(serializedVariable.type);
element.const3 = serializedVariable.isConst;
element.final2 = serializedVariable.isFinal;
element.hasImplicitType = serializedVariable.type == null;
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698