Skip to content
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

Support generated JVM bytecode #95

Closed
ting-yuan opened this issue Sep 30, 2020 · 5 comments
Closed

Support generated JVM bytecode #95

ting-yuan opened this issue Sep 30, 2020 · 5 comments
Assignees
Labels
P2 affects usability but not blocks users
Milestone

Comments

@ting-yuan
Copy link
Collaborator

ting-yuan commented Sep 30, 2020

While KSP doesn't have any facility to support generating bytecode, it should pick up bytecode generated solely by processors and add them to compile classpath, so as to participate in later compilation.

@ting-yuan ting-yuan added the P2 affects usability but not blocks users label Sep 30, 2020
@ting-yuan ting-yuan self-assigned this Sep 30, 2020
@ting-yuan ting-yuan changed the title Support generated bytecode Support generated JVM bytecode Sep 30, 2020
@ZacSweers
Copy link
Contributor

Put up a prototype to test with here: ZacSweers/MoshiX#43

@ting-yuan ting-yuan added this to the 2020Q4 milestone Oct 4, 2020
@ting-yuan
Copy link
Collaborator Author

Fixed in #138.

@ZacSweers
Copy link
Contributor

I don't think this is resolved. I updated my bytecode generation branch linked above, and while the classes themselves do get generated, they don't link at compile-time

e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (83, 63): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (87, 5): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (87, 12): Unresolved reference: `data`
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (87, 45): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (87, 52): Unresolved reference: `data`
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (88, 5): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (88, 12): Unresolved reference: data2
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (88, 45): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (88, 52): Unresolved reference: data2
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (89, 5): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (89, 12): Unresolved reference: data3
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (89, 45): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (89, 52): Unresolved reference: data3
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (90, 12): Cannot access class 'dev.zacsweers.moshix.ksp.codegen.UntypedNestedPersonResponse'. Check your module classpath for missing or conflicting dependencies
e: /Users/zsweers/dev/kotlin/personal/moshi-sealed/moshi-ksp/tests/build/generated/ksp/src/test/kotlin/dev/zacsweers/moshix/ksp/codegen/UntypedNestedPersonResponseJsonAdapter.kt: (90, 12): Type mismatch: inferred type is UntypedNestedPersonResponse! but UntypedNestedPersonResponse<T> was expected

image

image

@neetopia neetopia reopened this Nov 11, 2020
ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Feb 18, 2022
* Report KSP logs in compilations

Resolves google#69. This is based on an implementation I've been using in my projects, and also works around internal access across modules via lesser-known suppression mechanism until kotlin finally finishes implementing friend-paths support in their gradle/IDE tooling.

* Add tests

* Remove unnecessary copy of MessageCollectorBasedKSPLogger

Co-authored-by: Thilo Schuchort <[email protected]>
@ZacSweers
Copy link
Contributor

Trying to revisit this in github.com/square/moshi and finding the above remains an issue. I'm also finding that KSP2 completely doesn't link generated code against class files, let alone class files against source files.

@ZacSweers
Copy link
Contributor

ZacSweers commented Jun 22, 2024

Reference where I've been working on this square/moshi#1858. You can reproduce it there by running the JsonClassSymbolProcessorTest tests. Note I'm able to reproduce this in both the kotlin-compile-testing programmatic runner as well as in Gradle (if you run the DualKotlinTest file with KSP mode enabled in that subproject's build)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 affects usability but not blocks users
Projects
None yet
Development

No branches or pull requests

3 participants