blob: 4456498839ddb7c9f1700e6b3f7ae4bd0dd0fea9 [file] [log] [blame]
Christoffer Quist Adamsen0be95fb2018-07-06 10:45:56 +02001// Copyright (c) 2018, 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
5package classmerging;
6
7public class MethodCollisionTest {
8
9 public static void main(String[] args) {
Christoffer Quist Adamsenbfdbe602019-10-18 12:03:31 +020010 B b = new B();
11 b.m();
12
13 D d = new D();
14 d.m();
15
16 // Ensure that the instantiations are not dead code eliminated.
17 escape(b);
18 escape(d);
19 }
20
21 @NeverInline
22 static void escape(Object o) {
23 if (System.currentTimeMillis() < 0) {
24 System.out.println(o);
25 }
Christoffer Quist Adamsen0be95fb2018-07-06 10:45:56 +020026 }
27
28 public static class A {
29
30 // After class merging, this method will have the same signature as the method B.m,
31 // unless we handle the collision.
32 private A m() {
33 System.out.println("A.m");
34 return null;
35 }
36
37 public void invokeM() {
38 m();
39 }
40 }
41
42 public static class B extends A {
43
44 private B m() {
45 System.out.println("B.m");
46 invokeM();
47 return null;
48 }
49 }
50
51 public static class C {
52
53 // After class merging, this method will have the same signature as the method D.m,
54 // unless we handle the collision.
55 public C m() {
56 System.out.println("C.m");
57 return null;
58 }
59 }
60
61 public static class D extends C {
62
63 public D m() {
64 System.out.println("D.m");
65 super.m();
66 return null;
67 }
68 }
69
70
71}