-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Report errors on private fields in records
Closes #50144 Change-Id: I7cbf2fd30773269b5f839299f948da719f3eecc4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263781 Auto-Submit: Chloe Stefantsova <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
- Loading branch information
1 parent
41e04fc
commit a9a915e
Showing
13 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
(int _foo,) foo1() => throw 0; // Error. | ||
({int _foo}) foo2() => throw 0; // Error. | ||
foo3() => (_foo: 1); // Error. | ||
|
||
main() {} |
26 changes: 26 additions & 0 deletions
26
pkg/front_end/testcases/records/private_field_names.dart.strong.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:5:6: Error: Record field names can't be private. | ||
// (int _foo,) foo1() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:6:7: Error: Record field names can't be private. | ||
// ({int _foo}) foo2() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:7:12: Error: Record field names can't be private. | ||
// foo3() => (_foo: 1); // Error. | ||
// ^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo1() → invalid-type | ||
return throw 0; | ||
static method foo2() → invalid-type | ||
return throw 0; | ||
static method foo3() → dynamic | ||
return ({_foo: 1}); | ||
static method main() → dynamic {} |
31 changes: 31 additions & 0 deletions
31
pkg/front_end/testcases/records/private_field_names.dart.strong.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:5:6: Error: Record field names can't be private. | ||
// (int _foo,) foo1() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:6:7: Error: Record field names can't be private. | ||
// ({int _foo}) foo2() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:7:12: Error: Record field names can't be private. | ||
// foo3() => (_foo: 1); // Error. | ||
// ^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo1() → invalid-type | ||
return throw 0; | ||
static method foo2() → invalid-type | ||
return throw 0; | ||
static method foo3() → dynamic | ||
return ({_foo: 1}); | ||
static method main() → dynamic {} | ||
|
||
|
||
Extra constant evaluation status: | ||
Evaluated: RecordLiteral @ org-dartlang-testcase:///private_field_names.dart:7:11 -> RecordConstant(const ({_foo: 1})) | ||
Extra constant evaluation: evaluated: 3, effectively constant: 1 |
4 changes: 4 additions & 0 deletions
4
pkg/front_end/testcases/records/private_field_names.dart.textual_outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(int _foo,) foo1() => throw 0; | ||
({int _foo}) foo2() => throw 0; | ||
foo3() => (_foo: 1); | ||
main() {} |
26 changes: 26 additions & 0 deletions
26
pkg/front_end/testcases/records/private_field_names.dart.weak.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:5:6: Error: Record field names can't be private. | ||
// (int _foo,) foo1() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:6:7: Error: Record field names can't be private. | ||
// ({int _foo}) foo2() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:7:12: Error: Record field names can't be private. | ||
// foo3() => (_foo: 1); // Error. | ||
// ^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo1() → invalid-type | ||
return throw 0; | ||
static method foo2() → invalid-type | ||
return throw 0; | ||
static method foo3() → dynamic | ||
return ({_foo: 1}); | ||
static method main() → dynamic {} |
26 changes: 26 additions & 0 deletions
26
pkg/front_end/testcases/records/private_field_names.dart.weak.modular.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:5:6: Error: Record field names can't be private. | ||
// (int _foo,) foo1() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:6:7: Error: Record field names can't be private. | ||
// ({int _foo}) foo2() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:7:12: Error: Record field names can't be private. | ||
// foo3() => (_foo: 1); // Error. | ||
// ^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo1() → invalid-type | ||
return throw 0; | ||
static method foo2() → invalid-type | ||
return throw 0; | ||
static method foo3() → dynamic | ||
return ({_foo: 1}); | ||
static method main() → dynamic {} |
22 changes: 22 additions & 0 deletions
22
pkg/front_end/testcases/records/private_field_names.dart.weak.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:5:6: Error: Record field names can't be private. | ||
// (int _foo,) foo1() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:6:7: Error: Record field names can't be private. | ||
// ({int _foo}) foo2() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
import self as self; | ||
|
||
static method foo1() → invalid-type | ||
; | ||
static method foo2() → invalid-type | ||
; | ||
static method foo3() → dynamic | ||
; | ||
static method main() → dynamic | ||
; |
31 changes: 31 additions & 0 deletions
31
pkg/front_end/testcases/records/private_field_names.dart.weak.transformed.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:5:6: Error: Record field names can't be private. | ||
// (int _foo,) foo1() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:6:7: Error: Record field names can't be private. | ||
// ({int _foo}) foo2() => throw 0; // Error. | ||
// ^^^^ | ||
// | ||
// pkg/front_end/testcases/records/private_field_names.dart:7:12: Error: Record field names can't be private. | ||
// foo3() => (_foo: 1); // Error. | ||
// ^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
static method foo1() → invalid-type | ||
return throw 0; | ||
static method foo2() → invalid-type | ||
return throw 0; | ||
static method foo3() → dynamic | ||
return ({_foo: 1}); | ||
static method main() → dynamic {} | ||
|
||
|
||
Extra constant evaluation status: | ||
Evaluated: RecordLiteral @ org-dartlang-testcase:///private_field_names.dart:7:11 -> RecordConstant(const ({_foo: 1})) | ||
Extra constant evaluation: evaluated: 3, effectively constant: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters