Skip to content

Commit

Permalink
[ABI Validation] Sort class signatures before dump the same way Kotli…
Browse files Browse the repository at this point in the history
…nApiBuildTask does

Pull request Kotlin/binary-compatibility-validator#188
  • Loading branch information
fzhinkin authored and shanshin committed Oct 22, 2024
1 parent aed3735 commit 1fe8287
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,7 @@ public open class KotlinApiBuildTask @Inject constructor(
.filterOutAnnotated(nonPublicMarkers.map(::replaceDots).toSet())

outputApiDir.resolve("$projectName.api").bufferedWriter().use { writer ->
filteredSignatures
.sortedBy { it.name }
.forEach { api ->
writer.append(api.signature).appendLine(" {")
api.memberSignatures
.sortedWith(MEMBER_SORT_ORDER)
.forEach { writer.append("\t").appendLine(it.signature) }
writer.appendLine("}\n")
}
filteredSignatures.dump(writer)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,16 @@ public fun List<ClassBinarySignature>.dump(): PrintStream = dump(to = System.out

@ExternalApi
public fun <T : Appendable> List<ClassBinarySignature>.dump(to: T): T {
forEach { classApi ->
with(to) {
append(classApi.signature).appendLine(" {")
classApi.memberSignatures
.sortedWith(MEMBER_SORT_ORDER)
.forEach { append("\t").appendLine(it.signature) }
appendLine("}\n")
sortedBy { it.name }
.forEach { classApi ->
with(to) {
append(classApi.signature).appendLine(" {")
classApi.memberSignatures
.sortedWith(MEMBER_SORT_ORDER)
.forEach { append("\t").appendLine(it.signature) }
appendLine("}\n")
}
}
}
return to
}

Expand Down

0 comments on commit 1fe8287

Please sign in to comment.