Skip to content

Commit

Permalink
Repro
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Jul 4, 2023
1 parent f075120 commit 340323e
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.springframework.context.annotation
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.getBean
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException

Expand All @@ -39,6 +40,13 @@ class KotlinConfigurationClassTests {
assertThat(context.getBean<Bar>().foo).isEqualTo(foo)
}

@Test
fun `Configuration with declaration site variance`() {
val context = AnnotationConfigApplicationContext(ConfigurationWithDeclarationSiteVariance::class.java)
val config = context.getBean<ConfigurationWithDeclarationSiteVariance>()
assertThat(config.container).isNotNull()
}


@Configuration
class FinalConfigurationWithProxy {
Expand All @@ -63,4 +71,23 @@ class KotlinConfigurationClassTests {
class Foo

class Bar(val foo: Foo)

@Configuration(proxyBeanMethods = false)
class ConfigurationWithDeclarationSiteVariance {

@Autowired
lateinit var container: Container<Tuple<String, String>>

@Bean
fun container() : TupleContainer {
return TupleContainer()
}

}

// Works with class Tuple<A, B>
class Tuple<out A, out B>
interface Container<T>
class TupleContainer : Container<Tuple<String, String>>

}

0 comments on commit 340323e

Please sign in to comment.