Fixed bug with type projection building + test
Bug could be seen on fake overridden functions calls
This commit is contained in:
+5
-5
@@ -24,10 +24,10 @@ import org.jetbrains.kotlin.backend.common.reportWarning
|
|||||||
import org.jetbrains.kotlin.backend.konan.Context
|
import org.jetbrains.kotlin.backend.konan.Context
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isFunctionInvoke
|
import org.jetbrains.kotlin.backend.konan.descriptors.isFunctionInvoke
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.needsInlining
|
import org.jetbrains.kotlin.backend.konan.descriptors.needsInlining
|
||||||
|
import org.jetbrains.kotlin.backend.konan.descriptors.propertyIfAccessor
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
|
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.DeserializerDriver
|
import org.jetbrains.kotlin.backend.konan.ir.DeserializerDriver
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.ValueDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
@@ -211,12 +211,12 @@ private class Inliner(val globalSubstituteMap: MutableMap<DeclarationDescriptor,
|
|||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
private fun createTypeSubstitutor(irCall: IrCall): TypeSubstitutor? {
|
private fun createTypeSubstitutor(irCall: IrCall): TypeSubstitutor? {
|
||||||
|
|
||||||
val typeArgumentsMap = (irCall as IrMemberAccessExpressionBase).typeArguments
|
val typeArgumentsMap = (irCall as IrMemberAccessExpressionBase).typeArguments
|
||||||
if (typeArgumentsMap == null) return null
|
if (typeArgumentsMap == null) return null
|
||||||
val substitutionContext = typeArgumentsMap.entries.associate {
|
val descriptor = irCall.descriptor.resolveFakeOverride().original
|
||||||
(typeParameter, typeArgument) ->
|
val typeParameters = descriptor.propertyIfAccessor.typeParameters
|
||||||
typeParameter.typeConstructor to TypeProjectionImpl(typeArgument)
|
val substitutionContext = typeArgumentsMap.entries.associate { (typeParameter, typeArgument) ->
|
||||||
|
typeParameters[typeParameter.index].typeConstructor to TypeProjectionImpl(typeArgument)
|
||||||
}
|
}
|
||||||
return TypeSubstitutor.create(substitutionContext)
|
return TypeSubstitutor.create(substitutionContext)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2086,6 +2086,11 @@ task inline26(type: RunKonanTest) {
|
|||||||
source = "codegen/inline/inline26.kt"
|
source = "codegen/inline/inline26.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task inline_type_substitution_in_fake_override(type: RunKonanTest) {
|
||||||
|
goldValue = "OK\n"
|
||||||
|
source = "codegen/inline/typeSubstitutionInFakeOverride.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task deserialized_inline0(type: RunKonanTest) {
|
task deserialized_inline0(type: RunKonanTest) {
|
||||||
source = "serialization/deserialized_inline0.kt"
|
source = "serialization/deserialized_inline0.kt"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package codegen.inline.typeSubstitutionInFakeOverride
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
abstract class A {
|
||||||
|
inline fun <reified T : Any> baz(): String {
|
||||||
|
return T::class.simpleName!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : A() {
|
||||||
|
fun bar(): String {
|
||||||
|
return baz<OK>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OK
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
println(B().bar())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user