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/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2750503015: Reland: [Fasta] Do not emit default arguments at callsite (Closed)
Patch Set: Created 3 years, 9 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/front_end/lib/src/fasta/kernel/kernel_library_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index d9156ba62a4e80570c76c460d085c0c8c5a2d14d..21e00f59580a008ed96a87404c6527c78fbffda0 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -1622,7 +1622,7 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
if (target is Constructor) {
typeParameters = target.enclosingClass.typeParameters;
}
- if (!addDefaultArguments(target.function, arguments, typeParameters)) {
+ if (!checkArguments(target.function, arguments, typeParameters)) {
return throwNoSuchMethodError(target.name.name, arguments, charOffset);
}
if (target is Constructor) {
@@ -1632,31 +1632,13 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
}
- bool addDefaultArguments(FunctionNode function, Arguments arguments,
+ bool checkArguments(FunctionNode function, Arguments arguments,
List<TypeParameter> typeParameters) {
- bool missingInitializers = false;
-
- Expression defaultArgumentFrom(Expression expression) {
- if (expression == null) {
- missingInitializers = true;
- return null;
- }
- cloner ??= new CloneVisitor();
- return cloner.clone(expression);
- }
if (arguments.positional.length < function.requiredParameterCount ||
arguments.positional.length > function.positionalParameters.length) {
return false;
}
- for (int i = arguments.positional.length;
- i < function.positionalParameters.length;
- i++) {
- var expression =
- defaultArgumentFrom(function.positionalParameters[i].initializer);
- expression?.parent = arguments;
- arguments.positional.add(expression);
- }
Map<String, VariableDeclaration> names;
if (function.namedParameters.isNotEmpty) {
names = <String, VariableDeclaration>{};
@@ -1673,14 +1655,6 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
}
}
- if (names != null) {
- for (String name in names.keys) {
- VariableDeclaration parameter = names[name];
- arguments.named.add(new NamedExpression(
- name, defaultArgumentFrom(parameter.initializer))
- ..parent = arguments);
- }
- }
if (typeParameters.length != arguments.types.length) {
arguments.types.clear();
for (int i = 0; i < typeParameters.length; i++) {
@@ -1688,9 +1662,6 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
}
- if (missingInitializers) {
- library.addArgumentsWithMissingDefaultValues(arguments, function);
- }
return true;
}
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698