Skip to content

Commit d0e6544

Browse files
committed
add comments
1 parent c485643 commit d0e6544

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/ConstructorInstantiator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlin.reflect.KParameter
1111
internal class ConstructorInstantiator<T>(
1212
kConstructor: KFunction<T>, private val constructor: Constructor<T>
1313
) : Instantiator<T> {
14+
// Top level constructor does not require any instance parameters.
1415
override val hasInstanceParameter: Boolean = false
1516
override val valueParameters: List<KParameter> = kConstructor.parameters
1617
private val accessible: Boolean = constructor.isAccessible

src/main/kotlin/com/fasterxml/jackson/module/kotlin/MethodInstantiator.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ internal class MethodInstantiator<T>(
5959
override fun callBy(bucket: ArgumentBucket) = when (bucket.isFullInitialized()) {
6060
true -> SpreadWrapper.invoke(method, instance, bucket.values)
6161
false -> {
62+
// When calling a method defined in companion object with default arguments,
63+
// the arguments are in the order of [instance, *args, *masks, null].
64+
// Since ArgumentBucket.getValuesOnDefault returns [*args, *masks, null],
65+
// it should be repacked into an array including instance.
6266
val values = originalDefaultValues.clone().apply {
6367
bucket.getValuesOnDefault().forEachIndexed { index, value ->
6468
this[index + 1] = value

0 commit comments

Comments
 (0)