Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PlatformContext's companion object instead of PlatformContext.INSTANCE #2814

Closed
wants to merge 2 commits into from

Conversation

MoeRepo
Copy link

@MoeRepo MoeRepo commented Jan 26, 2025

Changelog

Use PlatformContext's companion object instead of PlatformContext.INSTANCE.

This code style exists in the official Kotlin library, such as kotlin.io.encoding.Base64 and kotlinx.serialization.json.Json classes.

One object is reduced, which can theoretically improve performance slightly.

This brings API changes. In some cases, the compiler may infer the PlatformContext.Companion type instead of PlatformContext.

Please run ./test.sh before submitting to ensure your pull request passes the automated checks.

  • gradlew apiCheck spotlessCheck
API check failed for project coil-core.
--- C:\Users\0\AndroidStudioProjects\coil\coil-core\build\api\klib-all\extracted\coil-core.klib.api
+++ C:\Users\0\AndroidStudioProjects\coil\coil-core\build\api\klib\coil-core.klib.api
@@ -430,10 +430,7 @@
 }
 
 abstract class coil3/PlatformContext { // coil3/PlatformContext|null[0]
-    final object Companion { // coil3/PlatformContext.Companion|null[0]
-        final val INSTANCE // coil3/PlatformContext.Companion.INSTANCE|{}INSTANCE[0]
-            final fun <get-INSTANCE>(): coil3/PlatformContext // coil3/PlatformContext.Companion.INSTANCE.<get-INSTANCE>|<get-INSTANCE>(){}[0]
-    }
+    final object Default : coil3/PlatformContext // coil3/PlatformContext.Default|null[0]
 }
 
 final class coil3.decode/BlackholeDecoder : coil3.decode/Decoder { // coil3.decode/BlackholeDecoder|null[0]

You can run :coil-core:apiDump task to overwrite API declarations
  • gradlew allTests testDebugUnitTest connectedDebugAndroidTest validateDebugScreenshotTest verifyPaparazziDebug verifyRoborazziDebug verifyRoborazziJvm

    I only have Windows devices. When I run the test, I get a lot of errors related to filePath.

    After checking, there are no errors related to this change.

@colinrtwhite
Copy link
Member

@MoeRepo Unfortunately we're not able to make this change as it breaks binary compatibility.

@MoeRepo MoeRepo closed this Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants