From b13cbc7a9a0377c0260a618edf0318ef1e49819b Mon Sep 17 00:00:00 2001 From: "Sergey G. Grekhov" Date: Mon, 22 Jan 2024 23:01:53 +0200 Subject: [PATCH] #2485. Add more constant evaluation tests for record types (#2499) --- Language/Expressions/Constants/as_type_A01_t01.dart | 4 ++++ Language/Expressions/Constants/as_type_A01_t03.dart | 9 +++++++++ Language/Expressions/Constants/as_type_A02_t02.dart | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/Language/Expressions/Constants/as_type_A01_t01.dart b/Language/Expressions/Constants/as_type_A01_t01.dart index 673da55868..727138fef7 100644 --- a/Language/Expressions/Constants/as_type_A01_t01.dart +++ b/Language/Expressions/Constants/as_type_A01_t01.dart @@ -48,6 +48,8 @@ main() { const c18 = IntET2(1) as IntET1; const c19 = C() as Object; const c20 = const C() as Object; + const c21 = () as (); + const c22 = (i: 1) as ({num i}); Expect.identical(1, c1); Expect.identical(3.14, c2); @@ -69,4 +71,6 @@ main() { Expect.identical(1, c18); Expect.identical(const C(), c19); Expect.identical(const C(), c20); + Expect.identical((), c21); + Expect.identical((i: 1), c22); } diff --git a/Language/Expressions/Constants/as_type_A01_t03.dart b/Language/Expressions/Constants/as_type_A01_t03.dart index 6c25ee9b6f..304d22561d 100644 --- a/Language/Expressions/Constants/as_type_A01_t03.dart +++ b/Language/Expressions/Constants/as_type_A01_t03.dart @@ -26,6 +26,7 @@ /// expression if `T` is a constant type expression of type `FutureOr` or /// an extension type with a representation type `void` /// @author sgrekhov22@gmail.com +/// @issue 54620 // SharedOptions=--enable-experiment=inline-class @@ -37,7 +38,15 @@ extension type const VoidET(void _) {} main() { const c1 = 1 as VoidET; const c2 = 2 as FutureOr; + const c3 = (3,) as (VoidET,); + const c4 = (4,) as (FutureOr,); + const c5 = (i: 5) as ({VoidET i}); + const c6 = (i: 6) as ({FutureOr i}); Expect.identical(1, c1); Expect.identical(2, c2); + Expect.identical((3,), c3); + Expect.identical((4,), c4); + Expect.identical((i: 5), c5); + Expect.identical((i: 6), c6); } diff --git a/Language/Expressions/Constants/as_type_A02_t02.dart b/Language/Expressions/Constants/as_type_A02_t02.dart index 6870dba035..11c9b96b2b 100644 --- a/Language/Expressions/Constants/as_type_A02_t02.dart +++ b/Language/Expressions/Constants/as_type_A02_t02.dart @@ -33,4 +33,14 @@ main() { // ^^^^^ // [analyzer] unspecified // [cfe] unspecified + const R1 = (void,) as Type; +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const R2 = ({int i}) as Type; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + }