Skip to content

Commit

Permalink
Avoid using UAST implementation classes in Lint checkers.
Browse files Browse the repository at this point in the history
`KotlinUClass.ktClass` is not supposed to be exposed and used this way.
Instead, `sourcePsi` is a good alternative in this use case.

RELNOTES=Avoid using UAST implementation classes in Lint checkers.
PiperOrigin-RevId: 402930753
  • Loading branch information
java-team-github-bot authored and Dagger Team committed Oct 13, 2021
1 parent 775de5e commit 44e1f05
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions java/dagger/lint/DaggerKotlinIssueDetector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import org.jetbrains.uast.UElement
import org.jetbrains.uast.UField
import org.jetbrains.uast.UMethod
import org.jetbrains.uast.getUastParentOfType
import org.jetbrains.uast.kotlin.KotlinUClass
import org.jetbrains.uast.toUElement

/**
Expand Down Expand Up @@ -257,6 +256,6 @@ class DaggerKotlinIssueDetector : Detector(), SourceCodeScanner {

/** @return whether or not the [this] is a Kotlin `object` type. */
private fun UClass.isObject(): Boolean {
return this is KotlinUClass && ktClass is KtObjectDeclaration
return sourcePsi is KtObjectDeclaration
}
}

0 comments on commit 44e1f05

Please sign in to comment.