Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ internal open class KotlinClassElement(
}

FieldElement::class.java -> {
classNode.getDeclaredProperties()
classNode.getAllProperties()
.filter {
it.hasBackingField && it.origin != Origin.SYNTHETIC
}
Expand Down
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;
}
}

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" }
}
}


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> {
Copy link
Contributor

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.

Copy link
Author

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.

ctx.getBean(Child::class.java)
}
}
}