IR. Change visibility to lowered default function/constructors to public
This commit is contained in:
+4
@@ -9,6 +9,8 @@ import org.jetbrains.kotlin.backend.common.*
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.*
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
@@ -361,6 +363,7 @@ private fun IrFunction.generateDefaultsFunctionImpl(context: CommonBackendContex
|
||||
isExternal = false
|
||||
isPrimary = false
|
||||
isExpect = false
|
||||
visibility = Visibilities.PUBLIC
|
||||
}
|
||||
is IrSimpleFunction ->
|
||||
buildFunWithDescriptorForInlining(descriptor) {
|
||||
@@ -370,6 +373,7 @@ private fun IrFunction.generateDefaultsFunctionImpl(context: CommonBackendContex
|
||||
modality = Modality.FINAL
|
||||
isExternal = false
|
||||
isTailrec = false
|
||||
visibility = Visibilities.PUBLIC
|
||||
}
|
||||
else -> throw IllegalStateException("Unknown function type")
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// FILE: Foo.kt
|
||||
|
||||
package foo
|
||||
|
||||
open class Foo() {
|
||||
protected fun foo(value: Boolean = false) = if (!value) "OK" else "fail5"
|
||||
}
|
||||
|
||||
// FILE: Bar.kt
|
||||
|
||||
package bar
|
||||
|
||||
import foo.Foo
|
||||
|
||||
class Bar() : Foo() {
|
||||
fun execute(): String {
|
||||
return object { fun test() = foo() }.test ()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Bar().execute()
|
||||
}
|
||||
|
||||
// @bar/Bar.class:
|
||||
// 0 access\$
|
||||
// 0 INVOKESTATIC foo/Foo.foo\$default
|
||||
|
||||
// @bar/Bar$execute$1.class:
|
||||
// 0 access\$
|
||||
// 1 INVOKESTATIC foo/Foo.foo\$default
|
||||
@@ -1,7 +1,19 @@
|
||||
class MyClass() {
|
||||
fun test(s: String = "") {}
|
||||
open class MyClass() {
|
||||
fun testPublic(s: String = "") {}
|
||||
|
||||
protected fun testProtected(s: String = "") {}
|
||||
|
||||
private fun testPrivate(s: String = "") {}
|
||||
}
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: MyClass, test$default
|
||||
// TESTED_OBJECTS: MyClass, testPublic$default
|
||||
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: MyClass, testProtected$default
|
||||
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
|
||||
|
||||
// TESTED_OBJECT_KIND: function
|
||||
// TESTED_OBJECTS: MyClass, testPrivate$default
|
||||
// FLAGS: ACC_PUBLIC, ACC_STATIC, ACC_SYNTHETIC
|
||||
@@ -1580,6 +1580,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/defaultArguments/methodHandlerElimination.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAccessorForDefault.kt")
|
||||
public void testNoAccessorForDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noAccessorForDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noEmptyArray.kt")
|
||||
public void testNoEmptyArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noEmptyArray.kt");
|
||||
|
||||
+5
@@ -1535,6 +1535,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/defaultArguments/methodHandlerElimination.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noAccessorForDefault.kt")
|
||||
public void testNoAccessorForDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noAccessorForDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noEmptyArray.kt")
|
||||
public void testNoEmptyArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noEmptyArray.kt");
|
||||
|
||||
Reference in New Issue
Block a user