Lars Bak | 82e83bf | 2017-05-22 11:11:42 +0200 | [diff] [blame] | 1 | // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | package interfaceinlining; |
| 5 | |
| 6 | // This test ensures a check cast instruction is inserted IFF |
| 7 | // the expression "((DataI) other).field()" is inlined. |
| 8 | // Failing to do so will result in an ART verification error. |
| 9 | public class Main { |
| 10 | public interface DataI { |
| 11 | int field(); |
| 12 | } |
| 13 | public static class Data implements DataI { |
| 14 | final int a; |
| 15 | public boolean equals(Object other) { |
| 16 | if (other instanceof DataI) { |
| 17 | return a == ((DataI) other).field(); |
| 18 | } |
| 19 | return false; |
| 20 | } |
| 21 | Data(int a) { |
| 22 | this.a = a; |
| 23 | } |
| 24 | public int field() { |
| 25 | return a; |
| 26 | } |
| 27 | } |
| 28 | public static void main (String[] args) { |
| 29 | System.out.print(new Data(1).equals(new Data(1))); |
| 30 | } |
| 31 | } |