1212//
1313//===----------------------------------------------------------------------===//
1414
15- import Foundation
16-
1715package extension JavaTranslator {
1816 struct SwiftTypeName : Hashable {
1917 let swiftType : String
@@ -42,14 +40,17 @@ package extension JavaTranslator {
4240 switch self {
4341 case . multipleClassesMappedToSameName( let swiftToJavaMapping) :
4442 """
45- The following Java classes were mapped to the same Swift type:
46- \( swiftToJavaMapping. map { mapping in
47- " Swift Type: \( mapping. swiftType. swiftModule ?? " " ) . \( mapping. swiftType. swiftType) , Java Types: \( mapping. javaTypes. sorted ( ) . joined ( separator: " , " ) ) "
48- } . joined ( separator: " \n " ) )
43+ The following Java classes were mapped to the same Swift type name:
44+ \( swiftToJavaMapping. map ( mappingDescription ( mapping: ) ) . joined ( separator: " \n " ) )
4945 """
5046 }
5147 }
5248
49+ private func mappingDescription( mapping: SwiftToJavaMapping ) -> String {
50+ let javaTypes = mapping. javaTypes. map { " ' \( $0) ' " } . joined ( separator: " , " )
51+ return " Swift Type: ' \( mapping. swiftType. swiftModule ?? " " ) '.' \( mapping. swiftType. swiftType) ', Java Types: \( javaTypes) "
52+
53+ }
5354 }
5455 func validateClassConfiguration( ) throws {
5556 // Group all classes by swift name
@@ -63,7 +64,7 @@ package extension JavaTranslator {
6364 // Convert them to swift object and throw
6465 var errorMappings = [ SwiftToJavaMapping] ( )
6566 for (swiftType, swiftJavaMappings) in multipleClassesMappedToSameName {
66- errorMappings. append ( SwiftToJavaMapping ( swiftType: swiftType, javaTypes: swiftJavaMappings. map ( \. 0 ) ) )
67+ errorMappings. append ( SwiftToJavaMapping ( swiftType: swiftType, javaTypes: swiftJavaMappings. map ( \. 0 ) . sorted ( ) ) )
6768 }
6869 throw ValidationError . multipleClassesMappedToSameName ( swiftToJavaMapping: errorMappings)
6970 }
0 commit comments