• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024-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
16// Annotation declaration:
17@Retention("SOURCE")
18@interface Anno {
19    name: string = "Jim"
20    id: int = 1
21}
22
23@Retention("SOURCE")
24@interface Anno2 {
25    name: string
26}
27
28function foo1(@Anno x : int, @Anno2({name: "name1"}) y : int) {
29}
30function foo2(@Anno() x : int, @Anno2({name: "name2"}) y : int) {
31}
32function foo3(@Anno({}) x : int, @Anno2({name: "name3"}) y : int) {
33}
34function foo4(@Anno({}) x: int, @Anno2({name: "name3"}) ...y : int[]) {
35}
36function foo5(@Anno({}) x: int, @Anno2({name: "name3"}) y ?: int) {
37}
38function foo6(@Anno() @Anno2({name: "name4"}) x : int, @Anno @Anno2({name: "name4"}) y : int) {
39}
40
41function main() {
42    foo1(1, 2)
43    foo2(3, 4)
44    foo3(5, 6)
45    foo4(7, 8)
46    foo5(9, 10)
47    foo6(11, 12)
48}
49