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

Unified Diff: pkg/analyzer/test/src/summary/element_text.dart

Issue 2978353002: Resynthesize field formal parameters from Kernel. (Closed)
Patch Set: Use VariableDeclaration.isFieldFormal Created 3 years, 5 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/test/src/context/mock_sdk.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/element_text.dart
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 5cad3dace12e6fcb0fe7e14716c78c487eaf6b22..b6bbae25abeb2f9ad516726d4dbcec40cc4e1b89 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -600,9 +600,7 @@ class _ElementWriter {
void writeParameterElement(ParameterElement e) {
String defaultValueSeparator;
- Expression defaultValue = e is ConstVariableElement
- ? (e as ConstVariableElement).constantInitializer
- : null;
+ Expression defaultValue;
String closeString;
ParameterKind kind = e.parameterKind;
if (kind == ParameterKind.REQUIRED) {
@@ -610,15 +608,24 @@ class _ElementWriter {
} else if (kind == ParameterKind.POSITIONAL) {
buffer.write('[');
defaultValueSeparator = ' = ';
+ defaultValue = (e as ConstVariableElement).constantInitializer;
closeString = ']';
} else if (kind == ParameterKind.NAMED) {
buffer.write('{');
defaultValueSeparator = ': ';
+ defaultValue = (e as ConstVariableElement).constantInitializer;
closeString = '}';
} else {
fail('Unknown parameter kind: $kind');
}
+ // Kernel desugars omitted default parameter values to 'null'.
+ // Analyzer does not set initializer at all.
+ // It is not an interesting distinction, so we skip NullLiteral(s).
+ if (defaultValue is NullLiteral) {
+ defaultValue = null;
+ }
+
writeMetadata(e, '', ' ');
writeIf(e.isCovariant, 'covariant ');
« no previous file with comments | « pkg/analyzer/test/src/context/mock_sdk.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698