Skip to content

Revert "[TypeChecker] Fix crash with Objective C keypaths." #17537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2018
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
5 changes: 2 additions & 3 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -3280,8 +3280,7 @@ namespace {
if (auto keyPath = dyn_cast<KeyPathExpr>(expr)) {
if (keyPath->isObjC()) {
auto &cs = CG.getConstraintSystem();
if (!cs.getTypeChecker().checkObjCKeyPathExpr(cs.DC, keyPath))
return { false, nullptr };
(void)cs.getTypeChecker().checkObjCKeyPathExpr(cs.DC, keyPath);
}
}

Expand Down
6 changes: 1 addition & 5 deletions lib/Sema/TypeCheckExprObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -317,10 +317,6 @@ Optional<Type> TypeChecker::checkObjCKeyPathExpr(DeclContext *dc,
// Handle property references.
if (auto var = dyn_cast<VarDecl>(found)) {
validateDecl(var);
if (var->isInvalid() || !var->hasInterfaceType() ||
var->getInterfaceType()->hasError()) {
return None;
}

// Resolve this component to the variable we found.
auto varRef = ConcreteDeclRef(var);
Expand Down
7 changes: 1 addition & 6 deletions test/expr/primary/keypath/keypath-objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation

// REQUIRES: objc_interop

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

@objc var `repeat`: String?

@objc var noType // expected-error {{type annotation missing in pattern}}
}

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

// Property with no type
let _: String = #keyPath(A.noType)

// Nested type of a bridged type (rdar://problem/28061409).
typealias IntArray = [Int]
let _: String = #keyPath(IntArray.Foo.propString)
Expand Down