Skip to content

Commit

Permalink
Enable jvm-default=all. (#1491)
Browse files Browse the repository at this point in the history
* Enable jvm-default=all.

* Revert.
  • Loading branch information
colinrtwhite authored Oct 9, 2022
1 parent 4a56342 commit 74ce8f0
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 41 deletions.
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Projects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private inline fun <reified T : BaseExtension> Project.setupBaseModule(
val arguments = mutableListOf(
// https://kotlinlang.org/docs/compiler-reference.html#progressive
"-progressive",
// Enable Java default method generation.
"-Xjvm-default=all",
// Generate smaller bytecode by not generating runtime not-null assertions.
"-Xno-call-assertions",
"-Xno-param-assertions",
Expand Down
55 changes: 28 additions & 27 deletions coil-base/api/coil-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ public final class coil/ComponentRegistry$Builder {
public abstract interface class coil/EventListener : coil/request/ImageRequest$Listener {
public static final field Companion Lcoil/EventListener$Companion;
public static final field NONE Lcoil/EventListener;
public abstract fun decodeEnd (Lcoil/request/ImageRequest;Lcoil/decode/Decoder;Lcoil/request/Options;Lcoil/decode/DecodeResult;)V
public abstract fun decodeStart (Lcoil/request/ImageRequest;Lcoil/decode/Decoder;Lcoil/request/Options;)V
public abstract fun fetchEnd (Lcoil/request/ImageRequest;Lcoil/fetch/Fetcher;Lcoil/request/Options;Lcoil/fetch/FetchResult;)V
public abstract fun fetchStart (Lcoil/request/ImageRequest;Lcoil/fetch/Fetcher;Lcoil/request/Options;)V
public abstract fun keyEnd (Lcoil/request/ImageRequest;Ljava/lang/String;)V
public abstract fun keyStart (Lcoil/request/ImageRequest;Ljava/lang/Object;)V
public abstract fun mapEnd (Lcoil/request/ImageRequest;Ljava/lang/Object;)V
public abstract fun mapStart (Lcoil/request/ImageRequest;Ljava/lang/Object;)V
public abstract fun onCancel (Lcoil/request/ImageRequest;)V
public abstract fun onError (Lcoil/request/ImageRequest;Lcoil/request/ErrorResult;)V
public abstract fun onStart (Lcoil/request/ImageRequest;)V
public abstract fun onSuccess (Lcoil/request/ImageRequest;Lcoil/request/SuccessResult;)V
public abstract fun resolveSizeEnd (Lcoil/request/ImageRequest;Lcoil/size/Size;)V
public abstract fun resolveSizeStart (Lcoil/request/ImageRequest;)V
public abstract fun transformEnd (Lcoil/request/ImageRequest;Landroid/graphics/Bitmap;)V
public abstract fun transformStart (Lcoil/request/ImageRequest;Landroid/graphics/Bitmap;)V
public abstract fun transitionEnd (Lcoil/request/ImageRequest;Lcoil/transition/Transition;)V
public abstract fun transitionStart (Lcoil/request/ImageRequest;Lcoil/transition/Transition;)V
public fun decodeEnd (Lcoil/request/ImageRequest;Lcoil/decode/Decoder;Lcoil/request/Options;Lcoil/decode/DecodeResult;)V
public fun decodeStart (Lcoil/request/ImageRequest;Lcoil/decode/Decoder;Lcoil/request/Options;)V
public fun fetchEnd (Lcoil/request/ImageRequest;Lcoil/fetch/Fetcher;Lcoil/request/Options;Lcoil/fetch/FetchResult;)V
public fun fetchStart (Lcoil/request/ImageRequest;Lcoil/fetch/Fetcher;Lcoil/request/Options;)V
public fun keyEnd (Lcoil/request/ImageRequest;Ljava/lang/String;)V
public fun keyStart (Lcoil/request/ImageRequest;Ljava/lang/Object;)V
public fun mapEnd (Lcoil/request/ImageRequest;Ljava/lang/Object;)V
public fun mapStart (Lcoil/request/ImageRequest;Ljava/lang/Object;)V
public fun onCancel (Lcoil/request/ImageRequest;)V
public fun onError (Lcoil/request/ImageRequest;Lcoil/request/ErrorResult;)V
public fun onStart (Lcoil/request/ImageRequest;)V
public fun onSuccess (Lcoil/request/ImageRequest;Lcoil/request/SuccessResult;)V
public fun resolveSizeEnd (Lcoil/request/ImageRequest;Lcoil/size/Size;)V
public fun resolveSizeStart (Lcoil/request/ImageRequest;)V
public fun transformEnd (Lcoil/request/ImageRequest;Landroid/graphics/Bitmap;)V
public fun transformStart (Lcoil/request/ImageRequest;Landroid/graphics/Bitmap;)V
public fun transitionEnd (Lcoil/request/ImageRequest;Lcoil/transition/Transition;)V
public fun transitionStart (Lcoil/request/ImageRequest;Lcoil/transition/Transition;)V
}

public final class coil/EventListener$Companion {
Expand Down Expand Up @@ -638,10 +638,10 @@ public final class coil/request/ImageRequest$Builder {
}

public abstract interface class coil/request/ImageRequest$Listener {
public abstract fun onCancel (Lcoil/request/ImageRequest;)V
public abstract fun onError (Lcoil/request/ImageRequest;Lcoil/request/ErrorResult;)V
public abstract fun onStart (Lcoil/request/ImageRequest;)V
public abstract fun onSuccess (Lcoil/request/ImageRequest;Lcoil/request/SuccessResult;)V
public fun onCancel (Lcoil/request/ImageRequest;)V
public fun onError (Lcoil/request/ImageRequest;Lcoil/request/ErrorResult;)V
public fun onStart (Lcoil/request/ImageRequest;)V
public fun onSuccess (Lcoil/request/ImageRequest;Lcoil/request/SuccessResult;)V
}

public final class coil/request/ImageRequest$Listener$DefaultImpls {
Expand Down Expand Up @@ -833,9 +833,10 @@ public final class coil/size/SizeResolvers {
}

public abstract interface class coil/size/ViewSizeResolver : coil/size/SizeResolver {
public abstract fun getSubtractPadding ()Z
public fun getSubtractPadding ()Z
public abstract fun getView ()Landroid/view/View;
public abstract fun size (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun size (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun size$suspendImpl (Lcoil/size/ViewSizeResolver;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class coil/size/ViewSizeResolver$DefaultImpls {
Expand Down Expand Up @@ -873,9 +874,9 @@ public class coil/target/ImageViewTarget : coil/target/GenericViewTarget {
}

public abstract interface class coil/target/Target {
public abstract fun onError (Landroid/graphics/drawable/Drawable;)V
public abstract fun onStart (Landroid/graphics/drawable/Drawable;)V
public abstract fun onSuccess (Landroid/graphics/drawable/Drawable;)V
public fun onError (Landroid/graphics/drawable/Drawable;)V
public fun onStart (Landroid/graphics/drawable/Drawable;)V
public fun onSuccess (Landroid/graphics/drawable/Drawable;)V
}

public final class coil/target/Target$DefaultImpls {
Expand Down
1 change: 1 addition & 0 deletions coil-base/src/main/java/coil/EventListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import coil.transition.TransitionTarget
*
* @see ImageLoader.Builder.eventListenerFactory
*/
@JvmDefaultWithCompatibility
interface EventListener : ImageRequest.Listener {

/**
Expand Down
1 change: 1 addition & 0 deletions coil-base/src/main/java/coil/request/ImageRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class ImageRequest private constructor(
/**
* A set of callbacks for an [ImageRequest].
*/
@JvmDefaultWithCompatibility
interface Listener {

/**
Expand Down
14 changes: 7 additions & 7 deletions coil-base/src/main/java/coil/request/RequestDelegate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ import coil.util.requestManager
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Job

internal sealed class RequestDelegate : DefaultLifecycleObserver {
internal sealed interface RequestDelegate : DefaultLifecycleObserver {

/** Throw a [CancellationException] if this request should be cancelled before starting. */
@MainThread
open fun assertActive() {}
fun assertActive() {}

/** Register all lifecycle observers. */
@MainThread
open fun start() {}
fun start() {}

/** Called when this request's job is cancelled or completes successfully/unsuccessfully. */
@MainThread
open fun complete() {}
fun complete() {}

/** Cancel this request's job and clear all lifecycle observers. */
@MainThread
open fun dispose() {}
fun dispose() {}
}

/** A request delegate for a one-shot requests with no target or a non-[ViewTarget]. */
internal class BaseRequestDelegate(
private val lifecycle: Lifecycle,
private val job: Job
) : RequestDelegate() {
) : RequestDelegate {

override fun start() {
lifecycle.addObserver(this)
Expand All @@ -59,7 +59,7 @@ internal class ViewTargetRequestDelegate(
private val target: ViewTarget<*>,
private val lifecycle: Lifecycle,
private val job: Job
) : RequestDelegate() {
) : RequestDelegate {

/** Repeat this request with the same [ImageRequest]. */
@MainThread
Expand Down
1 change: 1 addition & 0 deletions coil-base/src/main/java/coil/size/ViewSizeResolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fun <T : View> ViewSizeResolver(
/**
* A [SizeResolver] that measures the size of a [View].
*/
@JvmDefaultWithCompatibility
interface ViewSizeResolver<T : View> : SizeResolver {

/** The [View] to measure. This field should be immutable. */
Expand Down
1 change: 1 addition & 0 deletions coil-base/src/main/java/coil/target/Target.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.annotation.MainThread
/**
* A listener that accepts the result of an image request.
*/
@JvmDefaultWithCompatibility
interface Target {

/**
Expand Down
1 change: 1 addition & 0 deletions coil-base/src/main/java/coil/target/ViewTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.lifecycle.LifecycleObserver
* Optionally, [ViewTarget]s can implement [LifecycleObserver]. They are automatically registered
* when the request starts and unregistered when the request completes.
*/
@JvmDefaultWithCompatibility
interface ViewTarget<T : View> : Target {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import coil.target.Target
/**
* A [Target] that supports applying [Transition]s.
*/
@JvmDefaultWithCompatibility
interface TransitionTarget : Target {

/**
Expand Down
12 changes: 5 additions & 7 deletions coil-base/src/main/java/coil/util/HardwareBitmaps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,25 @@ internal fun HardwareBitmapService(logger: Logger?): HardwareBitmapService = whe
}

/** Decides if a request can use [Bitmap.Config.HARDWARE]. */
internal sealed class HardwareBitmapService {
internal sealed interface HardwareBitmapService {

/** Return 'true' if we are currently able to create [Bitmap.Config.HARDWARE]. */
@MainThread
abstract fun allowHardwareMainThread(size: Size): Boolean
fun allowHardwareMainThread(size: Size): Boolean

/** Perform any hardware bitmap allocation checks that cannot be done on the main thread. */
@WorkerThread
abstract fun allowHardwareWorkerThread(): Boolean
fun allowHardwareWorkerThread(): Boolean
}

/** Returns a fixed value for [allowHardwareMainThread] and [allowHardwareWorkerThread]. */
private class ImmutableHardwareBitmapService(private val allowHardware: Boolean) : HardwareBitmapService() {
private class ImmutableHardwareBitmapService(private val allowHardware: Boolean) : HardwareBitmapService {
override fun allowHardwareMainThread(size: Size) = allowHardware
override fun allowHardwareWorkerThread() = allowHardware
}

/** Guards against running out of file descriptors. */
private class LimitedFileDescriptorHardwareBitmapService(
private val logger: Logger?
) : HardwareBitmapService() {
private class LimitedFileDescriptorHardwareBitmapService(private val logger: Logger?) : HardwareBitmapService {

override fun allowHardwareMainThread(size: Size): Boolean {
return size.width.pxOrElse { Int.MAX_VALUE } > MIN_SIZE_DIMENSION &&
Expand Down

0 comments on commit 74ce8f0

Please sign in to comment.