Merge pull request #10859 from tamasvajk/kotlin-field-masking

Kotlin: Exclude fields of live literals from `java/field-masks-super-field`
This commit is contained in:
Tamás Vajk
2022-10-19 11:19:44 +02:00
committed by GitHub

View File

@@ -12,6 +12,7 @@
*/
import java
private import semmle.code.java.frameworks.android.Compose
class VisibleInstanceField extends Field {
VisibleInstanceField() {
@@ -28,6 +29,8 @@ where
masked.getName() = masking.getName() and
// Exclude intentional masking.
not exists(VarAccess va | va.getVariable() = masked | va.getQualifier() instanceof SuperAccess) and
type.fromSource()
type.fromSource() and
// Exclude live literal variables, which is generated code.
not masking.getInitializer() instanceof LiveLiteral
select masking, "This field shadows another field called $@ in a superclass.", masked,
masked.getName()