Kotlin: Enable java/non-serializable-field for Kotlin

It now ignores compiler-generated classes
This commit is contained in:
Ian Lynagh
2022-11-25 17:10:03 +00:00
parent d53d275bba
commit cd8c40e063
2 changed files with 7 additions and 1 deletions

View File

@@ -55,6 +55,8 @@ string nonSerialReason(RefType t) {
predicate exceptions(Class c, Field f) {
f.getDeclaringType() = c and
(
c.isCompilerGenerated()
or
// `Serializable` objects with custom `readObject` or `writeObject` methods
// may write out the "non-serializable" fields in a different way.
c.declaresMethod("readObject")
@@ -90,7 +92,7 @@ predicate exceptions(Class c, Field f) {
from Class c, Field f, string reason
where
c.getFile().isJavaSourceFile() and
c.fromSource() and
c.getAStrictAncestor() instanceof TypeSerializable and
f.getDeclaringType() = c and
not exceptions(c, f) and