Don't copy default value parameters for fake overrides
This commit is contained in:
Generated
+5
@@ -14670,6 +14670,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
+18
-5
@@ -5,14 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.overrides
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
|
||||
class FakeOverrideCopier(
|
||||
symbolRemapper: SymbolRemapper,
|
||||
private val symbolRemapper: SymbolRemapper,
|
||||
private val typeRemapper: TypeRemapper,
|
||||
private val symbolRenamer: SymbolRenamer
|
||||
) : DeepCopyIrTreeWithSymbols(symbolRemapper, typeRemapper, symbolRenamer) {
|
||||
@@ -87,4 +84,20 @@ class FakeOverrideCopier(
|
||||
this.getter = declaration.getter?.transform()
|
||||
this.setter = declaration.setter?.transform()
|
||||
}
|
||||
|
||||
override fun visitValueParameter(declaration: IrValueParameter): IrValueParameter =
|
||||
declaration.factory.createValueParameter(
|
||||
declaration.startOffset, declaration.endOffset,
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredValueParameter(declaration.symbol),
|
||||
symbolRenamer.getValueParameterName(declaration.symbol),
|
||||
declaration.index,
|
||||
declaration.type.remapType(),
|
||||
declaration.varargElementType?.remapType(),
|
||||
declaration.isCrossinline,
|
||||
declaration.isNoinline
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
// Don't set the default value for fake overrides.
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
// KT-40083
|
||||
|
||||
open class X {
|
||||
open fun red(x: Int, y: (() -> Int) = { 31 }): Int {
|
||||
return x+y()
|
||||
}
|
||||
}
|
||||
|
||||
class Y: X()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
fun box(): String {
|
||||
if (Y().red(17) { 23 } != 40) return "FAIL 1"
|
||||
if (Y().red(29) != 60) return "FAIL 2"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+5
@@ -15895,6 +15895,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
+5
@@ -15895,6 +15895,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
+5
@@ -14670,6 +14670,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/ir/kt29833.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
Generated
+5
@@ -12770,6 +12770,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
Generated
+5
@@ -12770,6 +12770,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
+5
@@ -12835,6 +12835,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt40083.kt")
|
||||
public void testKt40083() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectClass.kt")
|
||||
public void testObjectClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/objectClass.kt");
|
||||
|
||||
Reference in New Issue
Block a user