Fixed bugs in Kotlin Android Lint CleanupDetector
#KT-14780 Fixed #KT-14677 Fixed (cherry picked from commit f591b4958e4a836d37d70c2ad8ff15e626c6342a)
This commit is contained in:
+10
-2
@@ -1,7 +1,10 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintCommitTransactionInspection
|
||||
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.FragmentTransaction
|
||||
import android.app.FragmentManager
|
||||
import android.os.Bundle
|
||||
|
||||
class MainActivity : Activity() {
|
||||
@@ -17,8 +20,7 @@ class MainActivity : Activity() {
|
||||
transaction2.commit()
|
||||
|
||||
//WARNING
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val transaction3 = fragmentManager.<warning>beginTransaction</warning>()
|
||||
val transaction3 = fragmentManager.<warning descr="This transaction should be completed with a `commit()` call">beginTransaction</warning>()
|
||||
|
||||
//OK
|
||||
fragmentManager.beginTransaction().commit()
|
||||
@@ -30,4 +32,10 @@ class MainActivity : Activity() {
|
||||
a.commit()
|
||||
}
|
||||
}
|
||||
|
||||
// KT-14780: Kotlin Lint: "Missing commit() calls" false positive when the result of `commit()` is assigned or used as receiver
|
||||
fun testResultOfCommit(fm: FragmentManager) {
|
||||
val r1 = fm.beginTransaction().hide(fm.findFragmentByTag("aTag")).commit()
|
||||
val r2 = fm.beginTransaction().hide(fm.findFragmentByTag("aTag")).commit().toString()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user