Description
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VSMac 17.6.3 (build 421)
Description
Consider a class like this:
data class Foo(val value: String)
class FooManager {
private var customFoo: Foo? = null
private var defaultFoo = Foo("default")
val foo
get() = customFoo ?: defaultFoo
fun setCustomFoo(value: Foo) {
customFoo = value
}
}
setCustomFoo is a public set of a private var, but it shouldn't be eliminated because it's not generated because of Kotlin's "internal".
https://github.com/xamarin/java.interop/blob/main/tests/Xamarin.Android.Tools.Bytecode-Tests/kotlin/NameShadowing.kt#L13
fun setType(type: Int) = { println (type); }
should be fun setType(type: Int) { println (type); }
The equals make setType
return Unit() and not void, so the test case does pass as expected. If we fix this, then the test case fails because setType is being removed.
I think the best course is to modify KotlinFixups::FixupProperty
to only remove them if both the getter and setter exist and they're both public. There could still be some scenarios where this is inadvertently hiding functions, so maybe there needs to be a way to manually skip this check?
Steps to Reproduce
Fix the NameShadowing setType class and the test cases will fail.
Did you find any workaround?
Override and force it public: https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata#visibility
Or changing the backing field in the library so the names don't conflict.
Relevant log output
No response