Skip to content

Commit 2c297a6

Browse files
authored
Merge pull request #17537 from apple/revert-17497-rdar40955755
Revert "[TypeChecker] Fix crash with Objective C keypaths."
2 parents bc4b0d1 + 16a0808 commit 2c297a6

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -3280,8 +3280,7 @@ namespace {
32803280
if (auto keyPath = dyn_cast<KeyPathExpr>(expr)) {
32813281
if (keyPath->isObjC()) {
32823282
auto &cs = CG.getConstraintSystem();
3283-
if (!cs.getTypeChecker().checkObjCKeyPathExpr(cs.DC, keyPath))
3284-
return { false, nullptr };
3283+
(void)cs.getTypeChecker().checkObjCKeyPathExpr(cs.DC, keyPath);
32853284
}
32863285
}
32873286

lib/Sema/TypeCheckExprObjC.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -317,10 +317,6 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
317317
// Handle property references.
318318
if (auto var = dyn_cast<VarDecl>(found)) {
319319
validateDecl(var);
320-
if (var->isInvalid() || !var->hasInterfaceType() ||
321-
var->getInterfaceType()->hasError()) {
322-
return None;
323-
}
324320

325321
// Resolve this component to the variable we found.
326322
auto varRef = ConcreteDeclRef(var);

test/expr/primary/keypath/keypath-objc.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Foundation
44

55
// REQUIRES: objc_interop
66

7-
@objc class A : NSObject { // expected-error {{class 'A' has no initializers}}
7+
@objc class A : NSObject {
88
@objc var propB: B = B()
99
@objc var propString: String = "" // expected-note {{did you mean 'propString'}}
1010
@objc var propArray: [String] = []
@@ -21,8 +21,6 @@ import Foundation
2121
@objc func someMethod() { }
2222

2323
@objc var `repeat`: String?
24-
25-
@objc var noType // expected-error {{type annotation missing in pattern}}
2624
}
2725

2826
@objc class B : NSObject {
@@ -108,9 +106,6 @@ func testKeyPath(a: A, b: B) {
108106
// Property with keyword name.
109107
let _: String = #keyPath(A.repeat)
110108

111-
// Property with no type
112-
let _: String = #keyPath(A.noType)
113-
114109
// Nested type of a bridged type (rdar://problem/28061409).
115110
typealias IntArray = [Int]
116111
let _: String = #keyPath(IntArray.Foo.propString)

0 commit comments

Comments
 (0)