@@ -41,6 +41,16 @@ struct JNIProtocolTests {
4141 public func takeComposite(x: any SomeProtocol & B)
4242 """
4343
44+ let protocolInheritanceSource = """
45+ public protocol ParentProtocol {
46+ public func parentMethod()
47+ }
48+
49+ public protocol ChildProtocol: ParentProtocol {
50+ public func childMethod()
51+ }
52+ """
53+
4454 @Test
4555 func generatesJavaInterface( ) throws {
4656 try assertOutput (
@@ -72,6 +82,33 @@ struct JNIProtocolTests {
7282 )
7383 }
7484
85+ @Test
86+ func generatesJavaInterfaceWithInheritedProtocol( ) throws {
87+ try assertOutput (
88+ input: protocolInheritanceSource,
89+ config: config,
90+ . jni,
91+ . java,
92+ detectChunkByInitialLines: 1 ,
93+ expectedChunks: [
94+ """
95+ public interface ParentProtocol {
96+ ...
97+ public void parentMethod();
98+ ...
99+ }
100+ """ ,
101+ """
102+ public interface ChildProtocol extends ParentProtocol {
103+ ...
104+ public void childMethod();
105+ ...
106+ }
107+ """ ,
108+ ]
109+ )
110+ }
111+
75112 @Test
76113 func generatesJavaClassWithExtends( ) throws {
77114 try assertOutput (
@@ -348,4 +385,37 @@ struct JNIProtocolTests {
348385 ]
349386 )
350387 }
388+
389+ @Test
390+ func generatesProtocolWrappersWithInheritedProtocol( ) throws {
391+ try assertOutput (
392+ input: protocolInheritanceSource,
393+ config: config,
394+ . jni,
395+ . swift,
396+ detectChunkByInitialLines: 1 ,
397+ expectedChunks: [
398+ """
399+ protocol SwiftJavaParentProtocolWrapper: ParentProtocol {
400+ var _javaParentProtocolInterface: JavaParentProtocol { get }
401+ }
402+ """ ,
403+ """
404+ protocol SwiftJavaChildProtocolWrapper: ChildProtocol, SwiftJavaParentProtocolWrapper {
405+ var _javaChildProtocolInterface: JavaChildProtocol { get }
406+ }
407+ """ ,
408+ """
409+ extension SwiftJavaChildProtocolWrapper {
410+ var _javaParentProtocolInterface: JavaParentProtocol {
411+ _javaChildProtocolInterface
412+ }
413+ public func childMethod() {
414+ ...
415+ }
416+ }
417+ """ ,
418+ ]
419+ )
420+ }
351421}
0 commit comments