Skip to content

Commit 62dce8a

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.19'
2 parents f36c52a + 2c3501f commit 62dce8a

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

.github/workflows/dep_build_v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# Versions need to align with ones in 'main.yml' workflow
1919
# kotlin-reflect 1.8.2x has a bug and some tests fail, so we are downgrading to 1.8.10.
2020
# https://youtrack.jetbrains.com/issue/KT-65156
21-
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC']
21+
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC2']
2222
env:
2323
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
2424
steps:

.github/workflows/dep_build_v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# Versions need to align with ones in 'main.yml' workflow
1919
# kotlin-reflect 1.8.2x has a bug and some tests fail, so we are downgrading to 1.8.10.
2020
# https://youtrack.jetbrains.com/issue/KT-65156
21-
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC']
21+
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC2']
2222
env:
2323
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
2424
steps:

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
java_version: ['8', '11', '17', '21', '23']
3131
# kotlin-reflect 1.8.2x has a bug and some tests fail, so we are downgrading to 1.8.10.
3232
# https://youtrack.jetbrains.com/issue/KT-65156
33-
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC']
33+
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC2']
3434
include:
3535
- java_version: '8'
3636
kotlin_version: '1.8.10'

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contributors:
1818
# 2.19.0 (not yet released)
1919

2020
WrongWrong (@k163377)
21+
* #858: Refactor findDefaultCreator
2122
* #839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName
2223
* #835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport
2324

release-notes/VERSION-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Co-maintainers:
1818

1919
2.19.0 (not yet released)
2020

21+
#858: Minor performance improvement of findDefaultCreator in edge cases.
2122
#839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName.
2223
#835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport.
2324

src/main/kotlin/tools/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,11 @@ internal class KotlinNamesAnnotationIntrospector(
9191
): PotentialCreator? {
9292
val kClass = valueClass.creatableKotlinClass() ?: return null
9393

94-
val propertyNames = kClass.memberProperties.map { it.name }.toSet()
95-
96-
val defaultCreator = kClass.let { _ ->
97-
// By default, the primary constructor or the only publicly available constructor may be used
98-
val ctor = kClass.primaryConstructor ?: kClass.constructors.takeIf { it.size == 1 }?.single()
99-
ctor?.takeIf { it.isPossibleCreator(propertyNames) }
100-
}
94+
val defaultCreator = kClass.primarilyConstructor()
95+
?.takeIf { ctor ->
96+
val propertyNames = kClass.memberProperties.map { it.name }.toSet()
97+
ctor.isPossibleCreator(propertyNames)
98+
}
10199
?: return null
102100

103101
return declaredConstructors.find {
@@ -115,6 +113,9 @@ private fun AnnotatedClass.creatableKotlinClass(): KClass<*>? = annotated
115113
.takeIf { it.isKotlinClass() && !it.isEnum }
116114
?.kotlin
117115

116+
// By default, the primary constructor or the only publicly available constructor may be used
117+
private fun KClass<*>.primarilyConstructor() = primaryConstructor ?: constructors.singleOrNull()
118+
118119
private fun KFunction<*>.isPossibleCreator(propertyNames: Set<String>): Boolean = 0 < parameters.size
119120
&& !isPossibleSingleString(propertyNames)
120121
&& parameters.none { it.name == null }

0 commit comments

Comments
 (0)