Add CAST_NEVER_SUCCEEDS diagnostic to forwardDeclarations.kt
Add safe as casts to forwardDeclarations.kt ^KT-58929
This commit is contained in:
committed by
Space Team
parent
f5bd7cee05
commit
28f90b3ea8
@@ -48,7 +48,7 @@ interface FwdProtocol
|
||||
// FILE: main.kt
|
||||
|
||||
// this inspections differs in K1/K2, but unrelated to what is tested in this test
|
||||
@file:Suppress("CAST_NEVER_SUCCEEDS", "UNUSED_PARAMETER", "UNUSED_EXPRESSION", "UNUSED_VARIABLE", <!ERROR_SUPPRESSION!>"INCOMPATIBLE_TYPES"<!>)
|
||||
@file:Suppress("UNUSED_PARAMETER", "UNUSED_EXPRESSION", "UNUSED_VARIABLE", <!ERROR_SUPPRESSION!>"INCOMPATIBLE_TYPES"<!>)
|
||||
|
||||
fun testUnckeckedAsFromAny(x: Any) {
|
||||
<!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as? cnames.structs.FwdStruct<!>
|
||||
@@ -95,6 +95,9 @@ fun testInline4() {
|
||||
fun testCheckedAs1(x : lib.FwdStruct) = x as cnames.structs.FwdStruct
|
||||
fun testCheckedAs2(x : lib.FwdObjcClass) = x as objcnames.classes.FwdObjcClass
|
||||
fun testCheckedAs3(x : lib.FwdProtocol) = x as objcnames.protocols.FwdProtocol
|
||||
fun testCheckedSafeAs4(x : lib.FwdStruct) = x as? cnames.structs.FwdStruct
|
||||
fun testCheckedSafeAs5(x : lib.FwdObjcClass) = x as? objcnames.classes.FwdObjcClass
|
||||
fun testCheckedSafeAs6(x : lib.FwdProtocol) = x as? objcnames.protocols.FwdProtocol
|
||||
|
||||
fun testUnCheckedAs1(x : lib2.FwdStruct) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as cnames.structs.FwdStruct<!>
|
||||
fun testUnCheckedAs2(x : lib2.FwdObjcClass) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.classes.FwdObjcClass<!>
|
||||
|
||||
@@ -48,7 +48,7 @@ interface FwdProtocol
|
||||
// FILE: main.kt
|
||||
|
||||
// this inspections differs in K1/K2, but unrelated to what is tested in this test
|
||||
@file:Suppress("CAST_NEVER_SUCCEEDS", "UNUSED_PARAMETER", "UNUSED_EXPRESSION", "UNUSED_VARIABLE", "INCOMPATIBLE_TYPES")
|
||||
@file:Suppress("UNUSED_PARAMETER", "UNUSED_EXPRESSION", "UNUSED_VARIABLE", "INCOMPATIBLE_TYPES")
|
||||
|
||||
fun testUnckeckedAsFromAny(x: Any) {
|
||||
<!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as? cnames.structs.FwdStruct<!>
|
||||
@@ -92,12 +92,15 @@ fun testInline4() {
|
||||
val c : (objcnames.protocols.FwdProtocol) -> Unit = ::<!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>inlineF<!>
|
||||
}
|
||||
|
||||
fun testCheckedAs1(x : lib.FwdStruct) = x as cnames.structs.FwdStruct
|
||||
fun testCheckedAs2(x : lib.FwdObjcClass) = x as objcnames.classes.FwdObjcClass
|
||||
fun testCheckedAs1(x : lib.FwdStruct) = x <!CAST_NEVER_SUCCEEDS!>as<!> cnames.structs.FwdStruct
|
||||
fun testCheckedAs2(x : lib.FwdObjcClass) = x <!CAST_NEVER_SUCCEEDS!>as<!> objcnames.classes.FwdObjcClass
|
||||
fun testCheckedAs3(x : lib.FwdProtocol) = x as objcnames.protocols.FwdProtocol
|
||||
fun testCheckedSafeAs4(x : lib.FwdStruct) = x <!CAST_NEVER_SUCCEEDS!>as?<!> cnames.structs.FwdStruct
|
||||
fun testCheckedSafeAs5(x : lib.FwdObjcClass) = x <!CAST_NEVER_SUCCEEDS!>as?<!> objcnames.classes.FwdObjcClass
|
||||
fun testCheckedSafeAs6(x : lib.FwdProtocol) = x as? objcnames.protocols.FwdProtocol
|
||||
|
||||
fun testUnCheckedAs1(x : lib2.FwdStruct) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as cnames.structs.FwdStruct<!>
|
||||
fun testUnCheckedAs2(x : lib2.FwdObjcClass) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.classes.FwdObjcClass<!>
|
||||
fun testUnCheckedAs1(x : lib2.FwdStruct) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x <!CAST_NEVER_SUCCEEDS!>as<!> cnames.structs.FwdStruct<!>
|
||||
fun testUnCheckedAs2(x : lib2.FwdObjcClass) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x <!CAST_NEVER_SUCCEEDS!>as<!> objcnames.classes.FwdObjcClass<!>
|
||||
fun testUnCheckedAs3(x : lib2.FwdProtocol) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.protocols.FwdProtocol<!>
|
||||
|
||||
fun testUnCheckedAs4(x : lib.FwdStruct) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.classes.FwdObjcClass<!>
|
||||
fun testUnCheckedAs4(x : lib.FwdStruct) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x <!CAST_NEVER_SUCCEEDS!>as<!> objcnames.classes.FwdObjcClass<!>
|
||||
|
||||
Reference in New Issue
Block a user