Skip to content

Commit 48f24b0

Browse files
authored
Merge pull request #29866 from xedin/rdar-57356196
[CSApply] Always use `String` type for ObjC interop key path
2 parents 50e9cc3 + ae79b0d commit 48f24b0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4312,7 +4312,7 @@ namespace {
43124312
StringRef(stringCopy, compatStringBuf.size()),
43134313
SourceRange(),
43144314
/*implicit*/ true);
4315-
cs.setType(stringExpr, cs.getType(E));
4315+
cs.setType(stringExpr, TypeChecker::getStringType(cs.getASTContext()));
43164316
E->setObjCStringLiteralExpr(stringExpr);
43174317
}
43184318
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -verify
2+
// REQUIRES: objc_interop
3+
4+
import Foundation
5+
6+
@objc class A : NSObject {
7+
@objc var x: Int = 42
8+
}
9+
10+
@propertyWrapper
11+
struct Attr<V> {
12+
var wrappedValue: V {
13+
get { fatalError() }
14+
}
15+
16+
init(wrappedValue: V, key: KeyPath<A, V>) {}
17+
}
18+
19+
class B {
20+
@Attr(key: \.x) var y: Int = 0 // Ok
21+
}

0 commit comments

Comments
 (0)