From 8b373bd624439e17981c8a1791de8320fe5a49fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Thu, 9 Jan 2025 16:46:00 +0100 Subject: [PATCH] Fix tailrec as this was not a tailrec function --- .../core/android/common/activity/ContextExtensions.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/android/common/src/main/kotlin/app/k9mail/core/android/common/activity/ContextExtensions.kt b/core/android/common/src/main/kotlin/app/k9mail/core/android/common/activity/ContextExtensions.kt index 67767acc8ab..f2a929477f8 100644 --- a/core/android/common/src/main/kotlin/app/k9mail/core/android/common/activity/ContextExtensions.kt +++ b/core/android/common/src/main/kotlin/app/k9mail/core/android/common/activity/ContextExtensions.kt @@ -7,5 +7,10 @@ import android.content.Context import android.content.ContextWrapper // Source: https://stackoverflow.com/a/58249983 -tailrec fun Context.findActivity(): Activity? = this as? Activity - ?: (this as? ContextWrapper)?.baseContext?.findActivity() +tailrec fun Context.findActivity(): Activity? { + return if (this is Activity) { + this + } else { + (this as? ContextWrapper)?.baseContext?.findActivity() + } +}