Skip to content

Commit e06a8c6

Browse files
committed
Add test for casting of virtual function parameter types
These require a cast when a generic parameter changes name between parent and child types.
1 parent a62b5da commit e06a8c6

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed
Binary file not shown.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
public class Base<T> {
3+
4+
public T genericData;
5+
public String nonGenericData;
6+
7+
public void main(boolean unknown1, boolean unknown2) {
8+
9+
Base b = unknown1 ? new Impl1<T>() : new Impl2<T>();
10+
if(unknown2)
11+
b.f(genericData);
12+
else
13+
b.g(nonGenericData);
14+
}
15+
16+
public void f(T t) { }
17+
public void g(String t) { }
18+
19+
}
20+
21+
class Impl1<T> extends Base<T> {
22+
23+
public void f(T t) { assert false; }
24+
public void g(String t) { assert false; }
25+
26+
}
27+
28+
class Impl2<T> extends Base<T> {
29+
30+
public void f(T t) { assert false; }
31+
public void g(String t) { assert false; }
32+
33+
}
Binary file not shown.
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
Base.class
3+
--function Base.main --show-goto-functions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
\(struct Impl1 \*\)b \. Impl1\.f:\(Ljava/lang/Object;\)V\(\(struct java\.lang\.Object \*\)this->genericData\);
7+
\(struct Impl2 \*\)b \. Impl2\.f:\(Ljava/lang/Object;\)V\(\(struct java\.lang\.Object \*\)this->genericData\);
8+
\(struct Impl2 \*\)b \. Impl2\.g:\(Ljava/lang/String;\)V\(this->nonGenericData\);
9+
\(struct Impl1 \*\)b \. Impl1\.g:\(Ljava/lang/String;\)V\(this->nonGenericData\);
10+
--
11+
--
12+
Both the implementation classes use a different generic token (Impl1::T and Impl2::T) to refer
13+
to the generically-typed method f() and so a cast is needed. By contrast the concrete-typed
14+
virtual method g() does not need one.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Base.class
3+
--function Base.main
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
\[java::Impl1\.f:\(Ljava/lang/Object;\)V.assertion\.1\] line 23 assertion at file Base.java line 23 function java::Impl1\.f:\(Ljava/lang/Object;\)V bytecode-index 5: FAILURE
8+
\[java::Impl1\.g:\(Ljava/lang/String;\)V.assertion\.1\] line 24 assertion at file Base.java line 24 function java::Impl1\.g:\(Ljava/lang/String;\)V bytecode-index 5: FAILURE
9+
\[java::Impl2\.f:\(Ljava/lang/Object;\)V.assertion\.1\] line 30 assertion at file Base.java line 30 function java::Impl2\.f:\(Ljava/lang/Object;\)V bytecode-index 5: FAILURE
10+
\[java::Impl2\.g:\(Ljava/lang/String;\)V.assertion\.1\] line 31 assertion at file Base.java line 31 function java::Impl2\.g:\(Ljava/lang/String;\)V bytecode-index 5: FAILURE

0 commit comments

Comments
 (0)