pkl-config-java: Migrate nullness to jSpecify#1528
Merged
bioball merged 2 commits intoapple:mainfrom Apr 17, 2026
Merged
Conversation
604caa2 to
0d663de
Compare
HT154
reviewed
Apr 16, 2026
Contributor
|
Looks like changes are needed in pkl-config-kotlin for this to compile. Is this expected? diff --git a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/ConfigExtensions.kt b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/ConfigExtensions.kt
index 6bf47437..16513274 100644
--- a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/ConfigExtensions.kt
+++ b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/ConfigExtensions.kt
@@ -36,10 +36,10 @@ import org.pkl.config.kotlin.mapper.KotlinConverterFactories
* * easier to use with parameterized types: `to<List<String>>()` vs.
* `as(JavaType.listOf(String::class.java))`
*/
-inline fun <reified T> Config.to(): T {
+inline fun <reified T : Any> Config.to(): T {
val javaType = object : JavaType<T>() {}
// `as T?` may no longer be required after switching to JSpecify
- val result = `as`<T>(javaType.type) as T?
+ val result = `as`(javaType.type) as T?
if (result == null && null !is T) {
throw ConversionException(
"Expected a non-null value but got `null`. " +
diff --git a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt
index cf93536a..7e38a8e0 100644
--- a/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt
+++ b/pkl-config-kotlin/src/main/kotlin/org/pkl/config/kotlin/mapper/PPairToKotlinPair.kt
@@ -42,7 +42,7 @@ internal class PPairToKotlinPair : ConverterFactory {
)
}
- private class ConverterImpl<F, S>(
+ private class ConverterImpl<F : Any, S : Any>(
private val firstTargetType: Type,
private val secondTargetType: Type,
) : Converter<PPair<Any, Any>, Pair<F, S>> { |
Contributor
Author
|
Yes, I'm on it. kotlinc has direct support for jSpecify and is very strict about nullness. Unfortunately, a local |
0d663de to
6a6ce39
Compare
HT154
approved these changes
Apr 16, 2026
6a6ce39 to
88cbe91
Compare
Contributor
Author
|
@HT154 force-pushed because I had missed some |
88cbe91 to
8d9ccec
Compare
Member
Yeah, I'd consider it a bug if it isn't.
I don't think so. Happy to accept a PR to move this out. |
bioball
approved these changes
Apr 17, 2026
| inline fun <reified T> Config.to(): T { | ||
| val javaType = object : JavaType<T>() {} | ||
| // `as T?` may no longer be required after switching to JSpecify | ||
| val result = `as`<T>(javaType.type) as T? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Questions that came up while working on this PR:
Configbe thread-safe? Currently, it isn't, as someConverterimplementations aren't.Config.makeConfig()be part of the public API? Currently, it is.