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 16let arg='2'; 17let v:null|int=null; 18class A{ 19 20} 21let a:A = new A(); 22switch (arg){ 23 case '0': 24 case '1': 25 case '2': 26 break; 27 case '2': 28 break; 29 case '2': 30 break; 31 case 2: 32 break; 33 case v: 34 break; 35 case A: 36 break; 37} 38 39/* @@? 31:10 Error TypeError: Switch case type 'int' is not comparable to discriminant type 'String' */ 40/* @@? 33:10 Error TypeError: Switch case type 'null|Int' is not comparable to discriminant type 'String' */ 41/* @@? 35:10 Error TypeError: Class name "A" used in the wrong context */ 42/* @@? 35:10 Error TypeError: Switch case type 'A' is not comparable to discriminant type 'String' */ 43/* @@? 33:5 Error TypeError: Constant expression required */ 44/* @@? 35:5 Error TypeError: Constant expression required */ 45/* @@? 27:5 Error TypeError: Case duplicate */ 46/* @@? 29:5 Error TypeError: Case duplicate */ 47/* @@? 31:5 Error TypeError: Case duplicate */ 48