diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t01.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t01.dart index 96532d5e7b..4025348668 100644 --- a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t01.dart +++ b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t01.dart @@ -3,34 +3,34 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion If e is an expression whose static type V is the inline type -/// Inline and m is the name of a member that V has, a member access -/// like e.m(args) is treated as an invocation of the inline member m on the -/// receiver e according to the inline type Inline and with the actual type -/// arguments T1, ..., Ts, with the actual argument part args. +/// Inline and V has no member whose basename is the basename of m, +/// a member access like e.m(args) may be an extension member access, following +/// the normal rules about applicability and accessibility of extensions, in +/// particular that V must match the on-type of the extension. /// -/// @description Checks that a member access `e.m(args)` is treated as an -/// invocation of the inline member m on the receiver `e` according to the -/// inline type `Inline` and with the actual type arguments `T1, ..., Ts`, with -/// the actual argument part `args`. +/// @description Checks that if `V` has no member with the name `m`, but there +/// is an extension member `m` then it is invoked /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=inline-class -import "../../Utils/static_type_helper.dart"; +import "../../Utils/expect.dart"; -inline class V1 { - final T id; - V1(this.id); +extension Ex1 on V { + String foo() => "Ex1.foo()"; +} - (Map, T) asMap() => ({}, id); +extension Ex2 on int { + String bar() => "Ex2.bar()"; } -main() { - V1 v1 = V1(42); - v1.asMap() - .expectStaticType, num)>>(); +inline class V { + final int id; + V(this.id); +} - V1 v2 = V1("42"); - v2.asMap() - .expectStaticType, String)>>(); +main() { + V v = V(42); + Expect.equals("Ex1.foo()", v.foo()); + Expect.equals("Ex2.bar()", v.id.bar()); } diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t02.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t02.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t02.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t02.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t03.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t03.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t03.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t03.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t04.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t04.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t04.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t04.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t05.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t05.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t05.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A09_t05.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t01.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t01.dart index e7dad03bd7..2a2c0b019d 100644 --- a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t01.dart +++ b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t01.dart @@ -2,31 +2,36 @@ // 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 Similarly, e.m is treated an invocation of the inline member m on -/// the receiver e according to the inline type Inline and with the actual type -/// arguments T1, ..., Ts and no actual argument part. +/// @assertion Let DV be an inline class declaration named Inline with type +/// parameters X1 extends B1, .. Xs extends Bs. Assume that DV declares a final +/// instance variable with name id and type R. /// -/// @description Checks that a member access `e.m` is treated as an invocation -/// of the inline member `m` on the receiver `e` according to the inline type -/// `Inline` and with the actual type arguments `T1, ..., Ts` and no actual -/// argument part +/// We say that the declared representation type of Inline is R, and the +/// instantiated representation type corresponding to Inline is +/// [T1/X1, .. Ts/Xs]R. +/// ... +/// Let V be an inline type of the form Inline, and let R be the +/// corresponding instantiated representation type. If R is non-nullable then V +/// is a proper subtype of Object, and V is non-nullable. Otherwise, V is a +/// proper subtype of Object?, and V is potentially nullable. +/// +/// @description Checks that if an instantiated representation type `R` is +/// non-nullable then it is not an error to assign it to `Object` /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=inline-class -import "../../Utils/static_type_helper.dart"; - -inline class V1 { - final T id; +inline class V1 { + final int id; V1(this.id); +} - (Map, T) get asMap => ({}, id); +inline class V2 { + final T1 id; + V2(this.id); } main() { - V1 v1 = V1(42); - v1.asMap.expectStaticType, num)>>(); - - V1 v2 = V1("42"); - v2.asMap.expectStaticType, String)>>(); + Object v1 = V1(42); + Object v2 = V2("42"); } diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t02.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t02.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t02.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t02.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t03.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t03.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t03.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t03.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t04.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t04.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t04.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t04.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t05.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t05.dart similarity index 100% rename from LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t05.dart rename to LanguageFeatures/Inline-classes/static_analysis_inline_class_A10_t05.dart diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t01.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t01.dart deleted file mode 100644 index 4025348668..0000000000 --- a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A11_t01.dart +++ /dev/null @@ -1,36 +0,0 @@ -// 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 If e is an expression whose static type V is the inline type -/// Inline and V has no member whose basename is the basename of m, -/// a member access like e.m(args) may be an extension member access, following -/// the normal rules about applicability and accessibility of extensions, in -/// particular that V must match the on-type of the extension. -/// -/// @description Checks that if `V` has no member with the name `m`, but there -/// is an extension member `m` then it is invoked -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=inline-class - -import "../../Utils/expect.dart"; - -extension Ex1 on V { - String foo() => "Ex1.foo()"; -} - -extension Ex2 on int { - String bar() => "Ex2.bar()"; -} - -inline class V { - final int id; - V(this.id); -} - -main() { - V v = V(42); - Expect.equals("Ex1.foo()", v.foo()); - Expect.equals("Ex2.bar()", v.id.bar()); -} diff --git a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t01.dart b/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t01.dart deleted file mode 100644 index 2a2c0b019d..0000000000 --- a/LanguageFeatures/Inline-classes/static_analysis_inline_class_A12_t01.dart +++ /dev/null @@ -1,37 +0,0 @@ -// 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 Let DV be an inline class declaration named Inline with type -/// parameters X1 extends B1, .. Xs extends Bs. Assume that DV declares a final -/// instance variable with name id and type R. -/// -/// We say that the declared representation type of Inline is R, and the -/// instantiated representation type corresponding to Inline is -/// [T1/X1, .. Ts/Xs]R. -/// ... -/// Let V be an inline type of the form Inline, and let R be the -/// corresponding instantiated representation type. If R is non-nullable then V -/// is a proper subtype of Object, and V is non-nullable. Otherwise, V is a -/// proper subtype of Object?, and V is potentially nullable. -/// -/// @description Checks that if an instantiated representation type `R` is -/// non-nullable then it is not an error to assign it to `Object` -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=inline-class - -inline class V1 { - final int id; - V1(this.id); -} - -inline class V2 { - final T1 id; - V2(this.id); -} - -main() { - Object v1 = V1(42); - Object v2 = V2("42"); -}