Skip to content

Commit 642b786

Browse files
authored
#1399. Object member names are not allowed for positional fields names (#1513)
Authored by @sgrekhov. Adjusting record tests. Object member names are not allowed for positional fields names. Missing parameters names added, run-time types fixed.
1 parent 7623458 commit 642b786

23 files changed

+323
-72
lines changed

LanguageFeatures/Records/record_type_annotations_A02_t01.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef ({required int i, String s}) R2();
5050
// [analyzer] unspecified
5151
// [cfe] unspecified
5252

53-
typedef void R3(({required int i, String s}));
53+
typedef void R3(({required int i, String s}) r);
5454
// ^^^^^^^^
5555
// [analyzer] unspecified
5656
// [cfe] unspecified
@@ -60,7 +60,7 @@ typedef void R3(({required int i, String s}));
6060
// [analyzer] unspecified
6161
// [cfe] unspecified
6262

63-
void bar(({required int i, String s})) {}
63+
void bar(({required int i, String s}) r) {}
6464
// ^^^^^^^^
6565
// [analyzer] unspecified
6666
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A02_t02.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef ([int? i, String? s]) R2();
5050
// [analyzer] unspecified
5151
// [cfe] unspecified
5252

53-
typedef void R3(([int? i, String? s]));
53+
typedef void R3(([int? i, String? s]) r);
5454
// ^
5555
// [analyzer] unspecified
5656
// [cfe] unspecified
@@ -60,7 +60,7 @@ typedef void R3(([int? i, String? s]));
6060
// [analyzer] unspecified
6161
// [cfe] unspecified
6262

63-
void bar(([int i, String s])) {}
63+
void bar(([int i, String s]) r) {}
6464
// ^
6565
// [analyzer] unspecified
6666
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A02_t10.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef ({int i, String s}, int j) R3();
5353
// [analyzer] unspecified
5454
// [cfe] unspecified
5555

56-
typedef void R4(({int i, String s}, int));
56+
typedef void R4(({int i, String s}, int) r);
5757
// ^
5858
// [analyzer] unspecified
5959
// [cfe] unspecified
@@ -63,7 +63,7 @@ typedef void R4(({int i, String s}, int));
6363
// [analyzer] unspecified
6464
// [cfe] unspecified
6565

66-
void bar(({int i, String s}, int j,)) {}
66+
void bar(({int i, String s}, int j,) r) {}
6767
// ^
6868
// [analyzer] unspecified
6969
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A02_t12.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ typedef void R5((int? i, {String? s})? r);
4646

4747
(int? i, {String? s})? foo() => null;
4848

49-
void bar((int? i, {String? s})?) {}
49+
void bar((int? i, {String? s})? r) {}
5050

5151
main() {
5252
(int? i, String? s)? r1 = null;

LanguageFeatures/Records/record_type_annotations_A02_t13.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef (var i,) R3();
5353
// [analyzer] unspecified
5454
// [cfe] unspecified
5555

56-
typedef void R5(({var s}));
56+
typedef void R5(({var s}) r);
5757
// ^^^
5858
// [analyzer] unspecified
5959
// [cfe] unspecified
@@ -63,7 +63,7 @@ typedef void R5(({var s}));
6363
// [analyzer] unspecified
6464
// [cfe] unspecified
6565

66-
void bar(({var s})) {}
66+
void bar(({var s}) r) {}
6767
// ^^^
6868
// [analyzer] unspecified
6969
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A03_t01.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef ({int i, String s, int i}) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3(({int i, String s, int i}));
41+
typedef void R3(({int i, String s, int i}) r);
4242
// ^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified
@@ -48,7 +48,7 @@ typedef void R3(({int i, String s, int i}));
4848
// [analyzer] unspecified
4949
// [cfe] unspecified
5050

51-
void bar(({int i, String s, String i})) {}
51+
void bar(({int i, String s, String i}) r) {}
5252
// ^
5353
// [analyzer] unspecified
5454
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A03_t02.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ typedef (int i, int i, {String s}) R4();
4848
// [analyzer] unspecified
4949
// [cfe] unspecified
5050

51-
typedef void R5((int i, {String s, int i}));
51+
typedef void R5((int i, {String s, int i}) r);
5252
// ^
5353
// [analyzer] unspecified
5454
// [cfe] unspecified
5555

56-
typedef void R6((int i, int i, {String s}));
56+
typedef void R6((int i, int i, {String s}) r);
5757
// ^
5858
// [analyzer] unspecified
5959
// [cfe] unspecified
@@ -68,12 +68,12 @@ typedef void R6((int i, int i, {String s}));
6868
// [analyzer] unspecified
6969
// [cfe] unspecified
7070

71-
void bar1((int i, {String s, String i})) {}
71+
void bar1((int i, {String s, String i}) r) {}
7272
// ^
7373
// [analyzer] unspecified
7474
// [cfe] unspecified
7575

76-
void bar2((int i, String i, {String s})) {}
76+
void bar2((int i, String i, {String s}) r) {}
7777
// ^
7878
// [analyzer] unspecified
7979
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A04_t01.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -38,7 +38,7 @@ typedef (int) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3((String s));
41+
typedef void R3((String s) r);
4242
// ^^^^^^^^^^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A04_t02.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///

LanguageFeatures/Records/record_type_annotations_A04_t03.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -37,7 +37,7 @@ typedef R4 = (int i, {String s,});
3737

3838
typedef (int, {String s,}) R5();
3939

40-
typedef void R6(({String s, int i,}));
40+
typedef void R6(({String s, int i,}) r);
4141

4242
(int, bool,) foo1() => (42, true);
4343

@@ -71,6 +71,8 @@ main() {
7171
}
7272

7373
d as (int, int j,);
74+
d = (1, j: 2);
7475
d as (int, {int j,});
76+
d = (i: 1, j: 2);
7577
d as ({int i, int j,});
7678
}

