Report compile error for callable references to C/Obj-C variadics
#KT-36183 Fixed
This commit is contained in:
committed by
SvyatoslavScherbina
parent
2cf079abed
commit
0300307e21
+1
-1
@@ -243,7 +243,7 @@ internal val interopPhase = makeKonanFileLoweringPhase(
|
||||
::InteropLowering,
|
||||
name = "Interop",
|
||||
description = "Interop lowering",
|
||||
prerequisite = setOf(inlinePhase, localFunctionsPhase)
|
||||
prerequisite = setOf(inlinePhase, localFunctionsPhase, callableReferencePhase)
|
||||
)
|
||||
|
||||
internal val varargPhase = makeKonanFileLoweringPhase(
|
||||
|
||||
+5
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.backend.konan.getObjCMethodInfo
|
||||
import org.jetbrains.kotlin.backend.konan.lower.CallableReferenceLowering
|
||||
import org.jetbrains.kotlin.ir.descriptors.*
|
||||
|
||||
internal interface KotlinStubs {
|
||||
@@ -261,6 +262,10 @@ private fun <R> KotlinToCCallBuilder.handleArgumentForVarargParameter(
|
||||
} else {
|
||||
stubs.throwCompilerError(initializer, "unexpected initializer")
|
||||
}
|
||||
} else if (variable is IrValueParameter && CallableReferenceLowering.isLoweredCallableReference(variable)) {
|
||||
val location = variable.parent // Parameter itself has incorrect location.
|
||||
val kind = if (this.isObjCMethod) "Objective-C methods" else "C functions"
|
||||
stubs.reportError(location, "callable references to variadic $kind are not supported")
|
||||
} else {
|
||||
stubs.throwCompilerError(variable, "unexpected value declaration")
|
||||
}
|
||||
|
||||
+5
@@ -41,6 +41,11 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass
|
||||
|
||||
private object DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL : IrDeclarationOriginImpl("FUNCTION_REFERENCE_IMPL")
|
||||
|
||||
companion object {
|
||||
fun isLoweredCallableReference(declaration: IrDeclaration): Boolean =
|
||||
declaration.origin == DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL
|
||||
}
|
||||
|
||||
private val kTypeGenerator = KTypeGenerator(context)
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
|
||||
Reference in New Issue
Block a user