diff options
Diffstat (limited to 'test/477-checker-bound-type')
-rw-r--r-- | test/477-checker-bound-type/expected.txt | 0 | ||||
-rw-r--r-- | test/477-checker-bound-type/info.txt | 3 | ||||
-rw-r--r-- | test/477-checker-bound-type/src/Main.java | 61 |
3 files changed, 64 insertions, 0 deletions
diff --git a/test/477-checker-bound-type/expected.txt b/test/477-checker-bound-type/expected.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/477-checker-bound-type/expected.txt diff --git a/test/477-checker-bound-type/info.txt b/test/477-checker-bound-type/info.txt new file mode 100644 index 0000000..68c774a --- /dev/null +++ b/test/477-checker-bound-type/info.txt @@ -0,0 +1,3 @@ +Tests that we only generate a bound type if we have relevant users. +It also tests a code generator regression for GenerateTestAndBranch which +didn't take into account NullConstants. diff --git a/test/477-checker-bound-type/src/Main.java b/test/477-checker-bound-type/src/Main.java new file mode 100644 index 0000000..b30028d --- /dev/null +++ b/test/477-checker-bound-type/src/Main.java @@ -0,0 +1,61 @@ +/* +* Copyright (C) 2015 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +public class Main { + + // CHECK-START: java.lang.Object Main.boundTypeForIf(java.lang.Object) reference_type_propagation (after) + // CHECK: BoundType + public static Object boundTypeForIf(Object a) { + if (a != null) { + return a.toString(); + } else { + return null; + } + } + + // CHECK-START: java.lang.Object Main.boundTypeForInstanceOf(java.lang.Object) reference_type_propagation (after) + // CHECK: BoundType + public static Object boundTypeForInstanceOf(Object a) { + if (a instanceof Main) { + return (Main)a; + } else { + return null; + } + } + + // CHECK-START: java.lang.Object Main.noBoundTypeForIf(java.lang.Object) reference_type_propagation (after) + // CHECK-NOT: BoundType + public static Object noBoundTypeForIf(Object a) { + if (a == null) { + return new Object(); + } else { + return null; + } + } + + // CHECK-START: java.lang.Object Main.noBoundTypeForInstanceOf(java.lang.Object) reference_type_propagation (after) + // CHECK-NOT: BoundType + public static Object noBoundTypeForInstanceOf(Object a) { + if (a instanceof Main) { + return new Object(); + } else { + return null; + } + } + + public static void main(String[] args) { } +} |