KT-30419 Box inline classes in return types of covariant overrides

Use boxed version of an inline class in return type position for
covariant and generic-specialized overrides.

Also fixes KT-35234 and KT-31585.
This commit is contained in:
Dmitry Petrov
2020-03-30 12:41:48 +03:00
parent e44f12d7b0
commit 24b8495e00
31 changed files with 1296 additions and 68 deletions
@@ -52,7 +52,7 @@ class BridgeTest : TestCase() {
return Fun(text)
}
private fun bridge(from: Fun, to: Fun): Bridge<Meth> = Bridge(Meth(from), Meth(to))
private fun bridge(from: Fun, to: Fun): Bridge<Meth, Fun> = Bridge(Meth(from), Meth(to), emptySet())
/**
* Constructs a graph out of the given pairs of vertices. First vertex should be a function in the derived class,
@@ -125,13 +125,17 @@ class BridgeTest : TestCase() {
}
}
private fun doTest(function: Fun, expectedBridges: Set<Bridge<Meth>>) {
private fun doTest(function: Fun, expectedBridges: Set<Bridge<Meth, Fun>>) {
val actualBridges = generateBridges(function, ::Meth)
assert(actualBridges.firstOrNull { it.from == it.to } == null) {
assert(actualBridges.all { it.from != it.to }) {
"A bridge invoking itself was generated, which makes no sense, since it will result in StackOverflowError" +
" once called: $actualBridges"
}
assertEquals(expectedBridges, actualBridges, "Expected and actual bridge sets differ for function $function")
assertEquals(
expectedBridges.map { it.from to it.to },
actualBridges.map { it.from to it.to },
"Expected and actual bridge sets differ for function $function"
)
}
// ------------------------------------------------------------------------------------------------------------------