Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Nov 23, 2024
2 parents f36c52a + 2c3501f commit 62dce8a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dep_build_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# Versions need to align with ones in 'main.yml' workflow
# kotlin-reflect 1.8.2x has a bug and some tests fail, so we are downgrading to 1.8.10.
# https://youtrack.jetbrains.com/issue/KT-65156
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC']
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC2']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dep_build_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# Versions need to align with ones in 'main.yml' workflow
# kotlin-reflect 1.8.2x has a bug and some tests fail, so we are downgrading to 1.8.10.
# https://youtrack.jetbrains.com/issue/KT-65156
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC']
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC2']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
java_version: ['8', '11', '17', '21', '23']
# kotlin-reflect 1.8.2x has a bug and some tests fail, so we are downgrading to 1.8.10.
# https://youtrack.jetbrains.com/issue/KT-65156
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC']
kotlin_version: ['1.8.10', '1.9.24', '2.0.21', '2.1.0-RC2']
include:
- java_version: '8'
kotlin_version: '1.8.10'
Expand Down
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Contributors:
# 2.19.0 (not yet released)

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

Expand Down
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Co-maintainers:

2.19.0 (not yet released)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ internal class KotlinNamesAnnotationIntrospector(
): PotentialCreator? {
val kClass = valueClass.creatableKotlinClass() ?: return null

val propertyNames = kClass.memberProperties.map { it.name }.toSet()

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

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

// By default, the primary constructor or the only publicly available constructor may be used
private fun KClass<*>.primarilyConstructor() = primaryConstructor ?: constructors.singleOrNull()

private fun KFunction<*>.isPossibleCreator(propertyNames: Set<String>): Boolean = 0 < parameters.size
&& !isPossibleSingleString(propertyNames)
&& parameters.none { it.name == null }
Expand Down

0 comments on commit 62dce8a

Please sign in to comment.