Inliner: fixed bug with generic function reference + test
Fixes issue https://github.com/JetBrains/kotlin-native/issues/2336
This commit is contained in:
+2
@@ -359,6 +359,8 @@ private class Inliner(val globalSubstituteMap: MutableMap<DeclarationDescriptor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(unboundIndex == valueParameters.size) { "Not all arguments of <invoke> are used" }
|
assert(unboundIndex == valueParameters.size) { "Not all arguments of <invoke> are used" }
|
||||||
|
for (index in 0 until functionArgument.typeArgumentsCount)
|
||||||
|
putTypeArgument(index, functionArgument.getTypeArgument(index))
|
||||||
}
|
}
|
||||||
return owner.visitCall(super.visitCall(immediateCall) as IrCall, Ref(false))
|
return owner.visitCall(super.visitCall(immediateCall) as IrCall, Ref(false))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2586,6 +2586,11 @@ task inline_localObjectReturnedFromWhen(type: RunKonanTest) {
|
|||||||
source = "codegen/inline/localObjectReturnedFromWhen.kt"
|
source = "codegen/inline/localObjectReturnedFromWhen.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task inline_genericFunctionReference(type: RunKonanTest) {
|
||||||
|
goldValue = "0\n"
|
||||||
|
source = "codegen/inline/genericFunctionReference.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task classDeclarationInsideInline(type: RunKonanTest) {
|
task classDeclarationInsideInline(type: RunKonanTest) {
|
||||||
source = "codegen/inline/classDeclarationInsideInline.kt"
|
source = "codegen/inline/classDeclarationInsideInline.kt"
|
||||||
goldValue = "test1: 1.0\n1\ntest2\n"
|
goldValue = "test1: 1.0\n1\ntest2\n"
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codegen.inline.genericFunctionReference
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
class Z<T>(val x: T)
|
||||||
|
|
||||||
|
inline fun<T, R> foo(x: T, f: (T) -> R): R {
|
||||||
|
return f(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
val arr = Array(1) { foo(it, ::Z) }
|
||||||
|
println(arr[0].x)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user