-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[K/N][tests] Couple of reproducers for #KT-67218
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
kotlin-native/backend.native/tests/codegen/devirtualization/kt67218c.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
1 change: 1 addition & 0 deletions
1
kotlin-native/backend.native/tests/codegen/devirtualization/kt67218c.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OK |
36 changes: 36 additions & 0 deletions
36
kotlin-native/backend.native/tests/codegen/devirtualization/kt67218i.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
1 change: 1 addition & 0 deletions
1
kotlin-native/backend.native/tests/codegen/devirtualization/kt67218i.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OK |