Skip to content

Commit 1a1157d

Browse files
authored
Merge pull request #11446 from CodaFi/like-a-bridge-over-troubled-decls
Reject member lookups that require bridging metatypes
2 parents e92bd50 + 88fe9c5 commit 1a1157d

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
32633263

32643264
// If the instance type is a bridged to an Objective-C type, perform
32653265
// a lookup into that Objective-C type.
3266-
if (bridgedType) {
3266+
if (bridgedType && !isMetatype) {
32673267
LookupResult &bridgedLookup = lookupMember(bridgedClass, memberName);
32683268
ModuleDecl *foundationModule = nullptr;
32693269
for (auto result : bridgedLookup) {

test/ClangImporter/objc_bridge_categories.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import AppKit
99

1010
func testStringBridge(_ str: String) {
1111
var str2 = str.nsStringMethod()!
12-
var int = String.nsStringClassMethod()
12+
var int = NSString.nsStringClassMethod()
1313
var str3 = str.nsStringProperty!
1414

1515
// Make sure the types worked out as expected
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import Foundation;
2+
3+
// rdar://problem/33830526: Constraint system should not add static methods
4+
// to the overload search space if it would require bridging unrelated metatypes.
5+
@interface NSString (Extension)
6+
+ (void) meth;
7+
@end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -typecheck -import-objc-header %S/Inputs/invalid_metatype_bridging_header.h %s -verify
2+
3+
// REQUIRES: objc_interop
4+
5+
// rdar://problem/33830526: Constraint system should not add static methods
6+
// to the overload search space if it would require bridging unrelated metatypes.
7+
class Crasher {
8+
static func called(argument: String) {}
9+
}
10+
11+
Crasher.called(argument: .meth) // expected-error {{type 'String' has no member 'meth'}}
12+
Crasher.called(argument: String.meth) // expected-error {{type 'String' has no member 'meth'}}

0 commit comments

Comments
 (0)