mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Kotlin: Exclude constructs in serialization constructors from java/evaluation-to-constant
This commit is contained in:
@@ -3,6 +3,7 @@ import semmle.code.java.deadcode.DeadEnumConstant
|
||||
import semmle.code.java.deadcode.DeadCodeCustomizations
|
||||
import semmle.code.java.deadcode.DeadField
|
||||
import semmle.code.java.deadcode.EntryPoints
|
||||
private import semmle.code.java.frameworks.kotlin.Serialization
|
||||
|
||||
/**
|
||||
* Holds if the given callable has any liveness causes.
|
||||
@@ -309,10 +310,7 @@ class RootdefCallable extends Callable {
|
||||
this.isCompilerGenerated()
|
||||
or
|
||||
// Exclude Kotlin serialization constructors.
|
||||
this.(Constructor)
|
||||
.getParameterType(this.getNumberOfParameters() - 1)
|
||||
.(RefType)
|
||||
.hasQualifiedName("kotlinx.serialization.internal", "SerializationConstructorMarker")
|
||||
this instanceof SerializationConstructor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Provides classes and predicates for working with thi `kotlinx.serialization` plugin.
|
||||
*/
|
||||
|
||||
import java
|
||||
|
||||
/**
|
||||
* A constructor with a `SerializationConstructorMarker` parameter.
|
||||
*/
|
||||
class SerializationConstructor extends Constructor {
|
||||
SerializationConstructor() {
|
||||
this.getParameterType(this.getNumberOfParameters() - 1)
|
||||
.(RefType)
|
||||
.hasQualifiedName("kotlinx.serialization.internal", "SerializationConstructorMarker")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user