Christoffer Quist Adamsen | 1cbc764 | 2018-06-26 09:48:25 +0200 | [diff] [blame] | 1 | // 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 | |
| 5 | package classmerging; |
| 6 | |
| 7 | public class ConflictInGeneratedNameTest { |
| 8 | public static void main(String[] args) { |
| 9 | B obj = new B(); |
| 10 | obj.run(); |
| 11 | } |
| 12 | |
| 13 | public static class A { |
Rico Wind | e7dac29 | 2021-11-04 13:09:37 +0100 | [diff] [blame] | 14 | @NeverPropagateValue private String name = "A"; |
Christoffer Quist Adamsen | 1cbc764 | 2018-06-26 09:48:25 +0200 | [diff] [blame] | 15 | |
| 16 | public A() { |
| 17 | print("In A.<init>()"); |
Christoffer Quist Adamsen | 4fcaa65 | 2020-11-27 09:49:11 +0100 | [diff] [blame] | 18 | $r8$constructor$classmerging$ConflictInGeneratedNameTest$A(); |
Christoffer Quist Adamsen | 1cbc764 | 2018-06-26 09:48:25 +0200 | [diff] [blame] | 19 | } |
| 20 | |
Christoffer Quist Adamsen | 4fcaa65 | 2020-11-27 09:49:11 +0100 | [diff] [blame] | 21 | private void $r8$constructor$classmerging$ConflictInGeneratedNameTest$A() { |
| 22 | print("In A.$r8$constructor$classmerging$ConflictInGeneratedNameTest$A()"); |
Christoffer Quist Adamsen | 1cbc764 | 2018-06-26 09:48:25 +0200 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | public void printState() { |
| 26 | print("In A.printState()"); |
| 27 | print("A=" + name + "=" + getName()); |
| 28 | } |
| 29 | |
| 30 | // This method is not overridden. |
| 31 | public void foo() { |
| 32 | print("In A.foo()"); |
| 33 | } |
| 34 | |
| 35 | // This method is overridden. |
| 36 | public void bar() { |
| 37 | print("In A.bar()"); |
| 38 | } |
| 39 | |
| 40 | // This method is overridden and there is a PUBLIC method in B with the same name |
| 41 | // as the direct version of this method in B. |
| 42 | public void baz() { |
| 43 | print("In A.baz()"); |
| 44 | } |
| 45 | |
| 46 | // This method is overridden and there is a PRIVATE method in B with the same name |
| 47 | // as the direct version of this method in B. |
| 48 | public void boo() { |
| 49 | print("In A.boo()"); |
| 50 | } |
| 51 | |
| 52 | // There is a private method in B with the same name as this one. |
| 53 | private String getName() { |
| 54 | return name; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | public static class B extends A { |
Rico Wind | e7dac29 | 2021-11-04 13:09:37 +0100 | [diff] [blame] | 59 | @NeverPropagateValue private String name = "B"; |
| 60 | @NeverPropagateValue private String name$classmerging$ConflictInGeneratedNameTest$A = "C"; |
Christoffer Quist Adamsen | 1cbc764 | 2018-06-26 09:48:25 +0200 | [diff] [blame] | 61 | |
| 62 | public B() { |
| 63 | print("In B.<init>()"); |
| 64 | print("A=" + super.name + "=" + super.getName()); |
| 65 | print("B=" + name + "=" + getName()); |
| 66 | print("C=" + name$classmerging$ConflictInGeneratedNameTest$A); |
| 67 | } |
| 68 | |
| 69 | public void run() { |
| 70 | printState(); |
| 71 | foo(); |
| 72 | bar(); |
| 73 | baz(); |
| 74 | baz$classmerging$ConflictInGeneratedNameTest$A(); |
| 75 | boo(); |
| 76 | boo$classmerging$ConflictInGeneratedNameTest$A(); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public void bar() { |
| 81 | print("In B.bar()"); |
| 82 | super.bar(); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public void baz() { |
| 87 | print("In B.baz()"); |
| 88 | super.baz(); |
| 89 | } |
| 90 | |
| 91 | public void baz$classmerging$ConflictInGeneratedNameTest$A() { |
| 92 | print("In B.baz$classmerging$ConflictInGeneratedNameTest$A()"); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public void boo() { |
| 97 | print("In B.boo()"); |
| 98 | super.boo(); |
| 99 | } |
| 100 | |
| 101 | private void boo$classmerging$ConflictInGeneratedNameTest$A() { |
| 102 | print("In B.boo$classmerging$ConflictInGeneratedNameTest$A()"); |
| 103 | } |
| 104 | |
| 105 | private String getName() { |
| 106 | return name; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | public static void print(String message) { |
| 111 | System.out.println(message); |
| 112 | } |
| 113 | } |