[TBDGen] The non-deallocating destructor applies to some @objc classes.

The non-deallocating destructor doesn't exists when dealloc can be overriden,
which means any class that inherits from a class defined in Objective-C. This
isn't necessarily all @objc classes, because of the
-disable-objc-attr-requires-foundation-module flag.

Fixes rdar://problem/40542246.
This commit is contained in:
Huon Wilson
2018-05-25 19:53:46 +10:00
parent 24abeca16a
commit 859d0a79ba
4 changed files with 54 additions and 38 deletions

View File

@@ -0,0 +1,37 @@
// RUN: %empty-directory(%t)
// RUN: %gyb %s > %t/main.swift
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -import-objc-header %S/Inputs/objc_class_header.h -validate-tbd-against-ir=all %t/main.swift -disable-objc-attr-requires-foundation-module
// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -import-objc-header %S/Inputs/objc_class_header.h -validate-tbd-against-ir=all %t/main.swift -disable-objc-attr-requires-foundation-module
// REQUIRES: objc_interop
import Foundation
% names = ["Public", "Internal", "Private"]
% for i, name in enumerate(names):
% access = name.lower()
// a class by itself
${access} class ${name}Empty: NSObject {}
// subclasses of that
% for subname in names[i:]:
% subaccess = subname.lower()
${subaccess} class ${subname}Sub${name}Empty: ${name}Empty {}
%end
${access} class ${name}InheritObjCProtocol: NSObject, ObjCProtocol {}
// some bugs were revealed when there's @objc without inheriting from
// NSObject.
@objc ${access} class ${name}ObjCOnly {}
%end
@usableFromInline
@objc
internal class InternalObjCOnlyUsableFromInline {}