1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 public class Main { 18 19 /// CHECK-START: java.lang.Object Main.InlineNullConstant() inliner (before) 20 /// CHECK: NullConstant 21 /// CHECK-NOT: NullConstant 22 23 /// CHECK-START: java.lang.Object Main.InlineNullConstant() inliner (after) 24 /// CHECK: NullConstant 25 /// CHECK-NOT: NullConstant 26 returnNullConstant(Object x)27 public static Object returnNullConstant(Object x) { 28 return null; 29 } 30 InlineNullConstant()31 public static Object InlineNullConstant() { 32 return returnNullConstant(null); 33 } 34 35 /// CHECK-START: int Main.InlineIntConstant() inliner (before) 36 /// CHECK: IntConstant 42 37 /// CHECK-NOT: IntConstant 42 38 39 /// CHECK-START: int Main.InlineIntConstant() inliner (after) 40 /// CHECK: IntConstant 42 41 /// CHECK-NOT: IntConstant 42 42 returnIntConstant(int x)43 public static int returnIntConstant(int x) { 44 return 42; 45 } 46 InlineIntConstant()47 public static int InlineIntConstant() { 48 return returnIntConstant(42); 49 } 50 51 /// CHECK-START: long Main.InlineLongConstant() inliner (before) 52 /// CHECK: LongConstant 42 53 /// CHECK-NOT: LongConstant 42 54 55 /// CHECK-START: long Main.InlineLongConstant() inliner (after) 56 /// CHECK: LongConstant 42 57 /// CHECK-NOT: LongConstant 42 58 returnLongConstant(long x)59 public static long returnLongConstant(long x) { 60 return 42L; 61 } 62 InlineLongConstant()63 public static long InlineLongConstant() { 64 return returnLongConstant(42L); 65 } 66 main(String[] args)67 public static void main(String[] args) { 68 if (InlineNullConstant() != null) { 69 throw new Error("Expected null"); 70 } else if (InlineIntConstant() != 42) { 71 throw new Error("Expected int 42"); 72 } else if (InlineLongConstant() != 42L) { 73 throw new Error("Expected long 42"); 74 } 75 } 76 } 77