Skip to content

Commit

Permalink
[K/N][tests] Couple of reproducers for #KT-67218
Browse files Browse the repository at this point in the history
  • Loading branch information
homuroll authored and qodana-bot committed Apr 30, 2024
1 parent 1a630b5 commit 9ac91e4
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
14 changes: 14 additions & 0 deletions kotlin-native/backend.native/tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2814,6 +2814,20 @@ standaloneTest("devirtualization_anonymousObject") {
source = "codegen/devirtualization/anonymousObject.kt"
}

standaloneTest("devirtualization_kt67281c") {
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
useGoldenData = true
flags = ["-opt"]
source = "codegen/devirtualization/kt67218c.kt"
}

standaloneTest("devirtualization_kt67281i") {
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
useGoldenData = true
flags = ["-opt"]
source = "codegen/devirtualization/kt67218i.kt"
}

tasks.register("interfaceCallsNCasts_conservativeItable", KonanLocalTest) {
useGoldenData = true
source = "codegen/interfaceCallsNCasts/conservativeItable.kt"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

open class A {
open fun foo() = 42
}

open class B : A() {
override fun foo() = 117
}

class C : A()

class D : A()

class E : B()

class F : B()

class G : B()

fun foo(a: A) = a.foo()

fun box(): String {
if (foo(E()) != 117) return "fail 1"
if (foo(F()) != 117) return "fail 2"
if (foo(G()) != 117) return "fail 3"
if (foo(C()) != 42) return "fail 4"
if (foo(D()) != 42) return "fail 5"

return "OK"
}

fun main() = println(box())
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

interface I {
fun foo() = 42
}

open class B : I {
override fun foo() = 117
}

class C : I

class D : I

class E : B()

class F : B()

class G : B()

fun foo(i: I) = i.foo()

fun box(): String {
if (foo(E()) != 117) return "fail 1"
if (foo(F()) != 117) return "fail 2"
if (foo(G()) != 117) return "fail 3"
if (foo(C()) != 42) return "fail 4"
if (foo(D()) != 42) return "fail 5"

return "OK"
}

fun main() = println(box())
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OK

0 comments on commit 9ac91e4

Please sign in to comment.