1/* 2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16class C0 { 17 x0: boolean 18} 19 20function test1() : C0 { 21 return ([{x0: true}])[0] 22} 23 24function test2() : C0 { 25 return (([[{x0: true}]])[0])[0]; 26} 27 28function test3() { 29 let x0: C0 = ([{x0: true}])[0]; 30 if (false) { 31 return x0; 32 } 33 34 // Expecting type to be inferred from the other return expression 35 return ([{x0: true}])[0]; 36} 37 38function testParameter(x : C0) { 39} 40 41function main() : void { 42 let x0: C0 = ([{x0: true}])[0]; 43 arktest.assertTrue(x0.x0, 'Incorrect class composite property #1!'); 44 45 let x1: C0 = (([[{x0: true}]])[0])[0]; 46 arktest.assertTrue(x1.x0, 'Incorrect class composite property #2!'); 47 48 let x2: C0 = ((([[[{x0: true}]]])[0])[0])[0]; 49 arktest.assertTrue(x2.x0, 'Incorrect class composite property #3!'); 50 51 let f1: C0 = test1(); 52 arktest.assertTrue(f1.x0, 'Incorrect class composite property #4!'); 53 54 let f2: C0 = test2(); 55 arktest.assertTrue(f2.x0, 'Incorrect class composite property #5!'); 56 57 let f3: C0 = test3(); 58 arktest.assertTrue(f3.x0, 'Incorrect class composite property #6!'); 59 60 testParameter(([{x0: true}])[0]); 61 testParameter((([[{x0: true}]])[0])[0]); 62} 63