forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes dart-lang#2388. Add tests for the new method/setter rules. Upda…
…te assertions
- Loading branch information
Showing
7 changed files
with
198 additions
and
21 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
53 changes: 53 additions & 0 deletions
53
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t05.dart
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,53 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion We say that an extension type declaration DV has an extension | ||
/// type member named n in the cases where: | ||
/// - DV declares a member named n. | ||
/// - DV has no such declaration, but DV has a direct extension type | ||
/// superinterface V that has an extension type member named n due to a member | ||
/// declaration DM2, and DV does not declare a member that precludes DM2. | ||
/// | ||
/// @description Checks that it is no error if an extension type declares a | ||
/// getter that precludes inherited members | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
extension type V1(int id) { | ||
void n(int n) {} | ||
} | ||
|
||
extension type V2(int id) { | ||
String get n => "V2"; | ||
} | ||
|
||
extension type V3(int id) { | ||
void set n(int n) {} | ||
} | ||
|
||
extension type ET1(int id) implements V1 { | ||
bool get n => true; | ||
} | ||
|
||
extension type ET2(int id) implements V2 { | ||
bool get n => true; | ||
} | ||
|
||
extension type ET3(int id) implements V3 { | ||
bool get n => true; | ||
} | ||
|
||
extension type ET4(int id) implements V1, V2, V3 { | ||
bool get n => true; | ||
} | ||
|
||
main() { | ||
Expect.isTrue(ET1(42).n); | ||
Expect.isTrue(ET2(42).n); | ||
Expect.isTrue(ET3(42).n); | ||
Expect.isTrue(ET4(42).n); | ||
} |
53 changes: 53 additions & 0 deletions
53
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t06.dart
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,53 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion We say that an extension type declaration DV has an extension | ||
/// type member named n in the cases where: | ||
/// - DV declares a member named n. | ||
/// - DV has no such declaration, but DV has a direct extension type | ||
/// superinterface V that has an extension type member named n due to a member | ||
/// declaration DM2, and DV does not declare a member that precludes DM2. | ||
/// | ||
/// @description Checks that it is no error if an extension type declares a | ||
/// method that precludes inherited members | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
extension type V1(int id) { | ||
void n(int n) {} | ||
} | ||
|
||
extension type V2(int id) { | ||
String get n => "V2"; | ||
} | ||
|
||
extension type V3(int id) { | ||
void set n(int n) {} | ||
} | ||
|
||
extension type ET1(int id) implements V1 { | ||
T n<T>(T t) => t; | ||
} | ||
|
||
extension type ET2(int id) implements V2 { | ||
T n<T>(T t) => t; | ||
} | ||
|
||
extension type ET3(int id) implements V3 { | ||
T n<T>(T t) => t; | ||
} | ||
|
||
extension type ET4(int id) implements V1, V2, V3 { | ||
T n<T>(T t) => t; | ||
} | ||
|
||
main() { | ||
Expect.isTrue(ET1(42).n<bool>(true)); | ||
Expect.isTrue(ET2(42).n<bool>(true)); | ||
Expect.isTrue(ET3(42).n<bool>(true)); | ||
Expect.isTrue(ET4(42).n<bool>(true)); | ||
} |
67 changes: 67 additions & 0 deletions
67
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t07.dart
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,67 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
/// @assertion We say that an extension type declaration DV has an extension | ||
/// type member named n in the cases where: | ||
/// - DV declares a member named n. | ||
/// - DV has no such declaration, but DV has a direct extension type | ||
/// superinterface V that has an extension type member named n due to a member | ||
/// declaration DM2, and DV does not declare a member that precludes DM2. | ||
/// | ||
/// @description Checks that it is no error if an extension type declares a | ||
/// setter that precludes inherited members | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
String log = ""; | ||
|
||
extension type V1(int id) { | ||
void n(int n) {} | ||
} | ||
|
||
extension type V2(int id) { | ||
String get n => "V2"; | ||
} | ||
|
||
extension type V3(int id) { | ||
void set n(int n) {} | ||
} | ||
|
||
extension type ET1(int id) implements V1 { | ||
void set n(String v) { | ||
log += v; | ||
} | ||
} | ||
|
||
extension type ET2(int id) implements V2 { | ||
void set n(String v) { | ||
log += v; | ||
} | ||
} | ||
|
||
extension type ET3(int id) implements V3 { | ||
void set n(String v) { | ||
log += v; | ||
} | ||
} | ||
|
||
extension type ET4(int id) implements V1, V2, V3 { | ||
void set n(String v) { | ||
log += v; | ||
} | ||
} | ||
|
||
main() { | ||
Expect.equals("1", ET1(42).n = "1"); | ||
log = ""; | ||
Expect.equals("2", ET2(42).n = "2"); | ||
log = ""; | ||
Expect.equals("3", ET3(42).n = "3"); | ||
log = ""; | ||
Expect.equals("4", ET4(42).n = "4"); | ||
log = ""; | ||
} |