Regression: Types no longer validating
See original GitHub issueConsider the following class definition (taken from this file)
@Converter(
names = ["j8Duration"],
types = [ConverterType.DEFAULTING, ConverterType.OPTIONAL, ConverterType.SINGLE],
imports = ["java.time.*"],
builderFields = [
"public var longHelp: Boolean = true",
"public var positiveOnly: Boolean = true",
],
)
public class J8DurationConverter(
public val longHelp: Boolean = true,
public val positiveOnly: Boolean = true,
override var validator: Validator<ChronoContainer> = null
) : SingleConverter<ChronoContainer>() {
KSP will happily parse this under Kotlin 1.6.10
, using version 1.6.10-1.0.4
. There are no issues.
Under Kotlin 1.6.20
and KSP 1.6.20-1.0.5
, this class no longer validates - attempting to get the super types will result in a list with a single <Error object>
entry. Even worse, this seems to sporadically only happens on a clean build
- running build
again right after will sometimes result in validation passing perfectly, and the output being generated correctly.
I have a bunch of classes that are structured the same way and are generally quite similar that parse just fine under 1.0.5
. Some examples are below, but everything in the same directory works perfectly. Click here for the annotation processor code.
Working:
Broken:
- J8DurationCoalescingConverter and J8DurationConverter
- MappingsVersionConverter
- T4JDurationCoalescingConverter and T4JDurationConverter
This makes absolutely no sense to me whatsoever. I can’t see any significant differences, and I’m entirely out of ideas. For the time being, I’ve pushed a copy of the repo using last known working versions of Kotlin and KSP, simply updating them will cause this issue.
Since I really don’t know how to dig further, I’ve pushed a branch which exhibits this issue. Simply clone it and run gradlew build
.
Issue Analytics
- State:
- Created a year ago
- Comments:17
I can confirm @DRSchlaubi’s fix. It doesn’t help regarding my
TestPlugin
report, and I believe that’s because that was in thetest
source set rather thanmain
.I’ve removed it in our codebase as our test bot is in a different module now, and things are working, but it’s worth considering whether this is intentional KSP behaviour.
Huh, interesting - when I next have some spare time I’ll give that a go, thanks!