Native: apply ObjCExport virtual adapters from interfaces of supers

Previously they were skipped, and this was an incorrect optimization:
even if super class implements the interface too, this doesn't mean
that virtual adapters provided by that interface are inherited
by non-exported subclass that needs them;
for example, this doesn't happen when the super class is exported
(i.e. Obj-C class is not created at runtime).

Remove incorrect optimization instead of making it more sophisticated,
because it is useless anyway.

^KT-46431 Fixed
This commit is contained in:
Svyatoslav Scherbina
2021-06-11 15:35:25 +03:00
committed by Space
parent b7fbe09ef4
commit 5d5628f56e
5 changed files with 82 additions and 4 deletions
@@ -1027,10 +1027,12 @@ static Class createClass(const TypeInfo* typeInfo, Class superClass) {
for (int i = 0; i < typeInfo->implementedInterfacesCount_; ++i) {
const TypeInfo* interface = typeInfo->implementedInterfaces_[i];
if (superImplementedInterfaces.find(interface) == superImplementedInterfaces.end()) {
const ObjCTypeAdapter* typeAdapter = getTypeAdapter(interface);
if (typeAdapter != nullptr) {
addVirtualAdapters(result, typeAdapter);
const ObjCTypeAdapter* typeAdapter = getTypeAdapter(interface);
if (typeAdapter != nullptr) {
// Note: we could avoid adding virtual adapters if inherited from super type,
// but what's the point?
addVirtualAdapters(result, typeAdapter);
if (superImplementedInterfaces.find(interface) == superImplementedInterfaces.end()) {
addProtocolForAdapter(result, typeAdapter);
}
}