-
Notifications
You must be signed in to change notification settings - Fork 28
Fixes #2388. Add tests for the new method/setter rules. Update assertions #2393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -2,14 +2,15 @@ | |
// 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 a non-extension | ||
/// type member named n in the case where DV does not declare a member named n, | ||
/// but DV has a direct extension type superinterface V that has a non-extension | ||
/// type member named n, or DV has a direct non-extension type superinterface T | ||
/// whose interface contains a member signature named n. | ||
/// @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 if an extension type `ET` has a superinterface with | ||
/// a member `m` then this member is also presents in `ET` | ||
/// a member `m` then this member is also present in `ET` | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=inline-class | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -2,14 +2,15 @@ | |
// 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 a non-extension | ||
/// type member named n in the case where DV does not declare a member named n, | ||
/// but DV has a direct extension type superinterface V that has a non-extension | ||
/// type member named n, or DV has a direct non-extension type superinterface T | ||
/// whose interface contains a member signature named n. | ||
/// @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 if an extension type `ET` has a superinterface with | ||
/// a member `m` then this member is also presents in `ET`v but members of its | ||
/// a member `m` then this member is also present in `ET` but members of its | ||
/// representation type are not | ||
/// @author [email protected] | ||
|
||
|
@@ -23,20 +24,6 @@ extension type ET0(int id) { | |
|
||
extension type ET1(int id) implements ET0 {} | ||
|
||
extension type ET2(int id) implements num {} | ||
|
||
class I { | ||
int i = 0; | ||
} | ||
|
||
class J extends I { | ||
int j = 1; | ||
} | ||
|
||
extension type ET3(J rep) implements I { | ||
int get jOfEt3 => rep.j; | ||
} | ||
|
||
main() { | ||
ET1 et1 = ET1(42); | ||
et1.m1(); | ||
|
@@ -45,21 +32,5 @@ main() { | |
et1.ceil(); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
ET2 et2 = ET2(42); | ||
et2.ceil(); | ||
et2.isOdd; | ||
// ^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
var et3 = ET3(J()); | ||
et3.rep; | ||
et3.i; | ||
et3.jOfEt3; | ||
et3.j; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
73 changes: 73 additions & 0 deletions
73
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t05.dart
This file contains hidden or 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,73 @@ | ||
// 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 a getter doesn't preclude setter and vice versa | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
String log = ""; | ||
|
||
extension type V1(int _) { | ||
String get n => "V1"; | ||
} | ||
|
||
extension type V2(int _) { | ||
void set n(String n) { | ||
log = "V2: $n"; | ||
} | ||
} | ||
|
||
extension type V0(int _) implements V1, V2 {} | ||
|
||
extension type ET1(V1 _) implements V1 { | ||
void set n(String v) { | ||
log = "ET1: $v"; | ||
} | ||
} | ||
|
||
extension type ET2(V2 _) implements V2 { | ||
String get n => "ET2"; | ||
} | ||
|
||
extension type ET3(V0 _) implements V1, V2 { | ||
String get n => "ET3"; | ||
} | ||
|
||
extension type ET4(V0 _) implements V1, V2 { | ||
void set n(String v) { | ||
log = "ET4: $v"; | ||
} | ||
} | ||
|
||
main() { | ||
final v = V0(0); | ||
Expect.equals("V1", ET1(v).n); | ||
ET1(v).n = "a"; | ||
Expect.equals("ET1: a", log); | ||
log = ""; | ||
|
||
Expect.equals("ET2", ET2(v).n); | ||
ET2(v).n = "b"; | ||
Expect.equals("V2: b", log); | ||
log = ""; | ||
|
||
Expect.equals("ET3", ET3(v).n); | ||
ET3(v).n = "c"; | ||
Expect.equals("V2: c", log); | ||
log = ""; | ||
|
||
Expect.equals("V1", ET4(v).n); | ||
ET4(v).n = "d"; | ||
Expect.equals("ET4: d", log); | ||
} |
60 changes: 60 additions & 0 deletions
60
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t06.dart
This file contains hidden or 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,60 @@ | ||
// 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 an extension type declares a method or setter then | ||
/// they preclude inherited members | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
String log = ""; | ||
|
||
extension type V1(int _) { | ||
String n() => "V1"; | ||
} | ||
|
||
extension type V2(int _) { | ||
void set n(String v) { | ||
log = "V2: $v"; | ||
} | ||
} | ||
|
||
extension type ET1(V1 _) implements V1 { | ||
void set n(String v) { | ||
log = "ET1: $v"; | ||
} | ||
} | ||
|
||
extension type ET2(V2 _) implements V2 { | ||
String n() => "ET2"; | ||
} | ||
|
||
extension type ET3(V1 _) implements V1 { | ||
void set n(int v) { | ||
log = "ET3: $v"; | ||
} | ||
} | ||
|
||
extension type ET4(V2 _) implements V2 { | ||
T n<T>(T t) => t; | ||
} | ||
|
||
main() { | ||
ET1(V1(0)).n = "1"; | ||
Expect.equals("ET1: 1", log); | ||
log = ""; | ||
Expect.equals("ET2", ET2(V2(0)).n()); | ||
ET3(V1(0)).n = 3; | ||
Expect.equals("ET3: 3", log); | ||
Expect.equals(42, ET4(V2(0)).n<int>(42)); | ||
} |
62 changes: 62 additions & 0 deletions
62
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t07.dart
This file contains hidden or 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,62 @@ | ||
// 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 an extension type declares a method it precludes | ||
/// inherited members | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
extension type V1(int _) { | ||
String n() => "V1"; | ||
} | ||
|
||
extension type V2(int _) { | ||
void set n(String v) {} | ||
} | ||
|
||
extension type ET1(V1 _) implements V1 { | ||
void set n(String v) {} | ||
} | ||
|
||
extension type ET2(V2 _) implements V2 { | ||
String n() => "ET2"; | ||
} | ||
|
||
extension type ET3(V1 _) implements V1 { | ||
void set n(int v) {} | ||
} | ||
|
||
extension type ET4(V2 _) implements V2 { | ||
int n() => 42; | ||
} | ||
|
||
main() { | ||
ET1(V1(0)).n(); | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
ET2(V2(0)).n = "42"; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
ET3(V1(0)).n(); | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
ET4(V2(0)).n = "42"; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
61 changes: 61 additions & 0 deletions
61
LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t08.dart
This file contains hidden or 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,61 @@ | ||
// 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 a getter doesn't preclude setter and vice versa, | ||
/// and hence the `ET*` types have a getter/setter signature conflict. | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
extension type V1(int _) { | ||
String get n => "V1"; | ||
} | ||
|
||
extension type V2(int _) { | ||
void set n(String n) {} | ||
} | ||
|
||
extension type V0(int _) implements V1, V2 {} | ||
|
||
extension type ET1(V1 _) implements V1 { | ||
void set n(int v) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
extension type ET2(V2 _) implements V2 { | ||
int get n => 2; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
extension type ET3(V0 _) implements V1, V2 { | ||
int get n => 3; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
extension type ET4(V0 _) implements V1, V2 { | ||
void set n(int v) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(ET1); | ||
print(ET2); | ||
print(ET3); | ||
print(ET4); | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -4,12 +4,16 @@ | |
|
||
/// @assertion We say that an extension type declaration DV has a non-extension | ||
/// type member named n in the case where DV does not declare a member named n, | ||
/// but DV has a direct extension type superinterface V that has a non-extension | ||
/// type member named n, or DV has a direct non-extension type superinterface T | ||
/// whose interface contains a member signature named n. | ||
/// and one of the following criteria is satisfied: | ||
/// - DV has a direct extension type superinterface V that has a non-extension | ||
/// type member with signature m and name n, and DV does not declare a member | ||
/// that precludes m. | ||
/// - DV has a direct non-extension type superinterface whose interface contains | ||
/// a member signature m named n, and DV does not declare a member that | ||
/// precludes m. | ||
/// | ||
/// @description Checks that if an extension type `ET` has a superinterface with | ||
/// a member `m` then this member is also presents in `ET` | ||
/// a member `m` then this member is also present in `ET` | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=inline-class | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.