LanguageFeatures/Records/record_type_annotations_A04_t04.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -38,7 +38,7 @@ typedef (int, String s,,) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3((String s, int,,));
41+
typedef void R3((String s, int,,) r);
4242
// ^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified
@@ -53,7 +53,7 @@ typedef (int, {String s,,}) R5();
5353
// [analyzer] unspecified
5454
// [cfe] unspecified
5555

56-
typedef void R6(({String s, int i,,}));
56+
typedef void R6(({String s, int i,,}) r);
5757
// ^
5858
// [analyzer] unspecified
5959
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A04_t05.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -38,7 +38,7 @@ typedef (int, {String s},) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3(({String s, int i},));
41+
typedef void R3(({String s, int i},) r);
4242
// ^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A04_t06.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///

LanguageFeatures/Records/record_type_annotations_A05_t01.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -23,7 +23,7 @@
2323
/// the getter for the first positional field.
2424
///
2525
/// @description Checks that it is a compile-time error if a record type has a
26-
/// field named `hashCode`
26+
/// named field named `hashCode`
2727
/// @author [email protected]
2828
2929
// SharedOptions=--enable-experiment=records
@@ -38,7 +38,7 @@ typedef (int, {int hashCode}) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3((String s, {String hashCode}));
41+
typedef void R3((String s, {String hashCode}) r);
4242
// ^^^^^^^^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified
@@ -48,7 +48,7 @@ typedef void R3((String s, {String hashCode}));
4848
// [analyzer] unspecified
4949
// [cfe] unspecified
5050

51-
void bar((int i, {bool hashCode})) {}
51+
void bar((int i, {bool hashCode}) r) {}
5252
// ^^^^^^^^
5353
// [analyzer] unspecified
5454
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A05_t02.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -23,7 +23,7 @@
2323
/// the getter for the first positional field.
2424
///
2525
/// @description Checks that it is a compile-time error if a record type has a
26-
/// field named `runtimeType`
26+
/// named field named `runtimeType`
2727
/// @author [email protected]
2828
2929
// SharedOptions=--enable-experiment=records
@@ -38,7 +38,7 @@ typedef (int, {Type runtimeType}) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3((String s, {String runtimeType}));
41+
typedef void R3((String s, {String runtimeType}) r);
4242
// ^^^^^^^^^^^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified
@@ -48,7 +48,7 @@ typedef void R3((String s, {String runtimeType}));
4848
// [analyzer] unspecified
4949
// [cfe] unspecified
5050

51-
void bar((int i, {Type runtimeType})) {}
51+
void bar((int i, {Type runtimeType}) r) {}
5252
// ^^^^^^^^^^^
5353
// [analyzer] unspecified
5454
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A05_t03.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -23,7 +23,7 @@
2323
/// the getter for the first positional field.
2424
///
2525
/// @description Checks that it is a compile-time error if a record type has a
26-
/// field named `noSuchMethod`
26+
/// named field named `noSuchMethod`
2727
/// @author [email protected]
2828
2929
// SharedOptions=--enable-experiment=records
@@ -38,7 +38,7 @@ typedef (int, {Function noSuchMethod}) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3((String s, {String noSuchMethod}));
41+
typedef void R3((String s, {String noSuchMethod}) r);
4242
// ^^^^^^^^^^^^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified
@@ -48,7 +48,7 @@ typedef void R3((String s, {String noSuchMethod}));
4848
// [analyzer] unspecified
4949
// [cfe] unspecified
5050

51-
void bar((int i, {Function noSuchMethod})) {}
51+
void bar((int i, {Function noSuchMethod}) r) {}
5252
// ^^^^^^^^^^^^
5353
// [analyzer] unspecified
5454
// [cfe] unspecified

LanguageFeatures/Records/record_type_annotations_A05_t04.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// symmetric with record expressions and leaves the potential for later support
1515
/// for parentheses for grouping in type expressions.
1616
///
17-
/// A named field named hashCode, runtimeType, noSuchMethod, or toString.
17+
/// A field named hashCode, runtimeType, noSuchMethod, or toString.
1818
///
1919
/// A field name that starts with an underscore.
2020
///
@@ -23,7 +23,7 @@
2323
/// the getter for the first positional field.
2424
///
2525
/// @description Checks that it is a compile-time error if a record type has a
26-
/// field named `toString`
26+
/// named field named `toString`
2727
/// @author [email protected]
2828
2929
// SharedOptions=--enable-experiment=records
@@ -38,7 +38,7 @@ typedef (int, {int toString}) R2();
3838
// [analyzer] unspecified
3939
// [cfe] unspecified
4040

41-
typedef void R3((String s, {String toString}));
41+
typedef void R3((String s, {String toString}) r);
4242
// ^^^^^^^^
4343
// [analyzer] unspecified
4444
// [cfe] unspecified
@@ -48,7 +48,7 @@ typedef void R3((String s, {String toString}));
4848
// [analyzer] unspecified
4949
// [cfe] unspecified
5050

51-
void bar((int i, {bool toString})) {}
51+
void bar((int i, {bool toString}) r) {}
5252
// ^^^^^^^^
5353
// [analyzer] unspecified
5454
// [cfe] unspecified

0 commit comments

Comments
 (0)