-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: Types no longer validating #961
Comments
For a second example, I've noticed the same problem in another class (#950 was submitted by one of my users regarding it, but just to quickly recap...) Consider the following class definition (taken from this file) @WiredPlugin(
"test",
"0.0.1"
)
class TestPlugin(wrapper: PluginWrapper) : KordExPlugin(wrapper) {
override suspend fun setup() {
extension(::TestExtension)
}
} This one uses a different processor (which can be found here), but has a similar result - validation fails and, after some digging, the super types list contains |
does |
Unfortunately no, it does not - precisely the same problems. |
I thought that Kotlin 1.6.21 might help (as they fixed some compiler bugs that were also causing me issues), but that's not the case, unfortunately. |
Since 1.6.20-1.0.4 is also not working, I doubt it is a compiler issue, likely a regression. Can you try to reduce your reproduce project into a small one? You don't have to but if that is possible, it will help with my debugging. |
1.6.21-1.0.5 - not working, but that's expected I'd like to do that, but I think part of my problem is I don't know how to properly debug a KSP processor - since, short of unit tests, I couldn't figure out how to attach a debugger to it. Any ideas on that? If I can zero in on this somehow, I may be able to write some unit tests for this. |
I could successfully debug KSP plugins this way:
Somewhat slow, but works. More details: #31 |
Re-checked the alternative, which is way faster:
If the Gradle task completed before you could attach to the Kotlin compiler daemon, just leave the debugger attached and restart the Gradle task. |
Huh, interesting - when I next have some spare time I'll give that a go, thanks! |
Alright, I'm looking into this at the moment. Having attached a debugger (took a few tries but @OliverO2's instructions worked, thank you!), I've learned a few things about the situation.
I wonder if this is because the supertype was declared in a different sourceset. It's part of the same module, but my |
This does seem to be relevant. Creating a similar test plugin in the main sourceset will result in a success, and it's worth noting that all the unresolvable types given by the other annotation processor are in other modules. It seems to me that this issue is related to the unresolvable supertypes being in other modules and sourcesets. |
Doing some further messing around, I worked around the plugin processor issue by using the During this, I've noticed that the As for the other processor, I can't think of any useful workarounds because it needs that type info - but I'm noticing that it will consistently work if I run the build twice. It'll fail the first time and, assuming I don't clean build, it'll pass thereafter. |
it is expected to run |
So after some testing it seems like, validation fails because the types actually can't be resolved at this time, as they are defined in a different module, this could be
I found the following workaround (where Relevant commit: mikbot/kord-extensions@7a16526 tasks {
afterEvaluate {
"kspKotlin" {
dependsOn(":kord-extensions:build")
}
}
} |
I can confirm @DRSchlaubi's fix. It doesn't help regarding my 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. |
Can you revive the reproduce branch? I was trying to look into this but found the link is now dead. |
Unfortunately, I've moved to a new machine since the branch was cleaned up, so I no longer have a copy of it. However, I am happy to state that as of the latest versions of KSP and Kotlin, we no longer have this problem. Apologies, I completely forgot about this issue. |
Consider the following class definition (taken from this file)
KSP will happily parse this under Kotlin
1.6.10
, using version1.6.10-1.0.4
. There are no issues.Under Kotlin
1.6.20
and KSP1.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 aclean build
- runningbuild
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:
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
.The text was updated successfully, but these errors were encountered: