Skip to content

Commit 89ec72c

Browse files
authored
dart-lang#1400. Add the trivial case and a pattern check (dart-lang#2451)
Add the trivial case and a pattern check
1 parent ed6da2f commit 89ec72c

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

LanguageFeatures/Extension-types/static_analysis_member_invocation_A06_t02.dart

+6
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,11 @@ main() {
3232
et1.ceil();
3333
// ^^^^
3434
// [analyzer] unspecified
35+
// [cfe] unspecified
36+
37+
var ET1(m2: v1) = et1;
38+
var ET1(isOdd: v2) = et1;
39+
// ^^^^^
40+
// [analyzer] unspecified
3541
// [cfe] unspecified
3642
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion We say that an extension type declaration DV has an extension
6+
/// type member named n in the cases where:
7+
/// - DV declares a member named n.
8+
/// - DV has no such declaration, but DV has a direct extension type
9+
/// superinterface V that has an extension type member named n due to a member
10+
/// declaration DM2, and DV does not declare a member that precludes DM2.
11+
///
12+
/// @description Checks that if an extension type `ET` has no superinterface
13+
/// with a member `m` and doesn't declare it then it is a compile-time error to
14+
/// call this member
15+
/// @author [email protected]
16+
17+
// SharedOptions=--enable-experiment=inline-class
18+
19+
extension type ET(int _) {}
20+
21+
main() {
22+
ET et = ET(42);
23+
et.ceil();
24+
// ^^^^
25+
// [analyzer] unspecified
26+
// [cfe] unspecified
27+
28+
et.isOdd;
29+
// ^^^^^
30+
// [analyzer] unspecified
31+
// [cfe] unspecified
32+
33+
var ET(isEven: b) = et;
34+
// ^^^^^^
35+
// [analyzer] unspecified
36+
// [cfe] unspecified
37+
38+
var n = switch (et) {
39+
ET(isEven: true) => true,
40+
// ^^^^^^
41+
// [analyzer] unspecified
42+
// [cfe] unspecified
43+
_ => false
44+
};
45+
}

0 commit comments

Comments
 (0)