Skip to content

Commit af3a268

Browse files
authored
#1400. File delete/rename commit (#2072)
`static_analysis_inline_class_A09_t01.dart` and `static_analysis_inline_class_A10_t01.dart` were deleted. Other tests were renamed to fill the gap in the enumeration.
1 parent e43ef65 commit af3a268

12 files changed

+42
-110
lines changed

LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t01.dart

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// @assertion If e is an expression whose static type V is the inline type
6-
/// Inline<T1, .. Ts> and m is the name of a member that V has, a member access
7-
/// like e.m(args) is treated as an invocation of the inline member m on the
8-
/// receiver e according to the inline type Inline and with the actual type
9-
/// arguments T1, ..., Ts, with the actual argument part args.
6+
/// Inline<T1, .. Ts> and V has no member whose basename is the basename of m,
7+
/// a member access like e.m(args) may be an extension member access, following
8+
/// the normal rules about applicability and accessibility of extensions, in
9+
/// particular that V must match the on-type of the extension.
1010
///
11-
/// @description Checks that a member access `e.m(args)` is treated as an
12-
/// invocation of the inline member m on the receiver `e` according to the
13-
/// inline type `Inline` and with the actual type arguments `T1, ..., Ts`, with
14-
/// the actual argument part `args`.
11+
/// @description Checks that if `V` has no member with the name `m`, but there
12+
/// is an extension member `m` then it is invoked
1513
/// @author [email protected]
1614
1715
// SharedOptions=--enable-experiment=inline-class
1816

19-
import "../../Utils/static_type_helper.dart";
17+
import "../../Utils/expect.dart";
2018

21-
inline class V1<T> {
22-
final T id;
23-
V1(this.id);
19+
extension Ex1 on V {
20+
String foo() => "Ex1.foo()";
21+
}
2422

25-
(Map<K, V>, T) asMap<K, V>() => (<K, V>{}, id);
23+
extension Ex2 on int {
24+
String bar() => "Ex2.bar()";
2625
}
2726

28-
main() {
29-
V1<num> v1 = V1(42);
30-
v1.asMap<String, bool>()
31-
.expectStaticType<Exactly<(Map<String, bool>, num)>>();
27+
inline class V {
28+
final int id;
29+
V(this.id);
30+
}
3231

33-
V1<String> v2 = V1("42");
34-
v2.asMap<String, String>()
35-
.expectStaticType<Exactly<(Map<String, String>, String)>>();
32+
main() {
33+
V v = V(42);
34+
Expect.equals("Ex1.foo()", v.foo());
35+
Expect.equals("Ex2.bar()", v.id.bar());
3636
}

LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t01.dart

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
/// @assertion Similarly, e.m is treated an invocation of the inline member m on
6-
/// the receiver e according to the inline type Inline and with the actual type
7-
/// arguments T1, ..., Ts and no actual argument part.
5+
/// @assertion Let DV be an inline class declaration named Inline with type
6+
/// parameters X1 extends B1, .. Xs extends Bs. Assume that DV declares a final
7+
/// instance variable with name id and type R.
88
///
9-
/// @description Checks that a member access `e.m` is treated as an invocation
10-
/// of the inline member `m` on the receiver `e` according to the inline type
11-
/// `Inline` and with the actual type arguments `T1, ..., Ts` and no actual
12-
/// argument part
9+
/// We say that the declared representation type of Inline is R, and the
10+
/// instantiated representation type corresponding to Inline<T1,.. Ts> is
11+
/// [T1/X1, .. Ts/Xs]R.
12+
/// ...
13+
/// Let V be an inline type of the form Inline<T1, .. Ts>, and let R be the
14+
/// corresponding instantiated representation type. If R is non-nullable then V
15+
/// is a proper subtype of Object, and V is non-nullable. Otherwise, V is a
16+
/// proper subtype of Object?, and V is potentially nullable.
17+
///
18+
/// @description Checks that if an instantiated representation type `R` is
19+
/// non-nullable then it is not an error to assign it to `Object`
1320
/// @author [email protected]
1421
1522
// SharedOptions=--enable-experiment=inline-class
1623

17-
import "../../Utils/static_type_helper.dart";
18-
19-
inline class V1<T, K, V> {
20-
final T id;
24+
inline class V1 {
25+
final int id;
2126
V1(this.id);
27+
}
2228

23-
(Map<K, V>, T) get asMap => (<K, V>{}, id);
29+
inline class V2<T1, T2 extends num?> {
30+
final T1 id;
31+
V2(this.id);
2432
}
2533

2634
main() {
27-
V1<num, String, bool> v1 = V1(42);
28-
v1.asMap.expectStaticType<Exactly<(Map<String, bool>, num)>>();
29-
30-
V1<String, String, Null> v2 = V1("42");
31-
v2.asMap.expectStaticType<Exactly<(Map<String, Null>, String)>>();
35+
Object v1 = V1(42);
36+
Object v2 = V2<String?, int?>("42");
3237
}

0 commit comments

Comments
 (0)