tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 8cb97b84e630b90ab61aeb765e8487ef221161b1
parent 580df01aac93628da73473b3caf57d3787b00370
Author: Ryan VanderMeulen <rvandermeulen@mozilla.com>
Date:   Wed, 24 Dec 2025 15:50:06 +0000

Bug 1997078 - Suppress USELESS_CAST warnings in generated SafeArgs code. r=ahochheiden,android-reviewers,mcarare

Upstream issue:
https://issuetracker.google.com/issues/458082829

Differential Revision: https://phabricator.services.mozilla.com/D277193

Diffstat:
Mbuild/test/python/test_android_gradle_build.py | 6++++++
Mmobile/android/fenix/app/build.gradle | 26++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/build/test/python/test_android_gradle_build.py b/build/test/python/test_android_gradle_build.py @@ -167,6 +167,12 @@ def assert_all_task_statuses(objdir, acceptable_statuses, always_executed_tasks= # which get timestamps updated by the mach tasks above. Takes 0.000 seconds so not # a performance issue, but will be resolved when mach tasks get proper Gradle dependencies. ":geckoview:generateDebugAssets", + # Always executes because suppressUselessCastInSafeArgs sets `outputs.upToDateWhen { false }`. + # We could try using a marker file otherwise, but the task runtime is negligible and the added + # complexity doesn't seem worth it for what should only be a short-term workaround until Google + # fixes the upstream Navigation bug that led to it being added in the first place. + ":fenix:generateSafeArgsDebug", + ":fenix:suppressUselessCastInSafeArgs", ] build_metrics = get_test_run_build_metrics(objdir) diff --git a/mobile/android/fenix/app/build.gradle b/mobile/android/fenix/app/build.gradle @@ -834,6 +834,32 @@ tasks.register('printVariants') { } } +// Work around generated SafeArgs code hitting USELESS_CAST warnings with Kotlin 2.3+ +// https://issuetracker.google.com/issues/458082829 +def safeArgsSrc = fileTree(layout.buildDirectory.dir("generated/source/navigation-args")) { + include "**/*.kt" +} + +tasks.register("suppressUselessCastInSafeArgs") { + inputs.files(safeArgsSrc) + outputs.upToDateWhen { false } + + doLast { + safeArgsSrc.each { File f -> + if (!f.text.contains('@file:Suppress("USELESS_CAST")')) { + f.text = +"""@file:Suppress("USELESS_CAST") + +${f.text}""" + } + } + } +} + +tasks.matching { it.name.startsWith("generateSafeArgs") }.configureEach { + finalizedBy tasks.named("suppressUselessCastInSafeArgs") +} + afterEvaluate { // Format test output. Ported from AC #2401