Get rid of SuspendFunctionX interfaces
Use a pair of effectively abstract methods in CoroutineImpl instead
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.codegen
|
package org.jetbrains.kotlin.codegen
|
||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
|
||||||
import org.jetbrains.kotlin.codegen.coroutines.createJvmSuspendFunctionView
|
import org.jetbrains.kotlin.codegen.coroutines.createJvmSuspendFunctionView
|
||||||
import org.jetbrains.kotlin.coroutines.isSuspendLambda
|
import org.jetbrains.kotlin.coroutines.isSuspendLambda
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
@@ -29,7 +28,6 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
|
||||||
|
|
||||||
class JvmRuntimeTypes(module: ModuleDescriptor) {
|
class JvmRuntimeTypes(module: ModuleDescriptor) {
|
||||||
private val kotlinJvmInternalPackage = MutablePackageFragmentDescriptor(module, FqName("kotlin.jvm.internal"))
|
private val kotlinJvmInternalPackage = MutablePackageFragmentDescriptor(module, FqName("kotlin.jvm.internal"))
|
||||||
@@ -89,10 +87,6 @@ class JvmRuntimeTypes(module: ModuleDescriptor) {
|
|||||||
add(coroutineImplClass.defaultType)
|
add(coroutineImplClass.defaultType)
|
||||||
|
|
||||||
if (descriptor.isSuspendLambda) {
|
if (descriptor.isSuspendLambda) {
|
||||||
val parametersNumber =
|
|
||||||
descriptor.valueParameters.size + (if (functionType.isExtensionFunctionType) 1 else 0)
|
|
||||||
|
|
||||||
addIfNotNull(suspendFunctions.getOrNull(parametersNumber)?.defaultType)
|
|
||||||
add(functionType)
|
add(functionType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package kotlin.jvm.internal
|
package kotlin.jvm.internal
|
||||||
|
|
||||||
import kotlin.coroutines.*
|
import java.lang.IllegalStateException
|
||||||
|
import kotlin.coroutines.Continuation
|
||||||
|
import kotlin.coroutines.ContinuationInterceptor
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.intrinsics.SUSPENDED_MARKER
|
import kotlin.coroutines.intrinsics.SUSPENDED_MARKER
|
||||||
|
|
||||||
abstract class CoroutineImpl(
|
abstract class CoroutineImpl(
|
||||||
@@ -63,4 +66,12 @@ abstract class CoroutineImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun doResume(data: Any?, exception: Throwable?): Any?
|
protected abstract fun doResume(data: Any?, exception: Throwable?): Any?
|
||||||
|
|
||||||
|
open fun create(completion: Continuation<*>): Continuation<Unit> {
|
||||||
|
throw IllegalStateException("create(Continuation) has not been overridden")
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun create(value: Any?, completion: Continuation<*>): Continuation<Unit> {
|
||||||
|
throw IllegalStateException("create(Any?;Continuation) has not been overridden")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package kotlin.jvm.internal
|
|
||||||
|
|
||||||
import kotlin.coroutines.Continuation
|
|
||||||
|
|
||||||
interface SuspendFunction0<out R> {
|
|
||||||
fun create(resultingContinuation: Continuation<R>): Continuation<Unit>
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SuspendFunction1<in T, out R> {
|
|
||||||
fun create(value: T, resultingContinuation: Continuation<R>): Continuation<Unit>
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ import kotlin.coroutines.intrinsics.*
|
|||||||
public fun <R, T> (suspend R.() -> T).createCoroutine(
|
public fun <R, T> (suspend R.() -> T).createCoroutine(
|
||||||
receiver: R,
|
receiver: R,
|
||||||
completion: Continuation<T>
|
completion: Continuation<T>
|
||||||
): Continuation<Unit> = (this as kotlin.jvm.internal.SuspendFunction1<R, T>).create(receiver, completion)
|
): Continuation<Unit> = (this as kotlin.jvm.internal.CoroutineImpl).create(receiver, completion)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts coroutine with receiver type [R] and result type [T].
|
* Starts coroutine with receiver type [R] and result type [T].
|
||||||
@@ -43,7 +43,7 @@ public fun <R, T> (suspend R.() -> T).startCoroutine(
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
public fun <T> (suspend () -> T).createCoroutine(
|
public fun <T> (suspend () -> T).createCoroutine(
|
||||||
completion: Continuation<T>
|
completion: Continuation<T>
|
||||||
): Continuation<Unit> = (this as kotlin.jvm.internal.SuspendFunction0<T>).create(completion)
|
): Continuation<Unit> = (this as kotlin.jvm.internal.CoroutineImpl).create(completion)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts coroutine without receiver and with result type [T].
|
* Starts coroutine without receiver and with result type [T].
|
||||||
|
|||||||
+2
-8
@@ -485,6 +485,8 @@ public abstract class kotlin/jvm/internal/CoroutineImpl : kotlin/jvm/internal/La
|
|||||||
protected field completion Lkotlin/coroutines/Continuation;
|
protected field completion Lkotlin/coroutines/Continuation;
|
||||||
protected field label I
|
protected field label I
|
||||||
public fun <init> (ILkotlin/coroutines/Continuation;)V
|
public fun <init> (ILkotlin/coroutines/Continuation;)V
|
||||||
|
public fun create (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
|
||||||
|
public fun create (Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
|
||||||
protected abstract fun doResume (Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
|
protected abstract fun doResume (Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
|
||||||
public fun getContext ()Lkotlin/coroutines/CoroutineContext;
|
public fun getContext ()Lkotlin/coroutines/CoroutineContext;
|
||||||
public final fun getFacade ()Lkotlin/coroutines/Continuation;
|
public final fun getFacade ()Lkotlin/coroutines/Continuation;
|
||||||
@@ -903,14 +905,6 @@ public final class kotlin/jvm/internal/StringCompanionObject {
|
|||||||
public static final field INSTANCE Lkotlin/jvm/internal/StringCompanionObject;
|
public static final field INSTANCE Lkotlin/jvm/internal/StringCompanionObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract interface class kotlin/jvm/internal/SuspendFunction0 {
|
|
||||||
public abstract fun create (Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract interface class kotlin/jvm/internal/SuspendFunction1 {
|
|
||||||
public abstract fun create (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class kotlin/jvm/internal/TypeIntrinsics {
|
public class kotlin/jvm/internal/TypeIntrinsics {
|
||||||
public fun <init> ()V
|
public fun <init> ()V
|
||||||
public static fun asMutableCollection (Ljava/lang/Object;)Ljava/util/Collection;
|
public static fun asMutableCollection (Ljava/lang/Object;)Ljava/util/Collection;
|
||||||
|
|||||||
Reference in New Issue
Block a user