blob: 8638514919a219b70ee900fb5dad6ece8883fa40 [file] [log] [blame]
David Brazdil4a3faec2015-04-16 10:38:44 +01001/*
Roland Levillain6a92a032015-07-23 12:15:01 +01002 * 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 */
David Brazdil4a3faec2015-04-16 10:38:44 +010016
17public class Main {
18
David Brazdila06d66a2015-05-28 11:14:54 +010019 /// CHECK-START: java.lang.Object Main.InlineNullConstant() inliner (before)
20 /// CHECK: NullConstant
21 /// CHECK-NOT: NullConstant
David Brazdil4a3faec2015-04-16 10:38:44 +010022
David Brazdila06d66a2015-05-28 11:14:54 +010023 /// CHECK-START: java.lang.Object Main.InlineNullConstant() inliner (after)
24 /// CHECK: NullConstant
25 /// CHECK-NOT: NullConstant
David Brazdil4a3faec2015-04-16 10:38:44 +010026
27 public static Object returnNullConstant(Object x) {
28 return null;
29 }
30
31 public static Object InlineNullConstant() {
32 return returnNullConstant(null);
33 }
34
David Brazdila06d66a2015-05-28 11:14:54 +010035 /// CHECK-START: int Main.InlineIntConstant() inliner (before)
36 /// CHECK: IntConstant 42
37 /// CHECK-NOT: IntConstant 42
David Brazdil4a3faec2015-04-16 10:38:44 +010038
David Brazdila06d66a2015-05-28 11:14:54 +010039 /// CHECK-START: int Main.InlineIntConstant() inliner (after)
40 /// CHECK: IntConstant 42
41 /// CHECK-NOT: IntConstant 42
David Brazdil4a3faec2015-04-16 10:38:44 +010042
43 public static int returnIntConstant(int x) {
44 return 42;
45 }
46
47 public static int InlineIntConstant() {
48 return returnIntConstant(42);
49 }
50
David Brazdila06d66a2015-05-28 11:14:54 +010051 /// CHECK-START: long Main.InlineLongConstant() inliner (before)
52 /// CHECK: LongConstant 42
53 /// CHECK-NOT: LongConstant 42
David Brazdil4a3faec2015-04-16 10:38:44 +010054
David Brazdila06d66a2015-05-28 11:14:54 +010055 /// CHECK-START: long Main.InlineLongConstant() inliner (after)
56 /// CHECK: LongConstant 42
57 /// CHECK-NOT: LongConstant 42
David Brazdil4a3faec2015-04-16 10:38:44 +010058
59 public static long returnLongConstant(long x) {
60 return 42L;
61 }
62
63 public static long InlineLongConstant() {
64 return returnLongConstant(42L);
65 }
66
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}