[psi2ir] Ignore private members when creating fake overrides from descriptors

The behavior is unified with the IR deserializer.
See `isOverridableMemberOrAccessor` in IrOverridingUtil.kt

Without this change, if we add a private member to the Any in wasm stdlib,
the compiler starts crashing with a linker error.

It's hard to write a relevant, self-contained box test for that since it requires
adding a private member to Any and affects **only** "virtual" FunctionN interfaces.
This commit is contained in:
Zalim Bashorov
2023-03-28 01:24:08 +02:00
parent 0c1afcac67
commit 34f8851ac1
@@ -351,8 +351,11 @@ class IrDescriptorBasedFunctionFactory(
private fun IrClass.addFakeOverrides() {
val fakeOverrideDescriptors = descriptor.unsubstitutedMemberScope.getContributedDescriptors(DescriptorKindFilter.CALLABLES)
.filterIsInstance<CallableMemberDescriptor>().filter { it.kind === CallableMemberDescriptor.Kind.FAKE_OVERRIDE }
val fakeOverrideDescriptors =
descriptor.unsubstitutedMemberScope.getContributedDescriptors(DescriptorKindFilter.CALLABLES).asSequence()
.filterIsInstance<CallableMemberDescriptor>()
.filter { it.kind === CallableMemberDescriptor.Kind.FAKE_OVERRIDE && it.dispatchReceiverParameter != null }
.filter { !DescriptorVisibilities.isPrivate(it.visibility) && it.visibility != DescriptorVisibilities.INVISIBLE_FAKE }
fun createFakeOverrideFunction(descriptor: FunctionDescriptor, property: IrPropertySymbol?): IrSimpleFunction {
val returnType = descriptor.returnType?.let { toIrType(it) } ?: error("No return type for $descriptor")