提交 346ffb3a 编写于 作者: M Mikhail Glukhikh

FIR2IR: support substitution for SAM types

上级 7050af9b
...@@ -25,6 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.fullyExpandedType ...@@ -25,6 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents
import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType
import org.jetbrains.kotlin.fir.resolve.inference.isKMutableProperty import org.jetbrains.kotlin.fir.resolve.inference.isKMutableProperty
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap
import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.symbols.impl.*
...@@ -52,10 +54,10 @@ class CallAndReferenceGenerator( ...@@ -52,10 +54,10 @@ class CallAndReferenceGenerator(
private val adapterGenerator = AdapterGenerator(components, conversionScope) private val adapterGenerator = AdapterGenerator(components, conversionScope)
private val samResolver = FirSamResolverImpl(session, scopeSession) private val samResolver = FirSamResolverImpl(session, scopeSession)
private fun FirTypeRef.toIrType(conversionTypeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType = private fun FirTypeRef.toIrType(): IrType = with(typeConverter) { toIrType() }
with(typeConverter) { toIrType(conversionTypeContext) }
private fun ConeKotlinType.toIrType(): IrType = with(typeConverter) { toIrType() } private fun ConeKotlinType.toIrType(conversionTypeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType =
with(typeConverter) { toIrType(conversionTypeContext) }
fun convertToIrCallableReference( fun convertToIrCallableReference(
callableReferenceAccess: FirCallableReferenceAccess, callableReferenceAccess: FirCallableReferenceAccess,
...@@ -439,6 +441,17 @@ class CallAndReferenceGenerator( ...@@ -439,6 +441,17 @@ class CallAndReferenceGenerator(
} }
} }
private fun FirFunctionCall.buildSubstitutorByCalledFunction(function: FirFunction<*>?): ConeSubstitutor? {
if (function == null) return null
val map = mutableMapOf<FirTypeParameterSymbol, ConeKotlinType>()
for ((index, typeParameter) in function.typeParameters.withIndex()) {
val typeProjection = typeArguments.getOrNull(index) as? FirTypeProjectionWithVariance ?: continue
val type = typeProjection.typeRef.coneTypeSafe<ConeKotlinType>() ?: continue
map[typeParameter.symbol] = type
}
return ConeSubstitutorByMap(map)
}
internal fun IrExpression.applyCallArguments(call: FirCall?, annotationMode: Boolean): IrExpression { internal fun IrExpression.applyCallArguments(call: FirCall?, annotationMode: Boolean): IrExpression {
if (call == null) return this if (call == null) return this
return when (this) { return when (this) {
...@@ -461,14 +474,15 @@ class CallAndReferenceGenerator( ...@@ -461,14 +474,15 @@ class CallAndReferenceGenerator(
} }
val valueParameters = function?.valueParameters val valueParameters = function?.valueParameters
val argumentMapping = call.argumentMapping val argumentMapping = call.argumentMapping
val substitutor = (call as? FirFunctionCall)?.buildSubstitutorByCalledFunction(function) ?: ConeSubstitutor.Empty
if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) { if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) {
if (valueParameters != null) { if (valueParameters != null) {
return applyArgumentsWithReorderingIfNeeded(argumentMapping, valueParameters, annotationMode) return applyArgumentsWithReorderingIfNeeded(argumentMapping, valueParameters, substitutor, annotationMode)
} }
} }
for ((index, argument) in call.arguments.withIndex()) { for ((index, argument) in call.arguments.withIndex()) {
val valueParameter = valueParameters?.get(index) val valueParameter = valueParameters?.get(index)
val argumentExpression = convertArgument(argument, valueParameter) val argumentExpression = convertArgument(argument, valueParameter, substitutor)
putValueArgument(index, argumentExpression) putValueArgument(index, argumentExpression)
} }
} }
...@@ -496,6 +510,7 @@ class CallAndReferenceGenerator( ...@@ -496,6 +510,7 @@ class CallAndReferenceGenerator(
private fun IrMemberAccessExpression<*>.applyArgumentsWithReorderingIfNeeded( private fun IrMemberAccessExpression<*>.applyArgumentsWithReorderingIfNeeded(
argumentMapping: LinkedHashMap<FirExpression, FirValueParameter>, argumentMapping: LinkedHashMap<FirExpression, FirValueParameter>,
valueParameters: List<FirValueParameter>, valueParameters: List<FirValueParameter>,
substitutor: ConeSubstitutor,
annotationMode: Boolean annotationMode: Boolean
): IrExpression { ): IrExpression {
// Assuming compile-time constants only inside annotation, we don't need a block to reorder arguments to preserve semantics. // Assuming compile-time constants only inside annotation, we don't need a block to reorder arguments to preserve semantics.
...@@ -506,7 +521,7 @@ class CallAndReferenceGenerator( ...@@ -506,7 +521,7 @@ class CallAndReferenceGenerator(
return IrBlockImpl(startOffset, endOffset, type, IrStatementOrigin.ARGUMENTS_REORDERING_FOR_CALL).apply { return IrBlockImpl(startOffset, endOffset, type, IrStatementOrigin.ARGUMENTS_REORDERING_FOR_CALL).apply {
for ((argument, parameter) in argumentMapping) { for ((argument, parameter) in argumentMapping) {
val parameterIndex = valueParameters.indexOf(parameter) val parameterIndex = valueParameters.indexOf(parameter)
val irArgument = convertArgument(argument, parameter) val irArgument = convertArgument(argument, parameter, substitutor)
if (irArgument.hasNoSideEffects()) { if (irArgument.hasNoSideEffects()) {
putValueArgument(parameterIndex, irArgument) putValueArgument(parameterIndex, irArgument)
} else { } else {
...@@ -521,7 +536,7 @@ class CallAndReferenceGenerator( ...@@ -521,7 +536,7 @@ class CallAndReferenceGenerator(
} }
} else { } else {
for ((argument, parameter) in argumentMapping) { for ((argument, parameter) in argumentMapping) {
val argumentExpression = convertArgument(argument, parameter, annotationMode) val argumentExpression = convertArgument(argument, parameter, substitutor, annotationMode)
putValueArgument(valueParameters.indexOf(parameter), argumentExpression) putValueArgument(valueParameters.indexOf(parameter), argumentExpression)
} }
if (annotationMode) { if (annotationMode) {
...@@ -562,6 +577,7 @@ class CallAndReferenceGenerator( ...@@ -562,6 +577,7 @@ class CallAndReferenceGenerator(
private fun convertArgument( private fun convertArgument(
argument: FirExpression, argument: FirExpression,
parameter: FirValueParameter?, parameter: FirValueParameter?,
substitutor: ConeSubstitutor,
annotationMode: Boolean = false annotationMode: Boolean = false
): IrExpression { ): IrExpression {
var irArgument = visitor.convertToIrExpression(argument, annotationMode) var irArgument = visitor.convertToIrExpression(argument, annotationMode)
...@@ -574,7 +590,7 @@ class CallAndReferenceGenerator( ...@@ -574,7 +590,7 @@ class CallAndReferenceGenerator(
if (parameter?.returnTypeRef is FirResolvedTypeRef) { if (parameter?.returnTypeRef is FirResolvedTypeRef) {
// Java type case (from annotations) // Java type case (from annotations)
irArgument = irArgument.applySuspendConversionIfNeeded(argument, parameter) irArgument = irArgument.applySuspendConversionIfNeeded(argument, parameter)
irArgument = irArgument.applySamConversionIfNeeded(argument, parameter) irArgument = irArgument.applySamConversionIfNeeded(argument, parameter, substitutor)
} }
} }
return irArgument.applyAssigningArrayElementsToVarargInNamedForm(argument, parameter) return irArgument.applyAssigningArrayElementsToVarargInNamedForm(argument, parameter)
...@@ -583,6 +599,7 @@ class CallAndReferenceGenerator( ...@@ -583,6 +599,7 @@ class CallAndReferenceGenerator(
private fun IrExpression.applySamConversionIfNeeded( private fun IrExpression.applySamConversionIfNeeded(
argument: FirExpression, argument: FirExpression,
parameter: FirValueParameter?, parameter: FirValueParameter?,
substitutor: ConeSubstitutor,
shouldUnwrapVarargType: Boolean = false shouldUnwrapVarargType: Boolean = false
): IrExpression { ): IrExpression {
if (parameter == null) { if (parameter == null) {
...@@ -600,7 +617,7 @@ class CallAndReferenceGenerator( ...@@ -600,7 +617,7 @@ class CallAndReferenceGenerator(
if (irVarargElement is IrExpression) { if (irVarargElement is IrExpression) {
val firVarargArgument = val firVarargArgument =
argumentMapping[irVarargElement] ?: error("Can't find the original FirExpression for ${irVarargElement.render()}") argumentMapping[irVarargElement] ?: error("Can't find the original FirExpression for ${irVarargElement.render()}")
irVarargElement.applySamConversionIfNeeded(firVarargArgument, parameter, shouldUnwrapVarargType = true) irVarargElement.applySamConversionIfNeeded(firVarargArgument, parameter, substitutor, shouldUnwrapVarargType = true)
} else } else
irVarargElement irVarargElement
} }
...@@ -609,7 +626,8 @@ class CallAndReferenceGenerator( ...@@ -609,7 +626,8 @@ class CallAndReferenceGenerator(
if (!needSamConversion(argument, parameter)) { if (!needSamConversion(argument, parameter)) {
return this return this
} }
var samType = parameter.returnTypeRef.toIrType(ConversionTypeContext.WITH_INVARIANT) val samFirType = parameter.returnTypeRef.coneTypeSafe<ConeKotlinType>()?.let { substitutor.substituteOrSelf(it) }
var samType = samFirType?.toIrType(ConversionTypeContext.WITH_INVARIANT) ?: createErrorType()
if (shouldUnwrapVarargType) { if (shouldUnwrapVarargType) {
samType = samType.getArrayElementType(irBuiltIns) samType = samType.getArrayElementType(irBuiltIns)
} }
......
// !LANGUAGE: +NewInference +SamConversionPerArgument +SamConversionForKotlinFunctions +FunctionalInterfaceConversion // !LANGUAGE: +NewInference +SamConversionPerArgument +SamConversionForKotlinFunctions +FunctionalInterfaceConversion
// WITH_REFLECT // WITH_REFLECT
// FULL_JDK // FULL_JDK
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// FILE: Provider.java // FILE: Provider.java
......
fun test1(f: Function1<String, String>): C<String?> { fun test1(f: Function1<String, String>): C<String?> {
return C<String?>(jxx = f /*-> J<X?, X?>? */) return C<String?>(jxx = f /*-> J<String?, String?>? */)
} }
fun test2(x: Any) { fun test2(x: Any) {
x as Function1<String, String> /*~> Unit */ x as Function1<String, String> /*~> Unit */
C<String?>(jxx = x /*as Function1<String, String> */ /*-> J<X?, X?>? */) /*~> Unit */ C<String?>(jxx = x /*as Function1<String, String> */ /*-> J<String?, String?>? */) /*~> Unit */
} }
...@@ -5,7 +5,7 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall.kt ...@@ -5,7 +5,7 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall.kt
RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function1<kotlin.String, kotlin.String>): <root>.C<kotlin.String?> declared in <root>' RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function1<kotlin.String, kotlin.String>): <root>.C<kotlin.String?> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null
<class: X>: kotlin.String? <class: X>: kotlin.String?
jxx: TYPE_OP type=<root>.J<X of <root>.C?, X of <root>.C?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.C?, X of <root>.C?>? jxx: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>?
GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test1' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test1' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any VALUE_PARAMETER name:x index:0 type:kotlin.Any
...@@ -16,6 +16,6 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall.kt ...@@ -16,6 +16,6 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall.kt
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null
<class: X>: kotlin.String? <class: X>: kotlin.String?
jxx: TYPE_OP type=<root>.J<X of <root>.C?, X of <root>.C?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.C?, X of <root>.C?>? jxx: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>?
TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.String> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.String> TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.String> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null GET_VAR 'x: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
fun test3(f1: Function1<String, String>, f2: Function1<Int, String>): D<Int?, String?> { fun test3(f1: Function1<String, String>, f2: Function1<Int, String>): D<Int?, String?> {
return C<String?>(jxx = f1 /*-> J<X?, X?>? */).D<Int?>(jxy = f2 /*-> J<String?, Y?>? */) return C<String?>(jxx = f1 /*-> J<String?, String?>? */).D<Int?>(jxy = f2 /*-> J<String?, Int?>? */)
} }
class Outer<T1 : Any?> { class Outer<T1 : Any?> {
...@@ -29,14 +29,14 @@ class Outer<T1 : Any?> { ...@@ -29,14 +29,14 @@ class Outer<T1 : Any?> {
} }
fun test4(f: Function1<String, String>, g: Function1<Any, String>): Inner<Any?, String?> { fun test4(f: Function1<String, String>, g: Function1<Any, String>): Inner<Any?, String?> {
return Outer<String?>(j11 = f /*-> J<T1, T1> */).Inner<Any?>(j12 = g /*-> J<String?, T2> */) return Outer<String?>(j11 = f /*-> J<String?, String?> */).Inner<Any?>(j12 = g /*-> J<String?, Any?> */)
} }
fun testGenericJavaCtor1(f: Function1<String, Int>): G<String?> { fun testGenericJavaCtor1(f: Function1<String, Int>): G<String?> {
return G<String?, Int?>(x = f /*-> J<TCtor?, TClass?>? */) return G<String?, Int?>(x = f /*-> J<Int?, String?>? */)
} }
fun testGenericJavaCtor2(x: Any) { fun testGenericJavaCtor2(x: Any) {
x as Function1<String, Int> /*~> Unit */ x as Function1<String, Int> /*~> Unit */
G<String?, Int?>(x = x /*as Function1<String, Int> */ /*-> J<TCtor?, TClass?>? */) /*~> Unit */ G<String?, Int?>(x = x /*as Function1<String, Int> */ /*-> J<Int?, String?>? */) /*~> Unit */
} }
...@@ -8,9 +8,9 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt ...@@ -8,9 +8,9 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
<class: Y>: kotlin.Int? <class: Y>: kotlin.Int?
$outer: CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null $outer: CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null
<class: X>: kotlin.String? <class: X>: kotlin.String?
jxx: TYPE_OP type=<root>.J<X of <root>.C?, X of <root>.C?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.C?, X of <root>.C?>? jxx: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>?
GET_VAR 'f1: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test3' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null GET_VAR 'f1: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test3' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
jxy: TYPE_OP type=<root>.J<kotlin.String?, Y of <root>.C.D?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, Y of <root>.C.D?>? jxy: TYPE_OP type=<root>.J<kotlin.String?, kotlin.Int?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.Int?>?
GET_VAR 'f2: kotlin.Function1<kotlin.Int, kotlin.String> declared in <root>.test3' type=kotlin.Function1<kotlin.Int, kotlin.String> origin=null GET_VAR 'f2: kotlin.Function1<kotlin.Int, kotlin.String> declared in <root>.test3' type=kotlin.Function1<kotlin.Int, kotlin.String> origin=null
CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Outer<T1 of <root>.Outer> $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Outer<T1 of <root>.Outer>
...@@ -86,9 +86,9 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt ...@@ -86,9 +86,9 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
<class: T2>: kotlin.Any? <class: T2>: kotlin.Any?
$outer: CONSTRUCTOR_CALL 'public constructor <init> (j11: <root>.J<T1 of <root>.Outer, T1 of <root>.Outer>) [primary] declared in <root>.Outer' type=<root>.Outer<kotlin.String?> origin=null $outer: CONSTRUCTOR_CALL 'public constructor <init> (j11: <root>.J<T1 of <root>.Outer, T1 of <root>.Outer>) [primary] declared in <root>.Outer' type=<root>.Outer<kotlin.String?> origin=null
<class: T1>: kotlin.String? <class: T1>: kotlin.String?
j11: TYPE_OP type=<root>.J<T1 of <root>.Outer, T1 of <root>.Outer> origin=SAM_CONVERSION typeOperand=<root>.J<T1 of <root>.Outer, T1 of <root>.Outer> j11: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>
GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test4' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test4' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
j12: TYPE_OP type=<root>.J<kotlin.String?, T2 of <root>.Outer.Inner> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, T2 of <root>.Outer.Inner> j12: TYPE_OP type=<root>.J<kotlin.String?, kotlin.Any?> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.Any?>
GET_VAR 'g: kotlin.Function1<kotlin.Any, kotlin.String> declared in <root>.test4' type=kotlin.Function1<kotlin.Any, kotlin.String> origin=null GET_VAR 'g: kotlin.Function1<kotlin.Any, kotlin.String> declared in <root>.test4' type=kotlin.Function1<kotlin.Any, kotlin.String> origin=null
FUN name:testGenericJavaCtor1 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.Int>) returnType:<root>.G<kotlin.String?> FUN name:testGenericJavaCtor1 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.Int>) returnType:<root>.G<kotlin.String?>
VALUE_PARAMETER name:f index:0 type:kotlin.Function1<kotlin.String, kotlin.Int> VALUE_PARAMETER name:f index:0 type:kotlin.Function1<kotlin.String, kotlin.Int>
...@@ -97,7 +97,7 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt ...@@ -97,7 +97,7 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String?> origin=null CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String?> origin=null
<class: TClass>: kotlin.String? <class: TClass>: kotlin.String?
<TCtor>: kotlin.Int? <TCtor>: kotlin.Int?
x: TYPE_OP type=<root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>? origin=SAM_CONVERSION typeOperand=<root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>? x: TYPE_OP type=<root>.J<kotlin.Int?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.Int?, kotlin.String?>?
GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.Int> declared in <root>.testGenericJavaCtor1' type=kotlin.Function1<kotlin.String, kotlin.Int> origin=null GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.Int> declared in <root>.testGenericJavaCtor1' type=kotlin.Function1<kotlin.String, kotlin.Int> origin=null
FUN name:testGenericJavaCtor2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit FUN name:testGenericJavaCtor2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Any VALUE_PARAMETER name:x index:0 type:kotlin.Any
...@@ -109,6 +109,6 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt ...@@ -109,6 +109,6 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String?> origin=null CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String?> origin=null
<class: TClass>: kotlin.String? <class: TClass>: kotlin.String?
<TCtor>: kotlin.Int? <TCtor>: kotlin.Int?
x: TYPE_OP type=<root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>? origin=SAM_CONVERSION typeOperand=<root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>? x: TYPE_OP type=<root>.J<kotlin.Int?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.Int?, kotlin.String?>?
TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.Int> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.Int> TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.Int> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.testGenericJavaCtor2' type=kotlin.Any origin=null GET_VAR 'x: kotlin.Any declared in <root>.testGenericJavaCtor2' type=kotlin.Any origin=null
...@@ -16,7 +16,7 @@ fun test3() { ...@@ -16,7 +16,7 @@ fun test3() {
return bar<String?>(j = local fun <anonymous>(x: String): String? { return bar<String?>(j = local fun <anonymous>(x: String): String? {
return x return x
} }
/*-> J<X?>? */) /*-> J<String?>? */)
} }
fun test4(a: Any) { fun test4(a: Any) {
...@@ -26,16 +26,16 @@ fun test4(a: Any) { ...@@ -26,16 +26,16 @@ fun test4(a: Any) {
fun test5(a: Any) { fun test5(a: Any) {
a as Function1<String, String> /*~> Unit */ a as Function1<String, String> /*~> Unit */
bar<String?>(j = a /*as Function1<String, String> */ /*-> J<X?>? */) bar<String?>(j = a /*as Function1<String, String> */ /*-> J<String?>? */)
} }
fun <T : Any?> test6(a: Function1<T, T>) { fun <T : Any?> test6(a: Function1<T, T>) {
bar<T?>(j = a /*-> J<X?>? */) bar<T?>(j = a /*-> J<T?>? */)
} }
fun <T : Any?> test7(a: Any) { fun <T : Any?> test7(a: Any) {
a as Function1<T, T> /*~> Unit */ a as Function1<T, T> /*~> Unit */
bar<T?>(j = a /*as Function1<T, T> */ /*-> J<X?>? */) bar<T?>(j = a /*as Function1<T, T> */ /*-> J<T?>? */)
} }
fun test8(efn: @ExtensionFunctionType Function1<String, String>): J<String?> { fun test8(efn: @ExtensionFunctionType Function1<String, String>): J<String?> {
...@@ -43,9 +43,9 @@ fun test8(efn: @ExtensionFunctionType Function1<String, String>): J<String?> { ...@@ -43,9 +43,9 @@ fun test8(efn: @ExtensionFunctionType Function1<String, String>): J<String?> {
} }
fun test9(efn: @ExtensionFunctionType Function1<String, String>) { fun test9(efn: @ExtensionFunctionType Function1<String, String>) {
bar<String?>(j = efn /*-> J<X?>? */) bar<String?>(j = efn /*-> J<String?>? */)
} }
fun test10(fn: Function1<Int, String>) { fun test10(fn: Function1<Int, String>) {
bar2x<Int?>(j2x = fn /*-> J2X<Y?>? */) bar2x<Int?>(j2x = fn /*-> J2X<Int?>? */)
} }
...@@ -24,7 +24,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt ...@@ -24,7 +24,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Unit declared in <root>' RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Unit declared in <root>'
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String? <X>: kotlin.String?
j: TYPE_OP type=<root>.J<X of <root>.H.bar?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.H.bar?>? j: TYPE_OP type=<root>.J<kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?>?
FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.String?> origin=LAMBDA FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.String?> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String? FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String?
VALUE_PARAMETER name:x index:0 type:kotlin.String VALUE_PARAMETER name:x index:0 type:kotlin.String
...@@ -49,7 +49,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt ...@@ -49,7 +49,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String? <X>: kotlin.String?
j: TYPE_OP type=<root>.J<X of <root>.H.bar?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.H.bar?>? j: TYPE_OP type=<root>.J<kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?>?
TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.String> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.String> TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.String> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.String>
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
FUN name:test6 visibility:public modality:FINAL <T> (a:kotlin.Function1<T of <root>.test6, T of <root>.test6>) returnType:kotlin.Unit FUN name:test6 visibility:public modality:FINAL <T> (a:kotlin.Function1<T of <root>.test6, T of <root>.test6>) returnType:kotlin.Unit
...@@ -58,7 +58,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt ...@@ -58,7 +58,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
BLOCK_BODY BLOCK_BODY
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
<X>: T of <root>.test6? <X>: T of <root>.test6?
j: TYPE_OP type=<root>.J<X of <root>.H.bar?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.H.bar?>? j: TYPE_OP type=<root>.J<T of <root>.test6?>? origin=SAM_CONVERSION typeOperand=<root>.J<T of <root>.test6?>?
GET_VAR 'a: kotlin.Function1<T of <root>.test6, T of <root>.test6> declared in <root>.test6' type=kotlin.Function1<T of <root>.test6, T of <root>.test6> origin=null GET_VAR 'a: kotlin.Function1<T of <root>.test6, T of <root>.test6> declared in <root>.test6' type=kotlin.Function1<T of <root>.test6, T of <root>.test6> origin=null
FUN name:test7 visibility:public modality:FINAL <T> (a:kotlin.Any) returnType:kotlin.Unit FUN name:test7 visibility:public modality:FINAL <T> (a:kotlin.Any) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
...@@ -69,7 +69,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt ...@@ -69,7 +69,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
GET_VAR 'a: kotlin.Any declared in <root>.test7' type=kotlin.Any origin=null GET_VAR 'a: kotlin.Any declared in <root>.test7' type=kotlin.Any origin=null
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
<X>: T of <root>.test7? <X>: T of <root>.test7?
j: TYPE_OP type=<root>.J<X of <root>.H.bar?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.H.bar?>? j: TYPE_OP type=<root>.J<T of <root>.test7?>? origin=SAM_CONVERSION typeOperand=<root>.J<T of <root>.test7?>?
TYPE_OP type=kotlin.Function1<T of <root>.test7, T of <root>.test7> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<T of <root>.test7, T of <root>.test7> TYPE_OP type=kotlin.Function1<T of <root>.test7, T of <root>.test7> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<T of <root>.test7, T of <root>.test7>
GET_VAR 'a: kotlin.Any declared in <root>.test7' type=kotlin.Any origin=null GET_VAR 'a: kotlin.Any declared in <root>.test7' type=kotlin.Any origin=null
FUN name:test8 visibility:public modality:FINAL <> (efn:@[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.String>) returnType:<root>.J<kotlin.String?> FUN name:test8 visibility:public modality:FINAL <> (efn:@[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.String>) returnType:<root>.J<kotlin.String?>
...@@ -83,12 +83,12 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt ...@@ -83,12 +83,12 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
BLOCK_BODY BLOCK_BODY
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String? <X>: kotlin.String?
j: TYPE_OP type=<root>.J<X of <root>.H.bar?>? origin=SAM_CONVERSION typeOperand=<root>.J<X of <root>.H.bar?>? j: TYPE_OP type=<root>.J<kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?>?
GET_VAR 'efn: @[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test9' type=@[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.String> origin=null GET_VAR 'efn: @[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test9' type=@[ExtensionFunctionType] kotlin.Function1<kotlin.String, kotlin.String> origin=null
FUN name:test10 visibility:public modality:FINAL <> (fn:kotlin.Function1<kotlin.Int, kotlin.String>) returnType:kotlin.Unit FUN name:test10 visibility:public modality:FINAL <> (fn:kotlin.Function1<kotlin.Int, kotlin.String>) returnType:kotlin.Unit
VALUE_PARAMETER name:fn index:0 type:kotlin.Function1<kotlin.Int, kotlin.String> VALUE_PARAMETER name:fn index:0 type:kotlin.Function1<kotlin.Int, kotlin.String>
BLOCK_BODY BLOCK_BODY
CALL 'public open fun bar2x <Y> (j2x: <root>.J2X<Y of <root>.H.bar2x?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null CALL 'public open fun bar2x <Y> (j2x: <root>.J2X<Y of <root>.H.bar2x?>?): kotlin.Unit declared in <root>.H' type=kotlin.Unit origin=null
<Y>: kotlin.Int? <Y>: kotlin.Int?
j2x: TYPE_OP type=<root>.J2X<Y of <root>.H.bar2x?>? origin=SAM_CONVERSION typeOperand=<root>.J2X<Y of <root>.H.bar2x?>? j2x: TYPE_OP type=<root>.J2X<kotlin.Int?>? origin=SAM_CONVERSION typeOperand=<root>.J2X<kotlin.Int?>?
GET_VAR 'fn: kotlin.Function1<kotlin.Int, kotlin.String> declared in <root>.test10' type=kotlin.Function1<kotlin.Int, kotlin.String> origin=null GET_VAR 'fn: kotlin.Function1<kotlin.Int, kotlin.String> declared in <root>.test10' type=kotlin.Function1<kotlin.Int, kotlin.String> origin=null
...@@ -48,7 +48,7 @@ fun test7(a: Function1<Int, Int>) { ...@@ -48,7 +48,7 @@ fun test7(a: Function1<Int, Int>) {
} }
fun test8(a: Function0<Unit>) { fun test8(a: Function0<Unit>) {
J().run1(r = id<Function0<Unit>?>(x = a) /*-> Runnable? */) J().run1(r = id<Function0<Unit>?>(x = a /*-> Function0<Unit>? */) /*-> Runnable? */)
} }
fun test9() { fun test9() {
......
...@@ -104,7 +104,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt ...@@ -104,7 +104,8 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null
<T>: kotlin.Function0<kotlin.Unit>? <T>: kotlin.Function0<kotlin.Unit>?
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null x: TYPE_OP type=kotlin.Function0<kotlin.Unit>? origin=SAM_CONVERSION typeOperand=kotlin.Function0<kotlin.Unit>?
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY BLOCK_BODY
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册