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

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

Issue 1615073007: Add a test of summaries that uses strong mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix test failures 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 | « no previous file | pkg/analyzer/test/src/summary/summarize_elements_strong_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/summarize_elements.dart
diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart
index 288f5fd01c782b13042d53d74eb1c8bbc87ed312..6cb6dc6b71b87f7f5f3c961ebedbae41f2df4d98 100644
--- a/pkg/analyzer/lib/src/summary/summarize_elements.dart
+++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart
@@ -445,10 +445,18 @@ class _CompilationUnitSerializer {
UnlinkedExecutableBuilder b = new UnlinkedExecutableBuilder();
b.name = executableElement.name;
b.nameOffset = executableElement.nameOffset;
- if (executableElement is! ConstructorElement &&
- !executableElement.type.returnType.isVoid) {
- b.returnType = serializeTypeRef(
- executableElement.type.returnType, executableElement);
+ if (executableElement is! ConstructorElement) {
+ if (executableElement.hasImplicitReturnType) {
+ // In strong mode, the variable's static type may have been overwritten
+ // by an inferred type. In this part of the summary we want to store
+ // the weak mode static type (which is `dynamic`), since the strong
+ // mode static type is fully linked information.
+ b.returnType = serializeTypeRef(
+ librarySerializer.typeProvider.dynamicType, executableElement);
+ } else if (!executableElement.type.returnType.isVoid) {
+ b.returnType = serializeTypeRef(
+ executableElement.type.returnType, executableElement);
+ }
}
b.typeParameters =
executableElement.typeParameters.map(serializeTypeParam).toList();
@@ -699,7 +707,16 @@ class _CompilationUnitSerializer {
UnlinkedVariableBuilder b = new UnlinkedVariableBuilder();
b.name = variable.name;
b.nameOffset = variable.nameOffset;
- b.type = serializeTypeRef(variable.type, variable);
+ if (variable.hasImplicitType) {
+ // In strong mode, the variable's static type may have been overwritten
+ // by an inferred type. In this part of the summary we want to store the
+ // weak mode static type (which is `dynamic`), since the strong mode
+ // static type is fully linked information.
+ b.type = serializeTypeRef(
+ librarySerializer.typeProvider.dynamicType, variable);
+ } else {
+ b.type = serializeTypeRef(variable.type, variable);
+ }
b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
b.isFinal = variable.isFinal;
b.isConst = variable.isConst;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summarize_elements_strong_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698