Skip to content

Commit

Permalink
Improve readability of constructor invocation params (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers authored Mar 14, 2021
1 parent 3bc4751 commit 103b603
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,12 @@ internal class AdapterGenerator(
// We have to use the default primitive for the available type in order for
// invokeDefaultConstructor to properly invoke it. Just using "null" isn't safe because
// the transient type may be a primitive type.
result.addCode(input.type.rawType().defaultPrimitiveValue())
// Inline a little comment for readability indicating which parameter is it's referring to
result.addCode(
"/*·%L·*/·%L",
input.parameter.name,
input.type.rawType().defaultPrimitiveValue()
)
} else {
result.addCode("%N", (input as ParameterProperty).property.localName)
}
Expand All @@ -580,7 +585,7 @@ internal class AdapterGenerator(

if (useDefaultsConstructor) {
// Add the masks and a null instance for the trailing default marker instance
result.addCode(",\n%L,\nnull", maskNames.map { CodeBlock.of("%L", it) }.joinToCode(", "))
result.addCode(",\n%L,\n/*·DefaultConstructorMarker·*/·null", maskNames.map { CodeBlock.of("%L", it) }.joinToCode(", "))
}

result.addCode("\n»)\n")
Expand Down

0 comments on commit 103b603

Please sign in to comment.