Prohibit serializable annotation on local classes and anonymous objects

#KT-45541 Fixed
This commit is contained in:
Leonid Startsev
2021-03-18 18:25:53 +03:00
parent 3b789448a3
commit c66cddc442
5 changed files with 39 additions and 11 deletions
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// WITH_RUNTIME
// SKIP_TXT
import kotlinx.serialization.*
fun container() {
<!LOCAL_CLASSES_NOT_SUPPORTED!>@Serializable<!>
class X
val y = <!LOCAL_CLASSES_NOT_SUPPORTED!>@Serializable<!> object {}
}
val topLevelAnon = <!LOCAL_CLASSES_NOT_SUPPORTED!>@Serializable<!> object {}
@Serializable class A {
@Serializable class B // nesting classes are allowed
}