Files
openide/jvm/jvm-analysis-kotlin-tests-shared/testData/codeInspection/nonExtendableApiUsage/plugin/kotlinExtensions.kt
Bart van Helvert 72b748d5e0 [kotlin] Run Kotlin JVM tests on both K1 and K2 frontend
#IDEA-354810 Fixed


(cherry picked from commit d29d3256472dfe368161335732ded20ae95cf34e)

IJ-MR-140910

GitOrigin-RevId: 0a9b3cae7aab473f732012ad91b4e67f97ff8697
2024-08-02 11:11:07 +00:00

67 lines
3.2 KiB
Kotlin

package plugin.kotlin
import library.JavaClass
import library.JavaInterface
import library.JavaMethodOwner
import library.JavaNestedClassOwner
import library.JavaNonExtendableNestedOwner
import library.KotlinClass
import library.KotlinInterface
import library.KotlinMethodOwner
import library.KotlinNestedClassOwner
import library.KotlinNonExtendableNestedOwner
//Extensions of Java classes
class JavaInheritor : <warning descr="Class 'library.JavaClass' must not be extended">JavaClass</warning>()
class JavaImplementor : <warning descr="Interface 'library.JavaInterface' must not be implemented">JavaInterface</warning>
interface JavaInterfaceInheritor : <warning descr="Interface 'library.JavaInterface' must not be extended">JavaInterface</warning>
class JavaMethodOverrider : JavaMethodOwner() {
override fun <warning descr="Method 'doNotOverride()' must not be overridden">doNotOverride</warning>() = Unit
}
class JavaNestedClassInheritor : library.JavaNestedClassOwner.NestedClass()
class JavaNonExtendableNestedInheritor : JavaNonExtendableNestedOwner.<warning descr="Class 'library.JavaNonExtendableNestedOwner.NonExtendableNested' must not be extended">NonExtendableNested</warning>()
//Extensions of Kotlin classes
class KotlinInheritor : <warning descr="Class 'library.KotlinClass' must not be extended">KotlinClass</warning>()
class KotlinImplementor : <warning descr="Interface 'library.KotlinInterface' must not be implemented">KotlinInterface</warning>
interface KotlinInterfaceInheritor : <warning descr="Interface 'library.KotlinInterface' must not be extended">KotlinInterface</warning>
class KotlinNestedClassInheritor : KotlinNestedClassOwner.NestedClass()
class KotlinNonExtendableNestedInheritor : KotlinNonExtendableNestedOwner.<warning descr="Class 'library.KotlinNonExtendableNestedOwner.NonExtendableNested' must not be extended">NonExtendableNested</warning>()
class KotlinMethodOverrider : KotlinMethodOwner() {
override fun <warning descr="Method 'doNotOverride()' must not be overridden">doNotOverride</warning>() = Unit
}
fun anonymousClasses() {
object : <warning descr="Class 'library.JavaClass' must not be extended">JavaClass</warning>() { }
object : <warning descr="Interface 'library.JavaInterface' must not be implemented">JavaInterface</warning> { }
object : <warning descr="Class 'library.KotlinClass' must not be extended">KotlinClass</warning>() { }
object : <warning descr="Interface 'library.KotlinInterface' must not be implemented">KotlinInterface</warning> { }
object : JavaNonExtendableNestedOwner.<warning descr="Class 'library.JavaNonExtendableNestedOwner.NonExtendableNested' must not be extended">NonExtendableNested</warning>() { }
object : KotlinNonExtendableNestedOwner.<warning descr="Class 'library.KotlinNonExtendableNestedOwner.NonExtendableNested' must not be extended">NonExtendableNested</warning>() { }
//No warnings.
object : JavaNestedClassOwner.NestedClass() { }
object : KotlinNestedClassOwner.NestedClass() { }
object : JavaMethodOwner() {
override fun <warning descr="Method 'doNotOverride()' must not be overridden">doNotOverride</warning>() = Unit
}
object : KotlinMethodOwner() {
override fun <warning descr="Method 'doNotOverride()' must not be overridden">doNotOverride</warning>() = Unit
}
}