|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | 3 | // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
|
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. |
8 | 8 | /// |
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` |
13 | 20 | /// @author sgrekhov22@gmail.com |
14 | 21 |
|
15 | 22 | // SharedOptions=--enable-experiment=inline-class |
16 | 23 |
|
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; |
21 | 26 | V1(this.id); |
| 27 | +} |
22 | 28 |
|
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); |
24 | 32 | } |
25 | 33 |
|
26 | 34 | 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"); |
32 | 37 | } |
0 commit comments