1/*
2 * Copyright (c) 2024 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
16import {lang} from './@arkts.lang';
17import {II as III} from "./shared_module_sendable_export";
18'use shared'
19
20export const enum A{a, b} // ok, const enum is sendable type
21export enum B{a, b} // error, enum is not sendable type
22export let var1: number | A; // ok, union type of const enum and number
23export let var2: A.a; // error, enum member is not sendable type
24
25export class C{} // error, class is not sendable type
26@Sendable
27export class D{} // ok, sendable class is sendable type
28export let var3: A | C; //error
29
30export interface E{} // error, interface is not sendable type
31export interface F extends lang.ISendable{} // ok, interface extends ISendable is sendable type; 
32type ff = F;
33type ee = E;
34export {ff}; // ok
35export {ee}; // error
36let var4: C | ee;
37let var5: D | ff;
38export {var4}; // error
39export {var5}; // ok
40
41export * as ns from './shared_module_sendable_export'; // err,  ns is not sendable type
42export * from './shared_module_unsendable_export'; // error, 'export * from ...' is not supported
43export default III; // ok
44export {a} from './shared_module_sendable_export'; // ok
45export {a as aa} from './shared_module_unsendable_export'; // error
46export let var6: A | A.a; // error, union type of sendable and unsendbale
47export let var7: string | B = 'aaa'; // error , union type of sendable and unsendbale
48export let var8 = var7; // ok, no explicit type, the inferred type of var8 is string
49namespace ns {
50    export class A{}  // ok, exports from namespace are not checked 
51}
52
53function foo(): boolean {
54    return true;
55}
56
57export {foo};
58
59@Sendable
60export function sf():void {
61}
62
63@Sendable
64function sf2():void {
65}
66
67export {sf2};
68
69export const primitive_str = 'a'; // OK
70export const primitive_num = 1; // OK
71export const primitive_bool = true; // OK
72export const primitive_big = 1n; // OK
73
74export enum NormalEnum { // ERROR,
75  a,
76  b,
77  c,
78  d
79}
80
81export const enum ConstEnum { // OK
82  a,
83  b,
84  c,
85  d
86}
87
88export const unite1 = // ERROR
89  Math.random() < 0.5
90    ? NormalEnum.a
91    : primitive_str;
92
93export const unite2 = Math.random() < 0.5 ? primitive_str : primitive_big; // OK
94
95export {
96  primitive_str as strAlias,
97  primitive_num as numAlias,
98  primitive_bool as boolAlias,
99  primitive_big as bigAlias,
100  NormalEnum as NormalEnumAlas // ERROR
101};
102
103export type TypeC = C; // ERROR
104export type TypeE = E; // ERROR
105