13af6ab5fSopenharmony_ci/*
23af6ab5fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License.
53af6ab5fSopenharmony_ci * You may obtain a copy of the License at
63af6ab5fSopenharmony_ci *
73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
83af6ab5fSopenharmony_ci *
93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and
133af6ab5fSopenharmony_ci * limitations under the License.
143af6ab5fSopenharmony_ci */
153af6ab5fSopenharmony_ci
163af6ab5fSopenharmony_ciimport { 
173af6ab5fSopenharmony_ci  sendableClassA,
183af6ab5fSopenharmony_ci  sendableVar,
193af6ab5fSopenharmony_ci  nonSendableClassB,
203af6ab5fSopenharmony_ci  nonSendableVar,
213af6ab5fSopenharmony_ci  sendableInterface,
223af6ab5fSopenharmony_ci  nonSendableInterface,
233af6ab5fSopenharmony_ci  lang,
243af6ab5fSopenharmony_ci} from './@arkts.lang';
253af6ab5fSopenharmony_ci
263af6ab5fSopenharmony_ci// sendable class
273af6ab5fSopenharmony_ci@Sendable
283af6ab5fSopenharmony_ciclass localSendableClassA {}
293af6ab5fSopenharmony_ci
303af6ab5fSopenharmony_ci// sendable class var
313af6ab5fSopenharmony_cilet localSendableVar = localSendableClassA
323af6ab5fSopenharmony_ci
333af6ab5fSopenharmony_ci
343af6ab5fSopenharmony_ci// non-sendable class
353af6ab5fSopenharmony_ciclass localNonSendableClassB {}
363af6ab5fSopenharmony_ci
373af6ab5fSopenharmony_ci// non-sendable class var
383af6ab5fSopenharmony_cilet localNonSendableVar = localNonSendableClassB
393af6ab5fSopenharmony_ci
403af6ab5fSopenharmony_ci// sendable interface
413af6ab5fSopenharmony_ciinterface localSendableInterface extends lang.ISendable {}
423af6ab5fSopenharmony_ci
433af6ab5fSopenharmony_ci// non-sendable interface
443af6ab5fSopenharmony_ciinterface localNonSendableInterface {}
453af6ab5fSopenharmony_ci
463af6ab5fSopenharmony_ci// sendable interface type alias
473af6ab5fSopenharmony_citype localSendableInterfaceAlias = localSendableInterface
483af6ab5fSopenharmony_ci
493af6ab5fSopenharmony_ci// non-sendable interface type alias
503af6ab5fSopenharmony_citype localNonSendableInterfaceAlias = localNonSendableInterface
513af6ab5fSopenharmony_ci
523af6ab5fSopenharmony_ci// left: sendable class
533af6ab5fSopenharmony_ci
543af6ab5fSopenharmony_ci// class + class
553af6ab5fSopenharmony_ci
563af6ab5fSopenharmony_ci// case1: extends import var
573af6ab5fSopenharmony_ci// == case1.1: extends sendable
583af6ab5fSopenharmony_ci@Sendable
593af6ab5fSopenharmony_ciclass sendableClass1 extends sendableVar {} // ERROR
603af6ab5fSopenharmony_ci
613af6ab5fSopenharmony_ci// == case1.2: extends non-sendable
623af6ab5fSopenharmony_ci@Sendable
633af6ab5fSopenharmony_ciclass sendableClass2 extends nonSendableVar {} // ERROR
643af6ab5fSopenharmony_ci
653af6ab5fSopenharmony_ci// case2: extends local var
663af6ab5fSopenharmony_ci// == case2.1: extends sendable
673af6ab5fSopenharmony_ci@Sendable
683af6ab5fSopenharmony_ciclass sendableClass3 extends localSendableVar {} // ERROR
693af6ab5fSopenharmony_ci
703af6ab5fSopenharmony_ci// == case2.2: extends non-sendable
713af6ab5fSopenharmony_ci@Sendable
723af6ab5fSopenharmony_ciclass sendableClass4 extends localNonSendableVar {} // ERROR
733af6ab5fSopenharmony_ci
743af6ab5fSopenharmony_ci// case3: extends import class
753af6ab5fSopenharmony_ci// == case3.1: extends sendable
763af6ab5fSopenharmony_ci@Sendable
773af6ab5fSopenharmony_ciclass sendableClass5 extends sendableClassA {} // OK
783af6ab5fSopenharmony_ci
793af6ab5fSopenharmony_ci// == case3.2: extends non-sendable
803af6ab5fSopenharmony_ci@Sendable
813af6ab5fSopenharmony_ciclass sendableClass6 extends nonSendableClassB {} // ERROR
823af6ab5fSopenharmony_ci
833af6ab5fSopenharmony_ci// case4: extends local class
843af6ab5fSopenharmony_ci// == case4.1: extends sendable
853af6ab5fSopenharmony_ci@Sendable
863af6ab5fSopenharmony_ciclass sendableClass7 extends localSendableClassA {} // OK
873af6ab5fSopenharmony_ci
883af6ab5fSopenharmony_ci// == case4.2: extends non-sendable
893af6ab5fSopenharmony_ci@Sendable
903af6ab5fSopenharmony_ciclass sendableClass8 extends localNonSendableClassB {} // ERROR
913af6ab5fSopenharmony_ci
923af6ab5fSopenharmony_ci// class + interface
933af6ab5fSopenharmony_ci
943af6ab5fSopenharmony_ci// case1: implements local interface
953af6ab5fSopenharmony_ci// == case1.1: implements sendable
963af6ab5fSopenharmony_ci@Sendable
973af6ab5fSopenharmony_ciclass sendableClass9 implements localSendableInterface {} // OK
983af6ab5fSopenharmony_ci
993af6ab5fSopenharmony_ci// == case1.2: implements non-sendable
1003af6ab5fSopenharmony_ci@Sendable
1013af6ab5fSopenharmony_ciclass sendableClass10 implements localNonSendableInterface {} // OK
1023af6ab5fSopenharmony_ci
1033af6ab5fSopenharmony_ci// case2: implements import interface
1043af6ab5fSopenharmony_ci// == case2.1: implements sendable
1053af6ab5fSopenharmony_ci@Sendable
1063af6ab5fSopenharmony_ciclass sendableClass11 implements sendableInterface {} // OK
1073af6ab5fSopenharmony_ci
1083af6ab5fSopenharmony_ci// == case2.2: implements non-sendable
1093af6ab5fSopenharmony_ci@Sendable
1103af6ab5fSopenharmony_ciclass sendableClass12 implements nonSendableInterface {} // OK
1113af6ab5fSopenharmony_ci
1123af6ab5fSopenharmony_ci// case3: implements type alias
1133af6ab5fSopenharmony_ci// == case3.1: implements sendable
1143af6ab5fSopenharmony_ci@Sendable
1153af6ab5fSopenharmony_ciclass sendableClass13 implements localSendableInterfaceAlias {} // OK
1163af6ab5fSopenharmony_ci
1173af6ab5fSopenharmony_ci// == case3.2: implements non-sendable
1183af6ab5fSopenharmony_ci@Sendable
1193af6ab5fSopenharmony_ciclass sendableClass14 implements localNonSendableInterfaceAlias {} // OK
1203af6ab5fSopenharmony_ci
1213af6ab5fSopenharmony_ci// left: non sendable class
1223af6ab5fSopenharmony_ci
1233af6ab5fSopenharmony_ci// case1: extends import var
1243af6ab5fSopenharmony_ci// == case1.1: extends sendable
1253af6ab5fSopenharmony_ciclass sendableClass15 extends sendableVar {} // ERROR
1263af6ab5fSopenharmony_ci
1273af6ab5fSopenharmony_ci// == case1.2: extends non-sendable
1283af6ab5fSopenharmony_ciclass sendableClass16 extends nonSendableVar {} // OK
1293af6ab5fSopenharmony_ci
1303af6ab5fSopenharmony_ci// case2: extends local var
1313af6ab5fSopenharmony_ci// == case2.1: extends sendable
1323af6ab5fSopenharmony_ciclass sendableClass17 extends localSendableVar {} // ERROR
1333af6ab5fSopenharmony_ci
1343af6ab5fSopenharmony_ci// == case2.2: extends non-sendable
1353af6ab5fSopenharmony_ciclass sendableClass18 extends localNonSendableVar {} // OK
1363af6ab5fSopenharmony_ci
1373af6ab5fSopenharmony_ci// case3: extends import class
1383af6ab5fSopenharmony_ci// == case3.1: extends sendable
1393af6ab5fSopenharmony_ciclass sendableClass19 extends sendableClassA {} // ERROR
1403af6ab5fSopenharmony_ci
1413af6ab5fSopenharmony_ci// == case3.2: extends non-sendable
1423af6ab5fSopenharmony_ciclass sendableClass20 extends nonSendableClassB {} // OK
1433af6ab5fSopenharmony_ci
1443af6ab5fSopenharmony_ci// case4: extends local class
1453af6ab5fSopenharmony_ci// == case4.1: extends sendable
1463af6ab5fSopenharmony_ciclass sendableClass21 extends localSendableClassA {} // ERROR
1473af6ab5fSopenharmony_ci
1483af6ab5fSopenharmony_ci// == case4.2: extends non-sendable
1493af6ab5fSopenharmony_ciclass sendableClass22 extends localNonSendableClassB {} // OK
1503af6ab5fSopenharmony_ci
1513af6ab5fSopenharmony_ci// class + interface
1523af6ab5fSopenharmony_ci
1533af6ab5fSopenharmony_ci// case1: implements local interface
1543af6ab5fSopenharmony_ci// == case1.1: implements sendable
1553af6ab5fSopenharmony_ciclass sendableClass23 implements localSendableInterface {} // ERROR
1563af6ab5fSopenharmony_ci
1573af6ab5fSopenharmony_ci// == case1.2: implements non-sendable
1583af6ab5fSopenharmony_ciclass sendableClass24 implements localNonSendableInterface {} // OK
1593af6ab5fSopenharmony_ci
1603af6ab5fSopenharmony_ci// case2: implements import interface
1613af6ab5fSopenharmony_ci// == case2.1: implements sendable
1623af6ab5fSopenharmony_ciclass sendableClass25 implements sendableInterface {} // ERROR
1633af6ab5fSopenharmony_ci
1643af6ab5fSopenharmony_ci// == case2.2: implements non-sendable
1653af6ab5fSopenharmony_ciclass sendableClass26 implements nonSendableInterface {} // OK
1663af6ab5fSopenharmony_ci
1673af6ab5fSopenharmony_ci// case3: implements type alias
1683af6ab5fSopenharmony_ci// == case4.1: implements sendable
1693af6ab5fSopenharmony_ciclass sendableClass27 implements localSendableInterfaceAlias {} // ERROR
1703af6ab5fSopenharmony_ci
1713af6ab5fSopenharmony_ci// == case4.2: implements non-sendable
1723af6ab5fSopenharmony_ciclass sendableClass28 implements localNonSendableInterfaceAlias {} // OK
1733af6ab5fSopenharmony_ci
1743af6ab5fSopenharmony_ci// ISendable created by developer is not a sendable interface
1753af6ab5fSopenharmony_ci
1763af6ab5fSopenharmony_ciinterface ISendable {}
1773af6ab5fSopenharmony_ci
1783af6ab5fSopenharmony_ciinterface fakeSendableInterface extends ISendable {}
1793af6ab5fSopenharmony_ci
1803af6ab5fSopenharmony_ci// fake sendable interface type alias
1813af6ab5fSopenharmony_citype fakeSendableInterfaceAlias = fakeSendableInterface
1823af6ab5fSopenharmony_ci
1833af6ab5fSopenharmony_ciclass sendableClass29 implements fakeSendableInterface {} // OK
1843af6ab5fSopenharmony_ci
1853af6ab5fSopenharmony_ciclass sendableClass30 implements fakeSendableInterfaceAlias {} // OK