From dff4f43b83e243c030f15d8b6056defb911fecb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5Bp=CA=B2=C9=B5s=5D?= Date: Tue, 21 Jan 2020 00:34:59 +0100 Subject: [PATCH] Do not suppress a type system error (#2524) This code was sort of fine when it used raw Java types, but the Kotlin equivalent technically calls a method that takes a Nothing-typed argument with a value that is not of type Nothing. Whether that works depends on how lenient kotlinc is about inserting casts in bytecode. The solution is to give the unknown type represented by a star an explicit name by capturing it in a type variable, then cast to that type instead of Nothing. This is guaranteed to be an unchecked, but valid, cast. --- .../tachiyomi/ui/base/presenter/NucleusConductorDelegate.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/NucleusConductorDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/NucleusConductorDelegate.kt index 02ad4f966d..bce36974bd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/NucleusConductorDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/presenter/NucleusConductorDelegate.kt @@ -29,7 +29,9 @@ class NucleusConductorDelegate

>(private val factory: PresenterF bundle = presenterState } - @Suppress("TYPE_MISMATCH") + @Suppress("UNCHECKED_CAST") + private fun Presenter.takeView(view: Any) = takeView(view as View) + fun onTakeView(view: Any) { presenter?.takeView(view) }