Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions lib/Sema/TypeCheckDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3283,17 +3283,25 @@ class ObjCImplementationChecker {
if (reqParams.size() != implParams.size())
return false;

auto implParamList =
cast<AbstractFunctionDecl>(implDecl)->getParameters();
ParameterList *implParamList = nullptr;
if (auto afd = dyn_cast<AbstractFunctionDecl>(implDecl))
implParamList = afd->getParameters();

for (auto i : indices(reqParams)) {
const auto &reqParam = reqParams[i];
const auto &implParam = implParams[i];
ParamDecl *implParamDecl = implParamList->get(i);

if (!matchParamTypes(reqParam.getOldType(), implParam.getOldType(),
implParamDecl))
return false;
if (implParamList) {
// Some of the parameters may be IUOs; apply special logic.
if (!matchParamTypes(reqParam.getOldType(),
implParam.getOldType(),
implParamList->get(i)))
return false;
} else {
// IUOs not allowed here; apply ordinary logic.
if (!reqParam.getOldType()->matchesParameter(
implParam.getOldType(), matchOpts))
return false;
}
}

return matchTypes(funcReqTy->getResult(), funcImplTy->getResult(),
Expand Down
3 changes: 3 additions & 0 deletions test/decl/ext/Inputs/objc_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
- (void)instanceMethod1:(int)param;
- (void)instanceMethod2:(int)param;

// rdar://122280735 - crash when the parameter of a block property needs @escaping
@property (nonatomic, readonly) void (^ _Nonnull rdar122280735)(void (^_Nonnull completion)());

@end

@interface ObjCClass () <NSCopying>
Expand Down
4 changes: 4 additions & 0 deletions test/decl/ext/objc_implementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ protocol EmptySwiftProto {}
// OK
return self
}

// rdar://122280735 - crash when the parameter of a block property needs @escaping
let rdar122280735: (() -> ()) -> Void = { _ in }
// expected-warning@-1 {{property 'rdar122280735' of type '(() -> ()) -> Void' does not match type '(@escaping () -> Void) -> Void' declared by the header}}
}

@_objcImplementation(PresentAdditions) extension ObjCClass {
Expand Down
2 changes: 2 additions & 0 deletions test/decl/ext/objc_implementation_conflicts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ import objc_implementation_private
@objc func extensionMethod(fromHeader2: CInt) {}

@objc(copyWithZone:) func copy(with zone: NSZone?) -> Any { self }

let rdar122280735: (@escaping () -> ()) -> Void = { _ in }
}

@_objcImplementation(PresentAdditions) extension ObjCClass {
Expand Down