-
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.
[Tests] KT-69681: correct synthetic accessor tests where a private ty…
…pe is leaked from the declaring file Some tests would be corrected after KT-71416
- Loading branch information
1 parent
8fe5fed
commit 8423f3f
Showing
38 changed files
with
392 additions
and
541 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...eUsageInsideNonPrivateInlineFunction/privateMember/leakingPrivateClassConstructorError.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,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<!>() | ||
} |
11 changes: 11 additions & 0 deletions
11
...sageInsideNonPrivateInlineFunction/privateMember/leakingPrivateClassConstructorWarning.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,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<!>() | ||
} |
11 changes: 11 additions & 0 deletions
11
...eInsideNonPrivateInlineFunction/privateMember/usePrivateFunInterfaceFromInlineFunError.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,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<!>() |
11 changes: 11 additions & 0 deletions
11
...nsideNonPrivateInlineFunction/privateMember/usePrivateFunInterfaceFromInlineFunWarning.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,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<!>() |
10 changes: 10 additions & 0 deletions
10
...geInsideNonPrivateInlineFunction/topLevelPrivate/leakingPrivateClassThroughtKlassError.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,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" | ||
} |
10 changes: 10 additions & 0 deletions
10
...InsideNonPrivateInlineFunction/topLevelPrivate/leakingPrivateClassThroughtKlassWarning.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,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" | ||
} |
14 changes: 14 additions & 0 deletions
14
...ivateInlineFunction/topLevelPrivate/leakingPrivateClassThroughtPrivateTopLevelFunError.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,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() | ||
} |
14 changes: 14 additions & 0 deletions
14
...ateInlineFunction/topLevelPrivate/leakingPrivateClassThroughtPrivateTopLevelFunWarning.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,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() | ||
} |
19 changes: 19 additions & 0 deletions
19
...sideNonPrivateInlineFunction/topLevelPrivate/leakingPrivateClassThroughtTypecheckError.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,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" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...deNonPrivateInlineFunction/topLevelPrivate/leakingPrivateClassThroughtTypecheckWarning.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,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" | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
...b/syntheticAccessors/privateMember/crossFilePrivateLeak/leakingPrivateClassConstructor.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ors/privateMember/crossFilePrivateLeak/leakingPrivateCompanionThroughInternalInlineFun.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
2 changes: 1 addition & 1 deletion
2
...rs/privateMember/crossFilePrivateLeak/leakingPrivateInnerClassThroughInternalInlineFun.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
2 changes: 1 addition & 1 deletion
2
...s/privateMember/crossFilePrivateLeak/leakingPrivateNestedClassThroughInternalInlineFun.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
22 changes: 0 additions & 22 deletions
22
...theticAccessors/privateMember/crossFilePrivateLeak/usePrivateFunInterfaceFromInlineFun.kt
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
...syntheticAccessors/privateMember/crossModulePrivateLeak/leakingPrivateClassConstructor.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...s/privateMember/crossModulePrivateLeak/leakingPrivateCompanionThroughInternalInlineFun.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
2 changes: 1 addition & 1 deletion
2
.../privateMember/crossModulePrivateLeak/leakingPrivateInnerClassThroughInternalInlineFun.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
2 changes: 1 addition & 1 deletion
2
...privateMember/crossModulePrivateLeak/leakingPrivateNestedClassThroughInternalInlineFun.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
24 changes: 0 additions & 24 deletions
24
...eticAccessors/privateMember/crossModulePrivateLeak/usePrivateFunInterfaceFromInlineFun.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...velPrivate/crossFilePrivateLeak/leakingPrivateClassFromLocalObjectInsideInternalInline.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
2 changes: 1 addition & 1 deletion
2
...icAccessors/topLevelPrivate/crossFilePrivateLeak/leakingPrivateClassThroughGenericType.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
18 changes: 0 additions & 18 deletions
18
...ntheticAccessors/topLevelPrivate/crossFilePrivateLeak/leakingPrivateClassThroughtKlass.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...ors/topLevelPrivate/crossFilePrivateLeak/leakingPrivateClassThroughtPrivateTopLevelFun.kt
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
...ticAccessors/topLevelPrivate/crossFilePrivateLeak/leakingPrivateClassThroughtTypecheck.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...lPrivate/crossModulePrivateLeak/leakingPrivateClassFromLocalObjectInsideInternalInline.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
2 changes: 1 addition & 1 deletion
2
...Accessors/topLevelPrivate/crossModulePrivateLeak/leakingPrivateClassThroughGenericType.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
Oops, something went wrong.