-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix open issue#11829 #12102
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
Closed
Closed
fix open issue#11829 #12102
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
test-suite-kotlin-ksp/src/test/java/io/micronaut/reproduce/Parent.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package io.micronaut.reproduce; | ||
|
|
||
| import io.micronaut.context.ApplicationContext; | ||
| import io.micronaut.context.annotation.Bean; | ||
| import jakarta.inject.Inject; | ||
|
|
||
| @Bean | ||
| public class Parent { | ||
| @Inject ApplicationContext context; | ||
|
|
||
| public ApplicationContext getContext() { | ||
| return context; | ||
| } | ||
| } | ||
|
|
16 changes: 16 additions & 0 deletions
16
test-suite-kotlin-ksp/src/test/kotlin/io/micronaut/reproduce/Child.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package io.micronaut.reproduce | ||
|
|
||
| import io.micronaut.context.annotation.Bean | ||
| import jakarta.annotation.PostConstruct | ||
|
|
||
| @Bean | ||
| class Child : Parent() { | ||
|
|
||
| @PostConstruct | ||
| fun init() { | ||
| // If KSP fails to inject, this will throw | ||
| check(context != null) { "context should be injected" } | ||
| } | ||
| } | ||
|
|
||
|
|
20 changes: 20 additions & 0 deletions
20
test-suite-kotlin-ksp/src/test/kotlin/io/micronaut/reproduce/reproduce.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package io.micronaut.reproduce | ||
|
|
||
| import io.micronaut.context.ApplicationContext | ||
| import org.junit.jupiter.api.Test | ||
| import org.junit.jupiter.api.assertThrows | ||
|
|
||
| class ReproduceIssueSpec { | ||
|
|
||
| @Test | ||
| fun `Kotlin child inherits field from Java parent with KSP`() { | ||
| val ctx = ApplicationContext.run() | ||
|
|
||
| // Correctly reference the class for Micronaut to create a bean | ||
| assertThrows<IllegalStateException> { | ||
| ctx.getBean(Child::class.java) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jarvx If you fix this bug, Why do you expect an error? It turns out that after your fix there shouldn't be an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I am working on a new fix currently. I'll close my existing PRs first.