diff --git a/Assets/Tests/KotlinTokenizer/structs.swift b/Assets/Tests/KotlinTokenizer/structs.swift index a640cfd..9c48c54 100644 --- a/Assets/Tests/KotlinTokenizer/structs.swift +++ b/Assets/Tests/KotlinTokenizer/structs.swift @@ -2,7 +2,7 @@ struct Data { var text: String } -struct Person { +struct Person: Equatable { let name: String let surname: String var age: Int diff --git a/Sources/SwiftKotlinFramework/KotlinTokenizer.swift b/Sources/SwiftKotlinFramework/KotlinTokenizer.swift index 692c851..84cbe1a 100644 --- a/Sources/SwiftKotlinFramework/KotlinTokenizer.swift +++ b/Sources/SwiftKotlinFramework/KotlinTokenizer.swift @@ -159,8 +159,8 @@ public class KotlinTokenizer: SwiftTokenizer { at: bodyStart - 1) } - if let typeInheritanceList = declaration.typeInheritanceClause?.typeInheritanceList, - !typeInheritanceList.isEmpty, + if let typeInheritanceList = declaration.typeInheritanceClause?.typeInheritanceList.nonEquatable, + typeInheritanceList.isEmpty == false, let bodyStart = tokens.firstIndex(where: { $0.value == "{"}) { let clause = TypeInheritanceClause(classRequirement: false, typeInheritanceList: typeInheritanceList) let inheritanceTokens = tokenize(clause, node: declaration) @@ -439,9 +439,7 @@ public class KotlinTokenizer: SwiftTokenizer { // Simple enums (no tuple values) if !simpleCases.contains(where: { $0.tuple != nil }) { - let typeInheritanceList = declaration.typeInheritanceClause?.typeInheritanceList.filter { - $0.names.contains { $0.name.textDescription != "Equatable" } - } + let typeInheritanceList = declaration.typeInheritanceClause?.typeInheritanceList.nonEquatable if typeInheritanceList?.isEmpty == false { return tokenizeSimpleValueEnum(declaration: declaration, simpleCases: simpleCases) } else { diff --git a/Sources/SwiftKotlinFramework/utils/AST+Operations.swift b/Sources/SwiftKotlinFramework/utils/AST+Operations.swift index 0435185..8998b19 100644 --- a/Sources/SwiftKotlinFramework/utils/AST+Operations.swift +++ b/Sources/SwiftKotlinFramework/utils/AST+Operations.swift @@ -273,3 +273,10 @@ extension GuardStatement { (bodyStatement is ReturnStatement || bodyStatement is ThrowStatement) } } + +extension Collection where Iterator.Element == TypeIdentifier { + var nonEquatable: [TypeIdentifier] { + return filter { $0.names.contains { $0.name.textDescription != "Equatable" } } + } +} +