@@ -668,6 +668,44 @@ final class MethodImportTests {
668668 )
669669 }
670670
671+ let overloadedInitializers_interfaceFile =
672+ """
673+ import Swift
674+
675+ public class OverloadedInitializerClass {
676+ public init(throwing: Swift.Bool) throws
677+ public init?(doInit: Swift.Bool)
678+ }
679+ """
680+
681+ let overloadedFFMInitializers_interfaceFile =
682+ """
683+ import Swift
684+
685+ public class OverloadedFFMInitializerClass {
686+ public init(throwing: Swift.Bool) throws
687+ public init(doInit: Swift.Bool)
688+ }
689+ """
690+
691+ @Test ( " FFM: Overloaded initializers with same Java signature get suffixed Java names " )
692+ func ffm_overloaded_initializers_suffixed( ) throws {
693+ try assertOutput (
694+ input: overloadedFFMInitializers_interfaceFile,
695+ . ffm,
696+ . java,
697+ swiftModuleName: " OverloadModule " ,
698+ expectedChunks: [
699+ " public static OverloadedFFMInitializerClass initThrowing(boolean throwing, AllocatingSwiftArena swiftArena) " ,
700+ " public static OverloadedFFMInitializerClass initDoInit(boolean doInit, AllocatingSwiftArena swiftArena) " ,
701+ ] ,
702+ notExpectedChunks: [
703+ " public static OverloadedFFMInitializerClass init(boolean throwing, AllocatingSwiftArena swiftArena) " ,
704+ " public static OverloadedFFMInitializerClass init(boolean doInit, AllocatingSwiftArena swiftArena) " ,
705+ ]
706+ )
707+ }
708+
671709 // ==== -------------------------------------------------------------------
672710 // MARK: JNI overloaded method disambiguation
673711
@@ -776,4 +814,22 @@ final class MethodImportTests {
776814 ]
777815 )
778816 }
817+
818+ @Test ( " JNI: Overloaded initializers with same Java signature get suffixed Java names " )
819+ func jni_overloaded_initializers_suffixed( ) throws {
820+ try assertOutput (
821+ input: overloadedInitializers_interfaceFile,
822+ . jni,
823+ . java,
824+ swiftModuleName: " OverloadModule " ,
825+ expectedChunks: [
826+ " public static OverloadedInitializerClass initThrowing(boolean throwing, SwiftArena swiftArena) throws Exception " ,
827+ " public static java.util.Optional<OverloadedInitializerClass> initDoInit(boolean doInit, SwiftArena swiftArena) " ,
828+ ] ,
829+ notExpectedChunks: [
830+ " public static OverloadedInitializerClass init(boolean throwing, SwiftArena swiftArena) " ,
831+ " public static java.util.Optional<OverloadedInitializerClass> init(boolean doInit, SwiftArena swiftArena) " ,
832+ ]
833+ )
834+ }
779835}
0 commit comments