• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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 */
15import { X } from "./oh_modules/reflect_export"
16
17export function foo(prx: Object) {
18 Reflect.get(prx, 'a')  // 'hello'
19 Reflect.set(prx, 'a', 'world')  // true
20 Reflect.ownKeys(prx)  // ['a']
21}
22
23export function bar(obj: Object) {
24    return Reflect.has(obj, 'prop');
25}
26
27foo(new X()); //illegal
28
29bar(new X()); //illegal
30
31import {Reflect1} from "./oh_modules/reflect_export"
32import {obj_Reflect1} from "./oh_modules/reflect_export"
33import {objInter} from "./oh_modules/reflect_export"
34
35function reflect_method2(prx: Object) {
36    Reflect.get(prx, 'a')  // 'hello'
37    Reflect.set(prx, 'a', 'world')  // true
38    Reflect.ownKeys(prx)  // ['a']
39}
40
41reflect_method2(new Reflect1());
42Reflect.get(new Reflect1(), 'a')
43Reflect.set(new Reflect1(), 'a', 'world')
44Reflect.ownKeys(new Reflect1())
45let obj = new Reflect1()
46reflect_method2(obj);
47Reflect.get(obj, 'a')
48Reflect.set(obj, 'a', 'world')
49Reflect.ownKeys(obj)
50
51reflect_method2(obj_Reflect1);
52Reflect.get(obj_Reflect1, 'a')
53Reflect.set(obj_Reflect1, 'a', 'world')
54Reflect.ownKeys(obj_Reflect1)
55
56reflect_method2(objInter);
57Reflect.get(objInter, 'a')
58Reflect.set(objInter, 'a', 'world')
59Reflect.ownKeys(objInter)
60
61