[FIR] Resolve the continuation type inside createSuspendView()
Normally such types are resolved during enhancement, but creating the suspend view happens before enhancement, so the type may have not been resolved. ^KT-59915 Fixed
This commit is contained in:
committed by
Space Team
parent
1467e743fd
commit
aacfc31c90
+4
@@ -21,10 +21,12 @@ import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass
|
|||||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaMethod
|
import org.jetbrains.kotlin.fir.java.declarations.FirJavaMethod
|
||||||
import org.jetbrains.kotlin.fir.java.declarations.buildJavaMethodCopy
|
import org.jetbrains.kotlin.fir.java.declarations.buildJavaMethodCopy
|
||||||
import org.jetbrains.kotlin.fir.java.declarations.buildJavaValueParameterCopy
|
import org.jetbrains.kotlin.fir.java.declarations.buildJavaValueParameterCopy
|
||||||
|
import org.jetbrains.kotlin.fir.java.resolveIfJavaType
|
||||||
import org.jetbrains.kotlin.fir.java.syntheticPropertiesStorage
|
import org.jetbrains.kotlin.fir.java.syntheticPropertiesStorage
|
||||||
import org.jetbrains.kotlin.fir.java.symbols.FirJavaOverriddenSyntheticPropertySymbol
|
import org.jetbrains.kotlin.fir.java.symbols.FirJavaOverriddenSyntheticPropertySymbol
|
||||||
import org.jetbrains.kotlin.fir.java.toConeKotlinTypeProbablyFlexible
|
import org.jetbrains.kotlin.fir.java.toConeKotlinTypeProbablyFlexible
|
||||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.providers.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.scopes.*
|
import org.jetbrains.kotlin.fir.scopes.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.AbstractFirUseSiteMemberScope
|
import org.jetbrains.kotlin.fir.scopes.impl.AbstractFirUseSiteMemberScope
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirTypeIntersectionScopeContext.ResultOfIntersection
|
import org.jetbrains.kotlin.fir.scopes.impl.FirTypeIntersectionScopeContext.ResultOfIntersection
|
||||||
@@ -334,8 +336,10 @@ class JavaClassUseSiteMemberScope(
|
|||||||
|
|
||||||
private fun FirNamedFunctionSymbol.createSuspendView(): FirSimpleFunction? {
|
private fun FirNamedFunctionSymbol.createSuspendView(): FirSimpleFunction? {
|
||||||
val continuationParameter = fir.valueParameters.lastOrNull() ?: return null
|
val continuationParameter = fir.valueParameters.lastOrNull() ?: return null
|
||||||
|
val owner = classId.toSymbol(session)?.fir as? FirJavaClass ?: return null
|
||||||
val continuationParameterType = continuationParameter
|
val continuationParameterType = continuationParameter
|
||||||
.returnTypeRef
|
.returnTypeRef
|
||||||
|
.resolveIfJavaType(session, owner.javaTypeParameterStack)
|
||||||
.coneTypeSafe<ConeKotlinType>()
|
.coneTypeSafe<ConeKotlinType>()
|
||||||
?.lowerBoundIfFlexible() as? ConeClassLikeType
|
?.lowerBoundIfFlexible() as? ConeClassLikeType
|
||||||
?: return null
|
?: return null
|
||||||
|
|||||||
Vendored
-50
@@ -1,50 +0,0 @@
|
|||||||
// FILE: I.kt
|
|
||||||
|
|
||||||
interface I {
|
|
||||||
suspend fun foo(x: Int): String
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: JavaClass.java
|
|
||||||
import kotlin.coroutines.Continuation;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class JavaClass implements I {
|
|
||||||
@Override
|
|
||||||
public Object foo(int x, @NotNull Continuation<? super String> continuation) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: main.kt
|
|
||||||
|
|
||||||
import kotlin.coroutines.Continuation
|
|
||||||
class K1 : JavaClass()
|
|
||||||
|
|
||||||
class K2 : JavaClass() {
|
|
||||||
override suspend fun foo(x: Int): String = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
class K3 : JavaClass() {
|
|
||||||
override fun foo(x: Int, y: Continuation<String>): Any? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun builder(block: suspend () -> Unit) {}
|
|
||||||
|
|
||||||
fun main(x: Continuation<String>) {
|
|
||||||
JavaClass().foo(5, x)
|
|
||||||
K1().foo(6, x)
|
|
||||||
K2().foo(7, x)
|
|
||||||
K3().foo(8, x)
|
|
||||||
|
|
||||||
builder {
|
|
||||||
JavaClass().foo(1)
|
|
||||||
K1().foo(2)
|
|
||||||
K2().foo(3)
|
|
||||||
K3().foo(4)
|
|
||||||
|
|
||||||
JavaClass().foo(5, x)
|
|
||||||
K1().foo(6, x)
|
|
||||||
K2().foo(7, x)
|
|
||||||
K3().foo(8, x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// FILE: I.kt
|
// FILE: I.kt
|
||||||
|
|
||||||
interface I {
|
interface I {
|
||||||
|
|||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
// FILE: I.kt
|
|
||||||
|
|
||||||
interface I {
|
|
||||||
suspend fun foo(x: Int): String
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: JavaClass.java
|
|
||||||
import kotlin.coroutines.Continuation;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class JavaClass implements I {
|
|
||||||
@Override
|
|
||||||
public Object foo(int x, @NotNull Continuation<? super String> continuation) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: main.kt
|
|
||||||
|
|
||||||
import kotlin.coroutines.Continuation
|
|
||||||
class K1 : JavaClass()
|
|
||||||
|
|
||||||
class K2 : JavaClass() {
|
|
||||||
override suspend fun foo(x: Int): String = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
class K3 : JavaClass() {
|
|
||||||
override fun foo(x: Int, y: Continuation<String>): Any? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun builder(block: suspend () -> Unit) {}
|
|
||||||
|
|
||||||
fun main(x: Continuation<String>) {
|
|
||||||
JavaClass().foo(5, x)
|
|
||||||
K1().foo(6, x)
|
|
||||||
K2().foo(7, x)
|
|
||||||
K3().foo(8, x)
|
|
||||||
|
|
||||||
builder {
|
|
||||||
JavaClass().foo(1)
|
|
||||||
K1().foo(2)
|
|
||||||
K2().foo(3)
|
|
||||||
K3().foo(4)
|
|
||||||
|
|
||||||
JavaClass().foo(5, x)
|
|
||||||
K1().foo(6, x)
|
|
||||||
K2().foo(7, x)
|
|
||||||
K3().foo(8, x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// FILE: I.kt
|
// FILE: I.kt
|
||||||
|
|
||||||
interface I {
|
interface I {
|
||||||
|
|||||||
Reference in New Issue
Block a user