Skip to content

Commit 086362d

Browse files
authored
Merge pull request github#10859 from tamasvajk/kotlin-field-masking
Kotlin: Exclude fields of live literals from `java/field-masks-super-field`
2 parents 3afb9c1 + bd9c7df commit 086362d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

java/ql/src/Violations of Best Practice/Naming Conventions/FieldMasksSuperField.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
import java
15+
private import semmle.code.java.frameworks.android.Compose
1516

1617
class VisibleInstanceField extends Field {
1718
VisibleInstanceField() {
@@ -28,6 +29,8 @@ where
2829
masked.getName() = masking.getName() and
2930
// Exclude intentional masking.
3031
not exists(VarAccess va | va.getVariable() = masked | va.getQualifier() instanceof SuperAccess) and
31-
type.fromSource()
32+
type.fromSource() and
33+
// Exclude live literal variables, which is generated code.
34+
not masking.getInitializer() instanceof LiveLiteral
3235
select masking, "This field shadows another field called $@ in a superclass.", masked,
3336
masked.getName()

0 commit comments

Comments
 (0)