Test: inline class in binary dependencies

This commit is contained in:
Dmitry Petrov
2018-08-31 15:12:54 +03:00
parent ae0d980b54
commit 4c7430e990
2 changed files with 43 additions and 0 deletions
@@ -0,0 +1,38 @@
// !LANGUAGE: +InlineClasses
// FILE: A.kt
package z
interface IFoo {
fun foo(): String
}
inline class Z(val s: String) : IFoo {
constructor(i: Int) : this(i.toString())
override fun foo(): String = s
fun bar() = s
inline fun <T> run(lambda: (String) -> T) = lambda(s)
companion object {
fun z(i: Int) = Z(i)
}
}
// FILE: B.kt
import z.*
fun test(z: Z) {
if (z.foo() != "1234") throw AssertionError()
if (z.bar() != "1234") throw AssertionError()
if (z.run { it } != "1234") throw AssertionError()
if (listOf(z)[0].s != "1234") throw AssertionError()
}
fun box(): String {
test(Z("1234"))
test(Z(1234))
test(Z.z(1234))
return "OK"
}
@@ -123,6 +123,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
runTest("compiler/testData/compileKotlinAgainstKotlin/enum.kt");
}
@TestMetadata("inlineClassFromBinaryDependencies.kt")
public void testInlineClassFromBinaryDependencies() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt");
}
@TestMetadata("inlinedConstants.kt")
public void testInlinedConstants() throws Exception {
runTest("compiler/testData/compileKotlinAgainstKotlin/inlinedConstants.kt");