[FIR] Disable linkViaSignatures in K2 irText tests for non-JVM targets

This will make the test compiler configuration closer to the production
configuration.

KT-64809
This commit is contained in:
Sergej Jaskiewicz
2024-01-12 16:00:48 +01:00
committed by Space Team
parent a5031edd1a
commit e49b28d639
4 changed files with 12 additions and 9 deletions
@@ -70,12 +70,11 @@ class Fir2IrConfiguration private constructor(
fun forKlibCompilation( fun forKlibCompilation(
compilerConfiguration: CompilerConfiguration, compilerConfiguration: CompilerConfiguration,
diagnosticReporter: DiagnosticReporter, diagnosticReporter: DiagnosticReporter,
linkViaSignatures: Boolean = false, // FIXME(KT-64809): This parameter is only used in irText tests, we need to remove it.
): Fir2IrConfiguration = ): Fir2IrConfiguration =
Fir2IrConfiguration( Fir2IrConfiguration(
languageVersionSettings = compilerConfiguration.languageVersionSettings, languageVersionSettings = compilerConfiguration.languageVersionSettings,
diagnosticReporter = diagnosticReporter, diagnosticReporter = diagnosticReporter,
linkViaSignatures = linkViaSignatures, linkViaSignatures = false,
evaluatedConstTracker = compilerConfiguration.putIfAbsent( evaluatedConstTracker = compilerConfiguration.putIfAbsent(
CommonConfigurationKeys.EVALUATED_CONST_TRACKER, CommonConfigurationKeys.EVALUATED_CONST_TRACKER,
EvaluatedConstTracker.create(), EvaluatedConstTracker.create(),
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.dump import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.isPrimitiveArray import org.jetbrains.kotlin.ir.util.isPrimitiveArray
import org.jetbrains.kotlin.ir.util.isUnsignedArray import org.jetbrains.kotlin.ir.util.isUnsignedArray
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator.commonSuperType import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator.commonSuperType
import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.Variance
@@ -925,10 +926,15 @@ class CallAndReferenceGenerator(
} }
} }
} else { } else {
val name = if (this is IrCallImpl) symbol.signature.toString() else "???" val calleeSymbol = (this as? IrCallImpl)?.symbol
@OptIn(UnsafeDuringIrConstructionAPI::class)
val description = calleeSymbol?.signature?.render()
?: calleeSymbol?.takeIf { it.isBound }?.owner?.render()
?: "???"
IrErrorCallExpressionImpl( IrErrorCallExpressionImpl(
startOffset, endOffset, type, startOffset, endOffset, type,
"Cannot bind $argumentsCount arguments to $name call with $valueArgumentsCount parameters" "Cannot bind $argumentsCount arguments to '$description' call with $valueArgumentsCount parameters"
).apply { ).apply {
for (argument in call.arguments) { for (argument in call.arguments) {
addArgument(visitor.convertToIrExpression(argument)) addArgument(visitor.convertToIrExpression(argument))
@@ -42,7 +42,7 @@ FILE fqName:<root> fileName:/badInlinedBreakContinue.kt
CALL 'public final fun invoke <T, R> (value: T of kotlin.invoke): R of kotlin.invoke declared in kotlin' type=IrErrorType(null) origin=null CALL 'public final fun invoke <T, R> (value: T of kotlin.invoke): R of kotlin.invoke declared in kotlin' type=IrErrorType(null) origin=null
<T>: IrErrorType(null) <T>: IrErrorType(null)
<R>: IrErrorType(null) <R>: IrErrorType(null)
$receiver: ERROR_CALL 'Cannot bind 1 arguments to kotlin/Function0.invoke|invoke(){}[0] call with 0 parameters' type=kotlin.Nothing $receiver: ERROR_CALL 'Cannot bind 1 arguments to 'FUN IR_EXTERNAL_DECLARATION_STUB name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<R of kotlin.Function0>) returnType:R of kotlin.Function0 [operator]' call with 0 parameters' type=kotlin.Nothing
FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing
BLOCK_BODY BLOCK_BODY
@@ -86,7 +86,7 @@ FILE fqName:<root> fileName:/badInlinedBreakContinue.kt
CALL 'public final fun invoke <T, R> (value: T of kotlin.invoke): R of kotlin.invoke declared in kotlin' type=IrErrorType(null) origin=null CALL 'public final fun invoke <T, R> (value: T of kotlin.invoke): R of kotlin.invoke declared in kotlin' type=IrErrorType(null) origin=null
<T>: IrErrorType(null) <T>: IrErrorType(null)
<R>: IrErrorType(null) <R>: IrErrorType(null)
$receiver: ERROR_CALL 'Cannot bind 1 arguments to kotlin/Function0.invoke|invoke(){}[0] call with 0 parameters' type=kotlin.Nothing $receiver: ERROR_CALL 'Cannot bind 1 arguments to 'FUN IR_EXTERNAL_DECLARATION_STUB name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<R of kotlin.Function0>) returnType:R of kotlin.Function0 [operator]' call with 0 parameters' type=kotlin.Nothing
FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing
BLOCK_BODY BLOCK_BODY
@@ -134,7 +134,7 @@ FILE fqName:<root> fileName:/badInlinedBreakContinue.kt
CALL 'public final fun invoke <T, R> (value: T of kotlin.invoke): R of kotlin.invoke declared in kotlin' type=IrErrorType(null) origin=null CALL 'public final fun invoke <T, R> (value: T of kotlin.invoke): R of kotlin.invoke declared in kotlin' type=IrErrorType(null) origin=null
<T>: IrErrorType(null) <T>: IrErrorType(null)
<R>: IrErrorType(null) <R>: IrErrorType(null)
$receiver: ERROR_CALL 'Cannot bind 1 arguments to kotlin/Function0.invoke|invoke(){}[0] call with 0 parameters' type=kotlin.Nothing $receiver: ERROR_CALL 'Cannot bind 1 arguments to 'FUN IR_EXTERNAL_DECLARATION_STUB name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<R of kotlin.Function0>) returnType:R of kotlin.Function0 [operator]' call with 0 parameters' type=kotlin.Nothing
FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA FUN_EXPR type=kotlin.Function0<kotlin.Nothing> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing
BLOCK_BODY BLOCK_BODY
@@ -85,8 +85,6 @@ abstract class AbstractFir2IrNonJvmResultsConverter(
val fir2IrConfiguration = Fir2IrConfiguration.forKlibCompilation( val fir2IrConfiguration = Fir2IrConfiguration.forKlibCompilation(
compilerConfiguration, compilerConfiguration,
diagnosticReporter, diagnosticReporter,
// FIXME(KT-64809): This is for irText tests. Remove this when we stop building signatures from FIR entirely.
linkViaSignatures = LanguageSettingsDirectives.LINK_VIA_SIGNATURES in module.directives,
) )
val fir2irResult = inputArtifact.toFirResult().convertToIrAndActualize( val fir2irResult = inputArtifact.toFirResult().convertToIrAndActualize(
Fir2IrExtensions.Default, Fir2IrExtensions.Default,