Skip to content

Commit 91646f3

Browse files
committed
Java2Swift: Add a test importing part of ArrayList with generic List return
1 parent 5ad8abe commit 91646f3

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Tests/Java2SwiftTests/Java2SwiftTests.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var jvm: JavaVirtualMachine {
2525
}
2626

2727
class Java2SwiftTests: XCTestCase {
28-
func testJavaLangObjectMapping() async throws {
28+
func testJavaLangObjectMapping() throws {
2929
try assertTranslatedClass(
3030
JavaObject.self,
3131
swiftTypeName: "MyJavaObject",
@@ -46,6 +46,27 @@ class Java2SwiftTests: XCTestCase {
4646
]
4747
)
4848
}
49+
50+
func testGenericCollections() throws {
51+
try assertTranslatedClass(
52+
MyArrayList<JavaObject>.self,
53+
swiftTypeName: "JavaArrayList",
54+
translatedClasses: [
55+
"java.lang.Object": ("JavaObject", nil, true),
56+
"java.util.List": ("JavaList", nil, true),
57+
],
58+
expectedChunks: [
59+
"""
60+
@JavaMethod
61+
public func subList(_ arg0: Int32, _ arg1: Int32) -> JavaList<JavaObject>?
62+
"""
63+
]
64+
)
65+
}
66+
}
67+
68+
@JavaClass("java.util.ArrayList")
69+
public struct MyArrayList<E: AnyJavaObject> {
4970
}
5071

5172
/// Translate a Java class and assert that the translated output contains

0 commit comments

Comments
 (0)