Skip to content

Commit 06e6554

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[CFE] getFormal via Identifier (name and offset) and not just String (name)
Change-Id: I78059e627edaf8876eee74f878b36cfce990b78f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125265 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent edbff4e commit 06e6554

6 files changed

Lines changed: 16 additions & 8 deletions

File tree

pkg/front_end/lib/src/fasta/builder/function_builder.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:kernel/ast.dart';
1111

1212
import 'package:kernel/type_algebra.dart';
1313

14+
import '../identifiers.dart';
1415
import '../scope.dart';
1516

1617
import '../kernel/class_hierarchy_builder.dart' show ClassMember;
@@ -87,7 +88,7 @@ abstract class FunctionBuilder implements MemberBuilder {
8788
/// to support generic methods.
8889
Scope computeTypeParameterScope(Scope parent);
8990

90-
FormalParameterBuilder getFormal(String name);
91+
FormalParameterBuilder getFormal(Identifier identifier);
9192

9293
String get nativeMethodName;
9394

@@ -274,11 +275,16 @@ abstract class FunctionBuilderImpl extends MemberBuilderImpl
274275
}
275276

276277
@override
277-
FormalParameterBuilder getFormal(String name) {
278+
FormalParameterBuilder getFormal(Identifier identifier) {
278279
if (formals != null) {
279280
for (FormalParameterBuilder formal in formals) {
280-
if (formal.name == name) return formal;
281+
if (formal.name == identifier.name &&
282+
formal.charOffset == identifier.charOffset) {
283+
return formal;
284+
}
281285
}
286+
// If we have any formals we should find the one we're looking for.
287+
assert(false, "$identifier not found in $formals");
282288
}
283289
return null;
284290
}

pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3162,8 +3162,10 @@ class BodyBuilder extends ScopeListener<JumpTarget>
31623162
functionNestingLevel == 0 &&
31633163
memberKind != MemberKind.GeneralizedFunctionType) {
31643164
FunctionBuilder member = this.member;
3165-
parameter = member.getFormal(name.name);
3165+
parameter = member.getFormal(name);
31663166
if (parameter == null) {
3167+
// This happens when the list of formals (originally) contains a
3168+
// ParserRecovery - then the popped list becomes null.
31673169
push(new ParserRecovery(nameToken.charOffset));
31683170
return;
31693171
}

pkg/front_end/testcases/general/error_locations/error_location_05.dart.strong.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import self as self;
2020
import "dart:core" as core;
2121

2222
part error_location_05_lib1.dart;
23-
static method /* from org-dartlang-testcase:///error_location_05_lib1.dart */ x1(dynamic z = #C1, {dynamic z = #C1}) → dynamic {}
23+
static method /* from org-dartlang-testcase:///error_location_05_lib1.dart */ x1(dynamic z, {dynamic z = #C1}) → dynamic {}
2424
static method /* from org-dartlang-testcase:///error_location_05_lib1.dart */ x2() → dynamic {
2525
function y(dynamic z, {dynamic z = #C1}) → core::Null? {}
2626
}

pkg/front_end/testcases/general/error_locations/error_location_05.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import self as self;
2020
import "dart:core" as core;
2121

2222
part error_location_05_lib1.dart;
23-
static method /* from org-dartlang-testcase:///error_location_05_lib1.dart */ x1(dynamic z = #C1, {dynamic z = #C1}) → dynamic {}
23+
static method /* from org-dartlang-testcase:///error_location_05_lib1.dart */ x1(dynamic z, {dynamic z = #C1}) → dynamic {}
2424
static method /* from org-dartlang-testcase:///error_location_05_lib1.dart */ x2() → dynamic {
2525
function y(dynamic z, {dynamic z = #C1}) → core::Null? {}
2626
}

pkg/front_end/testcases/general/error_locations/error_location_06.dart.strong.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import self as self;
2020
import "dart:core" as core;
2121

2222
part error_location_06_lib1.dart;
23-
static method /* from org-dartlang-testcase:///error_location_06_lib1.dart */ x1(dynamic z = #C1, {dynamic z = #C1}) → dynamic {}
23+
static method /* from org-dartlang-testcase:///error_location_06_lib1.dart */ x1(dynamic z, {dynamic z = #C1}) → dynamic {}
2424
static method /* from org-dartlang-testcase:///error_location_06_lib1.dart */ x2() → dynamic {
2525
function y(dynamic z, {dynamic z = #C1}) → core::Null? {}
2626
}

pkg/front_end/testcases/general/error_locations/error_location_06.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import self as self;
2020
import "dart:core" as core;
2121

2222
part error_location_06_lib1.dart;
23-
static method /* from org-dartlang-testcase:///error_location_06_lib1.dart */ x1(dynamic z = #C1, {dynamic z = #C1}) → dynamic {}
23+
static method /* from org-dartlang-testcase:///error_location_06_lib1.dart */ x1(dynamic z, {dynamic z = #C1}) → dynamic {}
2424
static method /* from org-dartlang-testcase:///error_location_06_lib1.dart */ x2() → dynamic {
2525
function y(dynamic z, {dynamic z = #C1}) → core::Null? {}
2626
}

0 commit comments

Comments
 (0)