mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Type checker] Marking a class as @objc doesn’t require an interface type.
Fixes the crash in SR-8540 / rdar://problem/43383512.
This commit is contained in:
@@ -1520,11 +1520,11 @@ void markAsObjC(ValueDecl *D, ObjCReason reason,
|
|||||||
attr->setInvalid();
|
attr->setInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!D->hasInterfaceType()) {
|
if (!isa<TypeDecl>(D) && !D->hasInterfaceType()) {
|
||||||
ctx.getLazyResolver()->resolveDeclSignature(D);
|
ctx.getLazyResolver()->resolveDeclSignature(D);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isa<AccessorDecl>(D)) {
|
if (!isa<AccessorDecl>(D) && !isa<TypeDecl>(D)) {
|
||||||
useObjectiveCBridgeableConformances(D->getInnermostDeclContext(),
|
useObjectiveCBridgeableConformances(D->getInnermostDeclContext(),
|
||||||
D->getInterfaceType());
|
D->getInterfaceType());
|
||||||
}
|
}
|
||||||
|
|||||||
7
test/multifile/Inputs/objc-protocol-bridging.h
Normal file
7
test/multifile/Inputs/objc-protocol-bridging.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
@import Foundation;
|
||||||
|
|
||||||
|
@class SwiftClass;
|
||||||
|
@protocol ObjCProtocol
|
||||||
|
@optional
|
||||||
|
-(void)method:(nullable SwiftClass *)object;
|
||||||
|
@end
|
||||||
3
test/multifile/Inputs/objc-protocol-other.swift
Normal file
3
test/multifile/Inputs/objc-protocol-other.swift
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objc class SwiftClass : NSObject { }
|
||||||
7
test/multifile/objc-protocol.swift
Normal file
7
test/multifile/objc-protocol.swift
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// RUN: %target-swift-frontend -module-name test -emit-ir -primary-file %s %S/Inputs/objc-protocol-other.swift -import-objc-header %S/Inputs/objc-protocol-bridging.h -sdk %sdk -o %t.o
|
||||||
|
|
||||||
|
// REQUIRES: objc_interop
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objc class Foo : NSObject, ObjCProtocol { }
|
||||||
Reference in New Issue
Block a user