-
Notifications
You must be signed in to change notification settings - Fork 63
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
nested classes in java sources cannot be resolved #105
Comments
btw i'm sure it is because of that change because reverting it fixes the test. |
i put more investigation notes into google/ksp#263 (comment). This is about java files' location not matching the project structure. As far as I can see, we don't set source root, instead we send files to kotlin compile / java compile. |
so it works fine if i pass the sources folder into the kotlin compiler as |
here is a repro w/o KSP: i'm afraid we may need an API change to specify java file locations or allow paths in names. |
nevermind, repro had bad code :( |
seems like this is happening because we give |
Finally figured it out (i think :) ) I can "fix" that by giving the sources directory but it is not necessarily correct for source files that are created from other existing files:
Now the problem in the KCT side is that we allow passing arbitrary java files so their root directory does not really exist. |
If we set Is it not possible to add every Java file as a separate source root like we are doing here? I wonder why this |
This version includes a fix where java sources were not provided to KSP, which means getSymbolsAnnotatedWith didn't work. Unfortunately, this update hit a bug in KSP/KCT (not sure yet) where KSP cannot find java sources. After a long investigation (see github issues), I figured it is the lack of javaSourceRoots argument being passed into KotlinCompilation that confuses KSP (but regular kotlin compilation works fine). KCT does not set it and cannot easily set it since its public API receives any file as an argument (so it cannot calculate a root). For this reason, now Room's abstraction passes that argument directly. As part of that change, I also changed how SourceFile's are converted. Now we always build a "proper" folder structure before calling KCT. I've refactored all 3 places where we use KCT to use this common path. tschuchortdev/kotlin-compile-testing#105 google/ksp#263 Test: existing tests Change-Id: Ibd0d6fc46849c2a0489b2bb632a2c19862e31c9e
Apparently, this doesn't work. But I haven't figured out yet why. This is weird. |
By the way, I've talked to someone in the compiler team about this who had this to say:
With this in mind, I think it would be best to change the API to no longer accept paths to Java files and only to Java source roots. |
FYI this is what we do in room: For java, it expects a qualified name and content; In room, we actually write those files into proper places wrt their qualified names to avoid this issue. (and we can find the correct place from the qName). |
… done for room (mentioned here tschuchortdev/kotlin-compile-testing#105 (comment)) but this also does not work. Disabled ksp test for inner classes in java because of tschuchortdev/kotlin-compile-testing#105
* Rename .java to .kt * Convert processor ot Kotlin * Rename .java to .kt * Convert all processor tests to Kotlin and use com.github.tschuchortdev:kotlin-compile-testing for testing. Moved all tests over and make them more meaningful by testing what ends up in the index instad of just 1:1 ow which code they generate) which with the index bing binary is unverifiable. * Cleanup * Kotlin conversion cleanup and segmentation. * First step of ksp conversion * First step of ksp conversion * Fix delegate and index generation * Cleanup * Moved all tests to mockk Removed old unused dependencies Check generated source on top of functionality Split method and class elements into two sets for processing Fixed index generation for inner classes Added processor test with inner class Enabled ksp for sample project * Fix originating elements for Delegate generation. Fix originalting elment for Registry generation. Made unit test when running via ksp not to compiled code check. * Use | for separator of options * Fix argument and disable kapt plugin * Remove no unused jcenter Fix warning Updated gradle to 7.1 * Add Kapt test library to show setup for kapt. Clean up gralde plugin dependency for ksp. Updated documentation. * Use public version of xProcessorVersion Remove airbnb repo dependency * Add ktlint plugin and clean up the processor. Also add ktlint to ci checks. * Better error message match. * When running ksp allow the incremental flag to not be set and still get the custom processors from config. Use testKsp to test that behavior. * Cleanup. * Typos * Cleanup and Pr comments. * Rename .java to .kt * Made DeepLinkAnnotatedElement a sealed class Adde Kotlin source base tests. Cleanup/fixes * Enable failing tests * Kotlin conversion * Make sure to generate java source files in correct package like it is done for room (mentioned here tschuchortdev/kotlin-compile-testing#105 (comment)) but this also does not work. Disabled ksp test for inner classes in java because of tschuchortdev/kotlin-compile-testing#105 * Add missing import Add Kotlin based module * Add note about Kotlin source files when using KSP. * Remove note about kapt/ksp coexistance. Co-authored-by: Andreas Rossbacher <[email protected]>
* Rename .java to .kt * Convert processor ot Kotlin * Rename .java to .kt * Convert all processor tests to Kotlin and use com.github.tschuchortdev:kotlin-compile-testing for testing. Moved all tests over and make them more meaningful by testing what ends up in the index instad of just 1:1 ow which code they generate) which with the index bing binary is unverifiable. * Cleanup * Kotlin conversion cleanup and segmentation. * First step of ksp conversion * First step of ksp conversion * Fix delegate and index generation * Cleanup * Moved all tests to mockk Removed old unused dependencies Check generated source on top of functionality Split method and class elements into two sets for processing Fixed index generation for inner classes Added processor test with inner class Enabled ksp for sample project * Fix originating elements for Delegate generation. Fix originalting elment for Registry generation. Made unit test when running via ksp not to compiled code check. * Use | for separator of options * Fix argument and disable kapt plugin * Remove no unused jcenter Fix warning Updated gradle to 7.1 * Add Kapt test library to show setup for kapt. Clean up gralde plugin dependency for ksp. Updated documentation. * Use public version of xProcessorVersion Remove airbnb repo dependency * Add ktlint plugin and clean up the processor. Also add ktlint to ci checks. * Better error message match. * When running ksp allow the incremental flag to not be set and still get the custom processors from config. Use testKsp to test that behavior. * Cleanup. * Typos * Cleanup and Pr comments. * Rename .java to .kt * Made DeepLinkAnnotatedElement a sealed class Adde Kotlin source base tests. Cleanup/fixes * Enable failing tests * Kotlin conversion * Make sure to generate java source files in correct package like it is done for room (mentioned here tschuchortdev/kotlin-compile-testing#105 (comment)) but this also does not work. Disabled ksp test for inner classes in java because of tschuchortdev/kotlin-compile-testing#105 * Add missing import Add Kotlin based module * Add note about Kotlin source files when using KSP. * Remove note about kapt/ksp coexistance. Co-authored-by: Andreas Rossbacher <[email protected]>
looks like i broke something here:
0a0af2b
for some reason, KSP fails to resolve a nested class's type when it is in sources.
repro:
yigit@2e35c09
I initially thought this was a KSP problem but cannot reproduce it neither there nor in a test project.
google/ksp#263
The text was updated successfully, but these errors were encountered: