From 3e66d42be4b4cc382d3d1dd58713a213997df5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nivaldo=20Bondan=C3=A7a?= Date: Mon, 6 Nov 2023 15:38:37 -0800 Subject: [PATCH] [GH] Simple changes to fix AbstractMethodError from issue b/204328129 Please see [b/204328129](https://issuetracker.google.com/issues/204328129) for more details on the issue. Basically this is something necessary to help prevent weird compilation errors that happen with the Buck/Redex build toolchains that Meta uses. Not something meaningful, but since the change is dead simple I guess it shall pass. Test: This has been something that was patched on Meta source and we've been testing it for multiple prod releases of Threads, we're only now porting the change to Google because it seems appropriate. Fixes: b/204328129 This is an imported pull request from https://github.com/androidx/androidx/pull/625. Resolves #625 Github-Pr-Head-Sha: 05687415f1aec272e01b89764ab68d87cacdd639 GitOrigin-RevId: 023a53dd11c5486e28226fbbad8119c24454d790 (cherry picked from https://android-review.googlesource.com/q/commit:ca6fa30821e365ed3976bbcd0202c38b9da2c842) Merged-In: I5b3fe39e54ffd4f97234c0ff23e54f9b790b2f0f Change-Id: I5b3fe39e54ffd4f97234c0ff23e54f9b790b2f0f --- .../CharSequenceCharacterIteratorTest.kt | 18 ++++++++++++++++++ .../android/CharSequenceCharacterIterator.kt | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 text/text/src/androidTest/java/androidx/compose/ui/text/android/CharSequenceCharacterIteratorTest.kt diff --git a/text/text/src/androidTest/java/androidx/compose/ui/text/android/CharSequenceCharacterIteratorTest.kt b/text/text/src/androidTest/java/androidx/compose/ui/text/android/CharSequenceCharacterIteratorTest.kt new file mode 100644 index 0000000000000..52d4ab774bb16 --- /dev/null +++ b/text/text/src/androidTest/java/androidx/compose/ui/text/android/CharSequenceCharacterIteratorTest.kt @@ -0,0 +1,18 @@ +package androidx.compose.ui.text.android + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@SmallTest +@RunWith(AndroidJUnit4::class) +class CharSequenceCharacterIteratorTest { + @Test + fun canClone() { + val subject = CharSequenceCharacterIterator("", 0, 0) + val cloned = subject.clone() + assertThat(subject).isNotSameInstanceAs(cloned) + } +} diff --git a/text/text/src/main/java/androidx/compose/ui/text/android/CharSequenceCharacterIterator.kt b/text/text/src/main/java/androidx/compose/ui/text/android/CharSequenceCharacterIterator.kt index a46277c308ad6..d2bbc36273d2b 100644 --- a/text/text/src/main/java/androidx/compose/ui/text/android/CharSequenceCharacterIterator.kt +++ b/text/text/src/main/java/androidx/compose/ui/text/android/CharSequenceCharacterIterator.kt @@ -29,11 +29,12 @@ import java.text.CharacterIterator * @param start The index of the beginning of the range. * @param end The index of the end of the range. */ +@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") internal class CharSequenceCharacterIterator( private val charSequence: CharSequence, private val start: Int, private val end: Int -) : CharacterIterator { +) : Object() /* see b/204328129 */, CharacterIterator { private var index: Int = start /** @@ -173,7 +174,6 @@ internal class CharSequenceCharacterIterator( */ override fun clone(): Any { return try { - @Suppress("ABSTRACT_SUPER_CALL") super.clone() } catch (e: CloneNotSupportedException) { throw InternalError()