From 1f4e4f94a7eec278df8354c87053c03aa4e481aa Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 14 Apr 2023 14:43:00 +0200 Subject: [PATCH] [FIR] varargs: do not leak source of value parameter to the call site when source for compiled fir elements is set, it leaks e.g. to diagnostics, which is then filtered see `TestsWithStdLib.Experimental.testImplicitUsages` --- .../resolve/transformers/body/resolve/BodyResolveUtils.kt | 5 +++-- .../conversions/conversionOfSignedToUnsigned.fir.kt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt index 00e73c437f4..297301d56e1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt @@ -44,8 +44,9 @@ internal fun remapArgumentsWithVararg( var indexAfterVarargs = argumentList.size val newArgumentMapping = linkedMapOf() val varargArgument = buildVarargArgumentsExpression { - this.varargElementType = varargParameterTypeRef.withReplacedConeType(varargElementType) - this.typeRef = varargParameterTypeRef.withReplacedConeType(varargArrayType) + //todo ideally we should use here a source from the use-site and not from the declaration-site + this.varargElementType = varargParameterTypeRef.withReplacedConeType(varargElementType, KtFakeSourceElementKind.VarargArgument) + this.typeRef = varargParameterTypeRef.withReplacedConeType(varargArrayType, KtFakeSourceElementKind.VarargArgument) for ((i, arg) in argumentList.withIndex()) { val valueParameter = argumentMapping.getValue(arg) // Collect arguments if `arg` is a vararg argument of interest or other vararg arguments. diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/conversionOfSignedToUnsigned.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/conversionOfSignedToUnsigned.fir.kt index c15afedc409..e522843bead 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/conversions/conversionOfSignedToUnsigned.fir.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/conversions/conversionOfSignedToUnsigned.fir.kt @@ -36,7 +36,7 @@ fun takeUInt(@ImplicitIntegerCoercion u: UInt) {} fun takeULong(@ImplicitIntegerCoercion u: ULong) {} @ExperimentalUnsignedTypes -fun takeUBytes(@ImplicitIntegerCoercion vararg u: UByte) {} +fun takeUBytes(@ImplicitIntegerCoercion vararg u: UByte) {} fun takeLong(@ImplicitIntegerCoercion l: Long) {}