Don't copy default value parameters for fake overrides

This commit is contained in:
Alexander Gorshenev
2020-07-28 21:46:55 +03:00
parent 2cfd776092
commit 9a717e9ecf
9 changed files with 74 additions and 5 deletions
@@ -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");
@@ -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
View File
@@ -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"
}
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");