Skip to content

Commit

Permalink
Fix name shaowing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kdubb committed Dec 15, 2023
1 parent 0ab6ae6 commit 8602ede
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/io/outfoxx/swiftpoet/CodeWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ internal class CodeWriter constructor(
var a = 0
val partIterator = codeBlock.formatParts.listIterator()
while (partIterator.hasNext()) {
val part = partIterator.next()
when (part) {
when (val part = partIterator.next()) {
"%L" -> emitLiteral(codeBlock.args[a++], isConstantContext)

"%N" -> emit(codeBlock.args[a++] as String)
Expand Down Expand Up @@ -452,7 +451,7 @@ internal class CodeWriter constructor(
importsCollector.suggestedImports()
.generateImports(
generatedImports,
canonicalName = DeclaredTypeName::canonicalName,
DeclaredTypeName::canonicalName,
)
}

Expand All @@ -465,11 +464,11 @@ internal class CodeWriter constructor(

private fun <T> Map<String, T>.generateImports(
generatedImports: MutableMap<String, String>,
canonicalName: T.() -> String,
canonicalNameAccessor: T.() -> String,
): Map<String, T> {
return flatMap { (simpleName, qualifiedName) ->
listOf(simpleName to qualifiedName).also {
val canonicalName = qualifiedName.canonicalName()
val canonicalName = qualifiedName.canonicalNameAccessor()
generatedImports[canonicalName] = canonicalName
}
}.toMap()
Expand Down

0 comments on commit 8602ede

Please sign in to comment.