From 25d91e13f4205cd1aff78aa775109ba89a3aa76e Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 26 Nov 2024 16:43:33 +0200 Subject: [PATCH 01/11] #2976. Add semantics tests --- .../grammar_A03_t01.dart | 29 +++++ .../semantics_A01_t01.dart | 121 ++++++++++++++++++ .../semantics_A01_t02.dart | 82 ++++++++++++ .../semantics_A01_t03.dart | 82 ++++++++++++ .../semantics_A01_t04.dart | 114 +++++++++++++++++ .../semantics_A01_t05.dart | 93 ++++++++++++++ .../semantics_A01_t06.dart | 93 ++++++++++++++ .../shorthand_lib.dart | 54 ++++++++ 8 files changed, 668 insertions(+) create mode 100644 LanguageFeatures/Static-access-shorthand/grammar_A03_t01.dart create mode 100644 LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart create mode 100644 LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart create mode 100644 LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart create mode 100644 LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart create mode 100644 LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart create mode 100644 LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart create mode 100644 LanguageFeatures/Static-access-shorthand/shorthand_lib.dart diff --git a/LanguageFeatures/Static-access-shorthand/grammar_A03_t01.dart b/LanguageFeatures/Static-access-shorthand/grammar_A03_t01.dart new file mode 100644 index 0000000000..a4ea4a4858 --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/grammar_A03_t01.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2024, 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 We also add `.` to the tokens that an expression statement cannot +/// start with. +/// +/// @description Checks that numerical literal like `.123` is still not an error +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +main() { + .123; + + (.123); + + var v1 = .123 + 1; + + if (.123 > 0) {} + + const half = .5; + + final zero = 0 - .0; + + .314e+1; + + var pi = .214e+1 + 1; +} diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart new file mode 100644 index 0000000000..3e6ea32b7b --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart @@ -0,0 +1,121 @@ +// Copyright (c) 2024, 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 Dart semantics, static and dynamic, do not follow the grammar +/// precisely. For example, a static member invocation expression of the form +/// `C.id(e2)` is treated as an atomic entity for type inference (and +/// runtime semantics). It’s not a combination of doing a `C.id` tear-off, then +/// a `` instantiation and then an `(e2)` invocation. The context type of +/// that entire expression is used throughout the inference, where +/// `(e1.id)(e2)` has `(e1.id)` in a position where it has no context +/// type. +/// +/// Because of that, the specification of the static and runtime semantics of +/// the new constructs needs to address all the forms `.id`, `.id`, +/// `.id(args)`, `.id(args)`, `.new` or `.new(args)`. +/// ... +/// The general rule is that any of the expression forms above, starting with +/// `.id`, are treated exactly as if they were prefixed by a fresh identifier +/// `X` which denotes an accessible type alias for the greatest closure of the +/// context type scheme of the following primary and selector chain. +/// +/// @description Checks that expressions of the form `.id`, `.id(args)` and +/// `.id(args)` are treated as if they are prefixed by a fresh +/// identifier `X` which denotes an accessible type alias. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +import '../../Utils/expect.dart'; + +class C { + T t; + C(this.t); + + static C get id1 => C(1); + static C id2(X x) => C(x); +} + +typedef CAlias = C; +typedef CInt = C; + +mixin M on C { + static M get id1 => MC(1); + static M id2(X x) => MC(x); +} + +class MC = C with M; + +typedef MAlias = M; +typedef MInt = M; + +enum E { + e1(1), e2("2"); + final T t; + const E(this.t); + + static E get id1 => E.e1; + static E id2() => E.e2; +} + +typedef EAlias = E; +typedef EInt = E; + +extension type ET(T t) { + static ET get id1 => ET(1); + static ET id2(X x) => ET(x); +} + +typedef ETAlias = ET; +typedef ETInt = ET; + +main() { + C c1 = .id1; + Expect.equals(1, c1.t); + + C c2 = .id2("c2"); + Expect.equals("c2", c2.t); + + CAlias c3 = .id1; + Expect.equals(1, c3.t); + + CInt c4 = .id2(4); + Expect.equals(4, c4.t); + + M m1 = M.id1; + Expect.equals(1, m1.t); + + M m2 = .id2("m2"); + Expect.equals("m2", m2.t); + + MAlias m3 = .id1; + Expect.equals(1, m3.t); + + MInt m4 = .id2(4); + Expect.equals(4, m4.t); + + E e1 = .id1; + Expect.equals(E.e0, e1); + + E e2 = .id2(); + Expect.equals(E.e2, e2); + + EInt e3 = .id1; + Expect.equals(1, e3.t); + + EAlias e4 = .id2(); + Expect.equals("2", e4.t); + + ET et1 = .id1; + Expect.equals(1, et1.t); + + ET et2 = .id2("et2"); + Expect.equals("et2", et2.t); + + ETAlias et3 = .id1; + Expect.equals(1, et3.t); + + ETInt et4 = .id2(4); + Expect.equals(4, et4.t); +} diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart new file mode 100644 index 0000000000..fda58ea51e --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, 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 Dart semantics, static and dynamic, do not follow the grammar +/// precisely. For example, a static member invocation expression of the form +/// `C.id(e2)` is treated as an atomic entity for type inference (and +/// runtime semantics). It’s not a combination of doing a `C.id` tear-off, then +/// a `` instantiation and then an `(e2)` invocation. The context type of +/// that entire expression is used throughout the inference, where +/// `(e1.id)(e2)` has `(e1.id)` in a position where it has no context +/// type. +/// +/// Because of that, the specification of the static and runtime semantics of +/// the new constructs needs to address all the forms `.id`, `.id`, +/// `.id(args)`, `.id(args)`, `.new` or `.new(args)`. +/// ... +/// The general rule is that any of the expression forms above, starting with +/// `.id`, are treated exactly as if they were prefixed by a fresh identifier +/// `X` which denotes an accessible type alias for the greatest closure of the +/// context type scheme of the following primary and selector chain. +/// +/// @description Checks that expressions of the form `.id`, `.id(args)` and +/// `.id(args)` are treated as if they are prefixed by a fresh +/// identifier `X` which denotes an accessible type alias. Test unprefixed +/// import. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +import '../../Utils/expect.dart'; +import 'shorthand_lib.dart'; + +main() { + C c1 = .id1; + Expect.equals(1, c1.t); + + C c2 = .id2("c2"); + Expect.equals("c2", c2.t); + + CAlias c3 = .id1; + Expect.equals(1, c3.t); + + CInt c4 = .id2(4); + Expect.equals(4, c4.t); + + M m1 = M.id1; + Expect.equals(1, m1.t); + + M m2 = .id2("m2"); + Expect.equals("m2", m2.t); + + MAlias m3 = .id1; + Expect.equals(1, m3.t); + + MInt m4 = .id2(4); + Expect.equals(4, m4.t); + + E e1 = .id1; + Expect.equals(E.e0, e1); + + E e2 = .id2(); + Expect.equals(E.e2, e2); + + EInt e3 = .id1; + Expect.equals(1, e3.t); + + EAlias e4 = .id2(); + Expect.equals("2", e4.t); + + ET et1 = .id1; + Expect.equals(1, et1.t); + + ET et2 = .id2("et2"); + Expect.equals("et2", et2.t); + + ETAlias et3 = .id1; + Expect.equals(1, et3.t); + + ETInt et4 = .id2(4); + Expect.equals(4, et4.t); +} diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart new file mode 100644 index 0000000000..3d435744f7 --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, 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 Dart semantics, static and dynamic, do not follow the grammar +/// precisely. For example, a static member invocation expression of the form +/// `C.id(e2)` is treated as an atomic entity for type inference (and +/// runtime semantics). It’s not a combination of doing a `C.id` tear-off, then +/// a `` instantiation and then an `(e2)` invocation. The context type of +/// that entire expression is used throughout the inference, where +/// `(e1.id)(e2)` has `(e1.id)` in a position where it has no context +/// type. +/// +/// Because of that, the specification of the static and runtime semantics of +/// the new constructs needs to address all the forms `.id`, `.id`, +/// `.id(args)`, `.id(args)`, `.new` or `.new(args)`. +/// ... +/// The general rule is that any of the expression forms above, starting with +/// `.id`, are treated exactly as if they were prefixed by a fresh identifier +/// `X` which denotes an accessible type alias for the greatest closure of the +/// context type scheme of the following primary and selector chain. +/// +/// @description Checks that expressions of the form `.id`, `.id(args)` and +/// `.id(args)` are treated as if they are prefixed by a fresh +/// identifier `X` which denotes an accessible type alias. Test prefixed +/// import. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +import '../../Utils/expect.dart'; +import 'shorthand_lib.dart' as p; + +main() { + p.C c1 = .id1; + Expect.equals(1, c1.t); + + p.C c2 = .id2("c2"); + Expect.equals("c2", c2.t); + + p.CAlias c3 = .id1; + Expect.equals(1, c3.t); + + p.CInt c4 = .id2(4); + Expect.equals(4, c4.t); + + p.M m1 = M.id1; + Expect.equals(1, m1.t); + + p.M m2 = .id2("m2"); + Expect.equals("m2", m2.t); + + p.MAlias m3 = .id1; + Expect.equals(1, m3.t); + + p.MInt m4 = .id2(4); + Expect.equals(4, m4.t); + + p.E e1 = .id1; + Expect.equals(E.e0, e1); + + p.E e2 = .id2(); + Expect.equals(E.e2, e2); + + p.EInt e3 = .id1; + Expect.equals(1, e3.t); + + p.EAlias e4 = .id2(); + Expect.equals("2", e4.t); + + p.ET et1 = .id1; + Expect.equals(1, et1.t); + + p.ET et2 = .id2("et2"); + Expect.equals("et2", et2.t); + + p.ETAlias et3 = .id1; + Expect.equals(1, et3.t); + + p.ETInt et4 = .id2(4); + Expect.equals(4, et4.t); +} diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart new file mode 100644 index 0000000000..76301295b3 --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart @@ -0,0 +1,114 @@ +// Copyright (c) 2024, 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 Dart semantics, static and dynamic, do not follow the grammar +/// precisely. For example, a static member invocation expression of the form +/// `C.id(e2)` is treated as an atomic entity for type inference (and +/// runtime semantics). It’s not a combination of doing a `C.id` tear-off, then +/// a `` instantiation and then an `(e2)` invocation. The context type of +/// that entire expression is used throughout the inference, where +/// `(e1.id)(e2)` has `(e1.id)` in a position where it has no context +/// type. +/// +/// Because of that, the specification of the static and runtime semantics of +/// the new constructs needs to address all the forms `.id`, `.id`, +/// `.id(args)`, `.id(args)`, `.new` or `.new(args)`. +/// ... +/// The general rule is that any of the expression forms above, starting with +/// `.id`, are treated exactly as if they were prefixed by a fresh identifier +/// `X` which denotes an accessible type alias for the greatest closure of the +/// context type scheme of the following primary and selector chain. +/// +/// @description Checks that expressions of the form `.id` are treated +/// as if they are prefixed by a fresh identifier `X` which denotes an +/// accessible type alias. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +import '../../Utils/expect.dart'; + +class C { + static X id(X x) => x; +} +typedef CAlias = C; + +mixin M { + static X id(X x) => x; +} +typedef MAlias = M; +class MA = Object with M; + +enum E { + e0; + static X id(X x) => x; +} +typedef EAlias = E; + +extension type ET(int _) implements Object { + static X id(X x) => x; +} +typedef ETAlias = ET; + +main() { + Object o = C(); + if (o is C) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = C(); + if (o is CAlias) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = MA(); + if (o is M) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = MA(); + if (o is MAlias) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = E.e0; + if (o is E) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = E.e0; + if (o is EAlias) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = ET(0); + if (o is ET) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = ET(1); + if (o is EAlias) { + o = .id; + if (o is Function) { + Expect.equals(42, o(42)); + } + } +} diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart new file mode 100644 index 0000000000..c81aa15dbd --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart @@ -0,0 +1,93 @@ +// Copyright (c) 2024, 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 Dart semantics, static and dynamic, do not follow the grammar +/// precisely. For example, a static member invocation expression of the form +/// `C.id(e2)` is treated as an atomic entity for type inference (and +/// runtime semantics). It’s not a combination of doing a `C.id` tear-off, then +/// a `` instantiation and then an `(e2)` invocation. The context type of +/// that entire expression is used throughout the inference, where +/// `(e1.id)(e2)` has `(e1.id)` in a position where it has no context +/// type. +/// +/// Because of that, the specification of the static and runtime semantics of +/// the new constructs needs to address all the forms `.id`, `.id`, +/// `.id(args)`, `.id(args)`, `.new` or `.new(args)`. +/// ... +/// The general rule is that any of the expression forms above, starting with +/// `.id`, are treated exactly as if they were prefixed by a fresh identifier +/// `X` which denotes an accessible type alias for the greatest closure of the +/// context type scheme of the following primary and selector chain. +/// +/// @description Checks that expressions of the form `.id` are treated +/// as if they are prefixed by a fresh identifier `X` which denotes an +/// accessible type alias. Test unprefixed import. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +import '../../Utils/expect.dart'; +import 'shorthand_lib.dart'; + +main() { + Object o = C(); + if (o is C) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = C(); + if (o is CAlias) { + o = .id3int>; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = MA(); + if (o is M) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = MA(); + if (o is MAlias) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = E.e0; + if (o is E) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = E.e0; + if (o is EAlias) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = ET(0); + if (o is ET) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = ET(1); + if (o is EAlias) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } +} diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart new file mode 100644 index 0000000000..c134fa5924 --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart @@ -0,0 +1,93 @@ +// Copyright (c) 2024, 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 Dart semantics, static and dynamic, do not follow the grammar +/// precisely. For example, a static member invocation expression of the form +/// `C.id(e2)` is treated as an atomic entity for type inference (and +/// runtime semantics). It’s not a combination of doing a `C.id` tear-off, then +/// a `` instantiation and then an `(e2)` invocation. The context type of +/// that entire expression is used throughout the inference, where +/// `(e1.id)(e2)` has `(e1.id)` in a position where it has no context +/// type. +/// +/// Because of that, the specification of the static and runtime semantics of +/// the new constructs needs to address all the forms `.id`, `.id`, +/// `.id(args)`, `.id(args)`, `.new` or `.new(args)`. +/// ... +/// The general rule is that any of the expression forms above, starting with +/// `.id`, are treated exactly as if they were prefixed by a fresh identifier +/// `X` which denotes an accessible type alias for the greatest closure of the +/// context type scheme of the following primary and selector chain. +/// +/// @description Checks that expressions of the form `.id` are treated +/// as if they are prefixed by a fresh identifier `X` which denotes an +/// accessible type alias. Test prefixed import. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +import '../../Utils/expect.dart'; +import 'shorthand_lib.dart' as p; + +main() { + Object o = p.C(); + if (o is p.C) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = p.C(); + if (o is p.CAlias) { + o = .id3int>; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = p.MA(); + if (o is p.M) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = p.MA(); + if (o is MAlias) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = p.E.e0; + if (o is E) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = p.E.e0; + if (o is p.EAlias) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + + o = p.ET(0); + if (o is p.ET) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } + o = p.ET(1); + if (o is p.EAlias) { + o = .id3; + if (o is Function) { + Expect.equals(42, o(42)); + } + } +} diff --git a/LanguageFeatures/Static-access-shorthand/shorthand_lib.dart b/LanguageFeatures/Static-access-shorthand/shorthand_lib.dart new file mode 100644 index 0000000000..86900ab2d9 --- /dev/null +++ b/LanguageFeatures/Static-access-shorthand/shorthand_lib.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2024, 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 Common library for static access shorthand tests. +/// +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enum-shorthands + +class C { + T t; + C(this.t); + + static C get id1 => C(1); + static C id2(X x) => C(x); + static X id3(X x) => x; +} + +typedef CAlias = C; +typedef CInt = C; + +mixin M on C { + static M get id1 => MC(1); + static M id2(X x) => MC(x); + static X id3(X x) => x; +} + +class MC = C with M; + +typedef MAlias = M; +typedef MInt = M; + +enum E { + e1(1), e2("2"); + final T t; + const E(this.t); + + static E get id1 => E.e1; + static E id2() => E.e2; + static X id3(X x) => x; +} + +typedef EAlias = E; +typedef EInt = E; + +extension type ET(T t) { + static ET get id1 => ET(1); + static ET id2(X x) => ET(x); + static X id3(X x) => x; +} + +typedef ETAlias = ET; +typedef ETInt = ET; From ad85162454aaaa03ee4510337ccc05048884ba37 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 26 Nov 2024 18:29:09 +0200 Subject: [PATCH 02/11] Fix typo --- LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart index c81aa15dbd..6c35836fba 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart @@ -40,7 +40,7 @@ main() { } o = C(); if (o is CAlias) { - o = .id3int>; + o = .id3; if (o is Function) { Expect.equals(42, o(42)); } From 8a234de2d54c0725e40a218f2acf78e175d8d585 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 26 Nov 2024 18:31:35 +0200 Subject: [PATCH 03/11] Fix a typo 2 --- LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart index c134fa5924..14c6568ce5 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart @@ -40,7 +40,7 @@ main() { } o = p.C(); if (o is p.CAlias) { - o = .id3int>; + o = .id3; if (o is Function) { Expect.equals(42, o(42)); } From 12031458d5474fb05a107ed13fff1f22108bece5 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Wed, 27 Nov 2024 11:31:03 +0200 Subject: [PATCH 04/11] Fix some typos --- LanguageFeatures/Static-access-shorthand/grammar_A01_t03.dart | 2 +- LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart | 2 +- LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart | 2 +- LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LanguageFeatures/Static-access-shorthand/grammar_A01_t03.dart b/LanguageFeatures/Static-access-shorthand/grammar_A01_t03.dart index 19ac762638..c0dcfc954d 100644 --- a/LanguageFeatures/Static-access-shorthand/grammar_A01_t03.dart +++ b/LanguageFeatures/Static-access-shorthand/grammar_A01_t03.dart @@ -43,6 +43,6 @@ main() { E e2 = .staticMethod(); Expect.equals("v2", e2.value); - E e3 = E.values[1]; + E e3 = .values[1]; Expect.equals(E.v2, e3); } diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart index 3e6ea32b7b..c678b2cdea 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart @@ -83,7 +83,7 @@ main() { CInt c4 = .id2(4); Expect.equals(4, c4.t); - M m1 = M.id1; + M m1 = .id1; Expect.equals(1, m1.t); M m2 = .id2("m2"); diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart index fda58ea51e..da304ddfcc 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart @@ -44,7 +44,7 @@ main() { CInt c4 = .id2(4); Expect.equals(4, c4.t); - M m1 = M.id1; + M m1 = .id1; Expect.equals(1, m1.t); M m2 = .id2("m2"); diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart index 3d435744f7..bca1fb522d 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart @@ -44,7 +44,7 @@ main() { p.CInt c4 = .id2(4); Expect.equals(4, c4.t); - p.M m1 = M.id1; + p.M m1 = .id1; Expect.equals(1, m1.t); p.M m2 = .id2("m2"); From 3597dba3007e3251389ae6a412d662536197c801 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Thu, 28 Nov 2024 11:15:18 +0200 Subject: [PATCH 05/11] Update descriptions, remove non-aliases checks --- .../semantics_A01_t01.dart | 56 ++++++------------ .../semantics_A01_t02.dart | 57 ++++++------------- .../semantics_A01_t03.dart | 57 ++++++------------- .../semantics_A01_t04.dart | 5 +- .../semantics_A01_t05.dart | 6 +- .../semantics_A01_t06.dart | 10 ++-- 6 files changed, 58 insertions(+), 133 deletions(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart index c678b2cdea..a237b05dae 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart @@ -20,9 +20,9 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that expressions of the form `.id`, `.id(args)` and -/// `.id(args)` are treated as if they are prefixed by a fresh -/// identifier `X` which denotes an accessible type alias. +/// @description Checks that the processing of the context type for shorthand +/// of the forms `.id`, `.id(args)` and `.id(args)` includes a type +/// alias expansion. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=enum-shorthands @@ -71,51 +71,27 @@ typedef ETAlias = ET; typedef ETInt = ET; main() { - C c1 = .id1; + CAlias c1 = .id1; Expect.equals(1, c1.t); - C c2 = .id2("c2"); - Expect.equals("c2", c2.t); + CInt c2 = .id2(2); + Expect.equals(2, c2.t); - CAlias c3 = .id1; - Expect.equals(1, c3.t); - - CInt c4 = .id2(4); - Expect.equals(4, c4.t); - - M m1 = .id1; + MAlias m1 = .id1; Expect.equals(1, m1.t); - M m2 = .id2("m2"); - Expect.equals("m2", m2.t); - - MAlias m3 = .id1; - Expect.equals(1, m3.t); - - MInt m4 = .id2(4); - Expect.equals(4, m4.t); + MInt m2 = .id2(2); + Expect.equals(2, m2.t); - E e1 = .id1; - Expect.equals(E.e0, e1); + EInt e1 = .id1; + Expect.equals(1, e1.t); - E e2 = .id2(); - Expect.equals(E.e2, e2); + EAlias e2 = .id2(); + Expect.equals("2", e2.t); - EInt e3 = .id1; - Expect.equals(1, e3.t); - - EAlias e4 = .id2(); - Expect.equals("2", e4.t); - - ET et1 = .id1; + ETAlias et1 = .id1; Expect.equals(1, et1.t); - ET et2 = .id2("et2"); - Expect.equals("et2", et2.t); - - ETAlias et3 = .id1; - Expect.equals(1, et3.t); - - ETInt et4 = .id2(4); - Expect.equals(4, et4.t); + ETInt et2 = .id2(2); + Expect.equals(2, et2.t); } diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart index da304ddfcc..b85e9739c8 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart @@ -20,10 +20,9 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that expressions of the form `.id`, `.id(args)` and -/// `.id(args)` are treated as if they are prefixed by a fresh -/// identifier `X` which denotes an accessible type alias. Test unprefixed -/// import. +/// @description Checks that the processing of the context type for shorthand +/// of the forms `.id`, `.id(args)` and `.id(args)` includes a type +/// alias expansion. Test unprefixed import. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=enum-shorthands @@ -32,51 +31,27 @@ import '../../Utils/expect.dart'; import 'shorthand_lib.dart'; main() { - C c1 = .id1; + CAlias c1 = .id1; Expect.equals(1, c1.t); - C c2 = .id2("c2"); - Expect.equals("c2", c2.t); + CInt c2 = .id2(2); + Expect.equals(2, c2.t); - CAlias c3 = .id1; - Expect.equals(1, c3.t); - - CInt c4 = .id2(4); - Expect.equals(4, c4.t); - - M m1 = .id1; + MAlias m1 = .id1; Expect.equals(1, m1.t); - M m2 = .id2("m2"); - Expect.equals("m2", m2.t); - - MAlias m3 = .id1; - Expect.equals(1, m3.t); - - MInt m4 = .id2(4); - Expect.equals(4, m4.t); + MInt m2 = .id2(2); + Expect.equals(2, m2.t); - E e1 = .id1; - Expect.equals(E.e0, e1); + EInt e1 = .id1; + Expect.equals(1, e1.t); - E e2 = .id2(); - Expect.equals(E.e2, e2); + EAlias e2 = .id2(); + Expect.equals("2", e2.t); - EInt e3 = .id1; - Expect.equals(1, e3.t); - - EAlias e4 = .id2(); - Expect.equals("2", e4.t); - - ET et1 = .id1; + ETAlias et1 = .id1; Expect.equals(1, et1.t); - ET et2 = .id2("et2"); - Expect.equals("et2", et2.t); - - ETAlias et3 = .id1; - Expect.equals(1, et3.t); - - ETInt et4 = .id2(4); - Expect.equals(4, et4.t); + ETInt et2 = .id2(2); + Expect.equals(2, et2.t); } diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart index bca1fb522d..01ad825c51 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart @@ -20,10 +20,9 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that expressions of the form `.id`, `.id(args)` and -/// `.id(args)` are treated as if they are prefixed by a fresh -/// identifier `X` which denotes an accessible type alias. Test prefixed -/// import. +/// @description Checks that the processing of the context type for shorthand +/// of the forms `.id`, `.id(args)` and `.id(args)` includes a type +/// alias expansion. Test prefixed import. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=enum-shorthands @@ -32,51 +31,27 @@ import '../../Utils/expect.dart'; import 'shorthand_lib.dart' as p; main() { - p.C c1 = .id1; + p.CAlias c1 = .id1; Expect.equals(1, c1.t); - p.C c2 = .id2("c2"); - Expect.equals("c2", c2.t); + p.CInt c2 = .id2(2); + Expect.equals(2, c2.t); - p.CAlias c3 = .id1; - Expect.equals(1, c3.t); - - p.CInt c4 = .id2(4); - Expect.equals(4, c4.t); - - p.M m1 = .id1; + p.MAlias m1 = .id1; Expect.equals(1, m1.t); - p.M m2 = .id2("m2"); - Expect.equals("m2", m2.t); - - p.MAlias m3 = .id1; - Expect.equals(1, m3.t); - - p.MInt m4 = .id2(4); - Expect.equals(4, m4.t); + p.MInt m2 = .id2(2); + Expect.equals(2, m2.t); - p.E e1 = .id1; - Expect.equals(E.e0, e1); + p.EInt e1 = .id1; + Expect.equals(1, e1.t); - p.E e2 = .id2(); - Expect.equals(E.e2, e2); + p.EAlias e2 = .id2(); + Expect.equals("2", e2.t); - p.EInt e3 = .id1; - Expect.equals(1, e3.t); - - p.EAlias e4 = .id2(); - Expect.equals("2", e4.t); - - p.ET et1 = .id1; + p.ETAlias et1 = .id1; Expect.equals(1, et1.t); - p.ET et2 = .id2("et2"); - Expect.equals("et2", et2.t); - - p.ETAlias et3 = .id1; - Expect.equals(1, et3.t); - - p.ETInt et4 = .id2(4); - Expect.equals(4, et4.t); + p.ETInt et2 = .id2(2); + Expect.equals(2, et2.t); } diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart index 76301295b3..843cf0a1ee 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart @@ -20,9 +20,8 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that expressions of the form `.id` are treated -/// as if they are prefixed by a fresh identifier `X` which denotes an -/// accessible type alias. +/// @description Checks that the processing of the context type for shorthand +/// of the form `.id` includes a type alias expansion. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=enum-shorthands diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart index 6c35836fba..1cdbfee638 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart @@ -20,9 +20,9 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that expressions of the form `.id` are treated -/// as if they are prefixed by a fresh identifier `X` which denotes an -/// accessible type alias. Test unprefixed import. +/// @description Checks that the processing of the context type for shorthand +/// of the form `.id` includes a type alias expansion. Test unprefixed +/// import. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=enum-shorthands diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart index 14c6568ce5..5331d723d6 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart @@ -20,9 +20,9 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that expressions of the form `.id` are treated -/// as if they are prefixed by a fresh identifier `X` which denotes an -/// accessible type alias. Test prefixed import. +/// @description Checks that the processing of the context type for shorthand +/// of the form `.id` includes a type alias expansion. Test prefixed +/// import. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=enum-shorthands @@ -54,7 +54,7 @@ main() { } } o = p.MA(); - if (o is MAlias) { + if (o is p.MAlias) { o = .id3; if (o is Function) { Expect.equals(42, o(42)); @@ -62,7 +62,7 @@ main() { } o = p.E.e0; - if (o is E) { + if (o is p.E) { o = .id3; if (o is Function) { Expect.equals(42, o(42)); From 8623da33dd1aad1c26a6eba3724542b06420aded Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 28 Nov 2024 10:26:07 +0100 Subject: [PATCH 06/11] Update semantics_A01_t01.dart Spurious space --- LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart index a237b05dae..0bae665242 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t01.dart @@ -20,7 +20,7 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that the processing of the context type for shorthand +/// @description Checks that the processing of the context type for shorthand /// of the forms `.id`, `.id(args)` and `.id(args)` includes a type /// alias expansion. /// @author sgrekhov22@gmail.com From 6041c658abdd9e3f806728c311f508eeae03930c Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 28 Nov 2024 10:27:08 +0100 Subject: [PATCH 07/11] Update semantics_A01_t02.dart --- LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart index b85e9739c8..a8dbf543c3 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t02.dart @@ -20,7 +20,7 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that the processing of the context type for shorthand +/// @description Checks that the processing of the context type for shorthand /// of the forms `.id`, `.id(args)` and `.id(args)` includes a type /// alias expansion. Test unprefixed import. /// @author sgrekhov22@gmail.com From 5d9060996183da86d8bdc47b1cf65e8d0c0d1309 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 28 Nov 2024 10:27:28 +0100 Subject: [PATCH 08/11] Update semantics_A01_t03.dart --- LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart index 01ad825c51..60eaa9b542 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t03.dart @@ -20,7 +20,7 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that the processing of the context type for shorthand +/// @description Checks that the processing of the context type for shorthand /// of the forms `.id`, `.id(args)` and `.id(args)` includes a type /// alias expansion. Test prefixed import. /// @author sgrekhov22@gmail.com From 5de5a77fc2276c8a913a2dabbf046fa6097acf23 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 28 Nov 2024 10:27:50 +0100 Subject: [PATCH 09/11] Update semantics_A01_t04.dart --- LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart index 843cf0a1ee..58a0209655 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t04.dart @@ -20,7 +20,7 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that the processing of the context type for shorthand +/// @description Checks that the processing of the context type for shorthand /// of the form `.id` includes a type alias expansion. /// @author sgrekhov22@gmail.com From 891475b92bcd51d273a044f04b9e9008fa3f6bc5 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 28 Nov 2024 10:28:11 +0100 Subject: [PATCH 10/11] Update semantics_A01_t05.dart --- LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart index 1cdbfee638..b8eb764880 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t05.dart @@ -20,7 +20,7 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that the processing of the context type for shorthand +/// @description Checks that the processing of the context type for shorthand /// of the form `.id` includes a type alias expansion. Test unprefixed /// import. /// @author sgrekhov22@gmail.com From 138bdcf36591a8acaa995b2497b7b653a4da8432 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 28 Nov 2024 10:28:33 +0100 Subject: [PATCH 11/11] Update semantics_A01_t06.dart --- LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart index 5331d723d6..ac5fa05f6d 100644 --- a/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart +++ b/LanguageFeatures/Static-access-shorthand/semantics_A01_t06.dart @@ -20,7 +20,7 @@ /// `X` which denotes an accessible type alias for the greatest closure of the /// context type scheme of the following primary and selector chain. /// -/// @description Checks that the processing of the context type for shorthand +/// @description Checks that the processing of the context type for shorthand /// of the form `.id` includes a type alias expansion. Test prefixed /// import. /// @author sgrekhov22@gmail.com