-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2909. Fix extension applicability tests according to the updat…
- Loading branch information
Showing
2 changed files
with
59 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,46 +6,44 @@ | |
/// invocation with corresponding member basename m and target expression `e`, | ||
/// where `e` has static type `S`, if | ||
/// ... | ||
/// - The type S does not have a member with the basename m. For this, the type | ||
/// `dynamic` is considered as having all member names, and an expression of | ||
/// type `Never` or `void` cannot occur as the target of a member invocation, | ||
/// so none of these can ever have applicable extensions. Function types and | ||
/// the type `Function` are considered as having a `call` member. This ensure | ||
/// that if there is an applicable extension, the existing invocation would | ||
/// otherwise be a compile-time error. Members of `Object` exists on all | ||
/// types, so they can never be the target of implicit member invocations | ||
/// (they can also not be declared as extension members). | ||
/// - The type S does not have an instance member with the basename m. For this, | ||
/// the type `dynamic` is considered as having all member names, and an | ||
/// expression of type `Never` or `void` cannot occur as the target of a | ||
/// member invocation, so none of these can ever have applicable extensions. | ||
/// Function types and the type `Function` are considered as having a `call` | ||
/// member. This ensure that if there is an applicable extension, the existing | ||
/// invocation would otherwise be a compile-time error. Members of `Object` | ||
/// exists on all types, so they can never be the target of implicit member | ||
/// invocations (they can also not be declared as extension members). | ||
/// | ||
/// @description Check that an extension member with the basename `m` is not | ||
/// applicable if on type has a static member with the same basename. | ||
/// @description Check that an extension member with the basename `m` is | ||
/// applicable even if the on type has a static member with the same basename. | ||
/// @author [email protected] | ||
/// @issue 56818 | ||
import '../../Utils/expect.dart'; | ||
|
||
String _log = ""; | ||
|
||
class C { | ||
static String get m1 => "m1"; | ||
static String m2() => "m2"; | ||
static void set m3(String _) {} | ||
static void set m3(String _) { | ||
_log = "m3"; | ||
} | ||
} | ||
|
||
extension Ext on C { | ||
String get m1 => "Ext.m1"; | ||
String m2() => "Ext.m2"; | ||
void set m3(String _) {} | ||
void set m3(String _) { | ||
_log = "Ext.m3"; | ||
} | ||
} | ||
|
||
main() { | ||
print(C().m1); | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
print(C().m2()); | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
Expect.equals("Ext.m1", C().m1); | ||
Expect.equals("Ext.m2", C().m2()); | ||
C().m3 = ""; | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
Expect.equals("Ext.m3", _log); | ||
} |
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 |
---|---|---|
|
@@ -6,45 +6,51 @@ | |
/// invocation with corresponding member basename m and target expression `e`, | ||
/// where `e` has static type `S`, if | ||
/// ... | ||
/// - The type S does not have a member with the basename m. For this, the type | ||
/// `dynamic` is considered as having all member names, and an expression of | ||
/// type `Never` or `void` cannot occur as the target of a member invocation, | ||
/// so none of these can ever have applicable extensions. Function types and | ||
/// the type `Function` are considered as having a `call` member. This ensure | ||
/// that if there is an applicable extension, the existing invocation would | ||
/// otherwise be a compile-time error. Members of `Object` exists on all | ||
/// types, so they can never be the target of implicit member invocations | ||
/// (they can also not be declared as extension members). | ||
/// - The type S does not have an instance member with the basename m. For this, | ||
/// the type `dynamic` is considered as having all member names, and an | ||
/// expression of type `Never` or `void` cannot occur as the target of a | ||
/// member invocation, so none of these can ever have applicable extensions. | ||
/// Function types and the type `Function` are considered as having a `call` | ||
/// member. This ensure that if there is an applicable extension, the existing | ||
/// invocation would otherwise be a compile-time error. Members of `Object` | ||
/// exists on all types, so they can never be the target of implicit member | ||
/// invocations (they can also not be declared as extension members). | ||
/// | ||
/// @description Check that an extension member with the basename `m` is not | ||
/// applicable if on type has a static member with the same basename. | ||
/// @description Check that an extension member with the basename `m` is | ||
/// applicable even if the on type has a static member with the same basename. | ||
/// @author [email protected] | ||
import '../../Utils/expect.dart'; | ||
|
||
String _log = ""; | ||
|
||
class C { | ||
static String get m1 => "m1"; | ||
static String m2() => "m2"; | ||
static void set m3(String _) {} | ||
static void set m3(String _) { | ||
_log = "m3"; | ||
} | ||
static void set m4(String _) { | ||
_log = "m4"; | ||
} | ||
} | ||
|
||
extension Ext on C { | ||
void set m1(String _) {} | ||
void set m2(String _) {} | ||
String m3() => "Ext.m2"; | ||
void set m1(String _) { | ||
_log = "Ext.m1"; | ||
} | ||
void set m2(String _) { | ||
_log = "Ext.m2"; | ||
} | ||
String m3() => "Ext.m3"; | ||
String get m4 => "Ext.m4"; | ||
} | ||
|
||
main() { | ||
print(C().m1); | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
print(C().m2()); | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
C().m3 = ""; | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
C().m1 = ""; | ||
Expect.equals("Ext.m1", _log); | ||
C().m2 = ""; | ||
Expect.equals("Ext.m2", _log); | ||
Expect.equals("Ext.m3", C().m3()); | ||
Expect.equals("Ext.m4", C().m4); | ||
} |