Skip to content

Commit

Permalink
[Tests] KT-69681: correct synthetic accessor tests where a private ty…
Browse files Browse the repository at this point in the history
…pe is leaked from the declaring file

Some tests would be corrected after KT-71416
  • Loading branch information
AnzhelaSukhanova authored and Space Team committed Nov 8, 2024
1 parent 8fe5fed commit 8423f3f
Show file tree
Hide file tree
Showing 38 changed files with 392 additions and 541 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// LANGUAGE: +ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private class Private {
fun foo() = "OK"
}

internal inline fun internalInlineFun(): String {
return <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!><!PRIVATE_CLASS_MEMBER_FROM_INLINE!>Private<!>()<!>.<!PRIVATE_CLASS_MEMBER_FROM_INLINE!>foo<!>()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// LANGUAGE: -ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private class Private {
fun foo() = "OK"
}

internal inline fun internalInlineFun(): String {
return <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!><!PRIVATE_CLASS_MEMBER_FROM_INLINE!>Private<!>()<!>.<!PRIVATE_CLASS_MEMBER_FROM_INLINE!>foo<!>()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// LANGUAGE: +ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private fun interface I {
fun foo(): Int
}

inline fun publicInlineFun(): Int = (<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>I { 1 }<!>).<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>foo<!>()

internal inline fun internalInlineFun(): Int = (<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>I { 1 }<!>).<!PRIVATE_CLASS_MEMBER_FROM_INLINE!>foo<!>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// LANGUAGE: -ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private fun interface I {
fun foo(): Int
}

inline fun publicInlineFun(): Int = (<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>I { 1 }<!>).<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>foo<!>()

internal inline fun internalInlineFun(): Int = (<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>I { 1 }<!>).<!PRIVATE_CLASS_MEMBER_FROM_INLINE!>foo<!>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// LANGUAGE: +ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private class Private

internal inline fun getPrivateKlass(): String {
<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>val klass = <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>Private::class<!><!>
return <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>klass<!>.simpleName ?: "null"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// LANGUAGE: -ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private class Private

internal inline fun getPrivateKlass(): String {
<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>val klass = <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>Private::class<!><!>
return <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>klass<!>.simpleName ?: "null"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// For now the checker is working before inlining. The test should be corrected after KT-71416.
// LANGUAGE: +ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

interface Foo

private class FooImpl : Foo

private inline fun privateMethod(): Foo = FooImpl()

internal inline fun internalMethod(): Foo {
return privateMethod()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// For now the checker is working before inlining. The test should be corrected after KT-71416.
// LANGUAGE: -ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

interface Foo

private class FooImpl : Foo

private inline fun privateMethod(): Foo = FooImpl()

internal inline fun internalMethod(): Foo {
return privateMethod()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// LANGUAGE: +ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private class Private

internal inline fun isPrivate(obj: Any): String = when (obj) {
<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>is Private<!> -> "isPrivate"
else -> "OK1"
}

internal inline fun asPrivate(obj: Any): String {
try {
<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>val privateObj = <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_ERROR!>obj as Private<!><!>
return "asPrivate"
} catch (e: ClassCastException) {
return "OK2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// LANGUAGE: -ForbidExposureOfPrivateTypesInNonPrivateInlineFunctionsInKlibs
// DIAGNOSTICS: -NOTHING_TO_INLINE
// FIR_IDENTICAL

private class Private

internal inline fun isPrivate(obj: Any): String = when (obj) {
<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>is Private<!> -> "isPrivate"
else -> "OK1"
}

internal inline fun asPrivate(obj: Any): String {
try {
<!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>val privateObj = <!IR_PRIVATE_TYPE_USED_IN_NON_PRIVATE_INLINE_FUNCTION_WARNING!>obj as Private<!><!>
return "asPrivate"
} catch (e: ClassCastException) {
return "OK2"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// FILE: A.kt
class A {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// FILE: A.kt
class A {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// FILE: A.kt
class A {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// MODULE: lib
// FILE: A.kt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// MODULE: lib
// FILE: A.kt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// MODULE: lib
// FILE: A.kt
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// FILE: A.kt
private open class A {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// FILE: a.kt
private class Private
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// MODULE: lib
// FILE: A.kt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// IGNORE_BACKEND: ANY
// ^^^ Muted because a private type is leaked from the declaring file, and the visibility validator detects this.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681.
// This test should be converted to a test that checks reporting private types exposure. To be done in KT-69681 and KT-71416.

// MODULE: lib
// FILE: a.kt
Expand Down
Loading

0 comments on commit 8423f3f

Please sign in to comment.