Skip to content

[ClangImporter] Handle property with getter that returns instancetype #12414

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
Oct 16, 2017
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
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3772,7 +3772,7 @@ namespace {

// If the method has a related result type that is representable
// in Swift as DynamicSelf, do so.
if (decl->hasRelatedResultType()) {
if (!prop && decl->hasRelatedResultType()) {
result->setDynamicSelf(true);
resultTy = DynamicSelfType::get(dc->getSelfInterfaceType(),
Impl.SwiftContext);
Expand Down
5 changes: 5 additions & 0 deletions test/ClangImporter/Inputs/custom-modules/ObjCParseExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,8 @@ typedef SomeCell <NSCopying> *CopyableSomeCell;
// Note the custom setter name here; this is important.
@property (setter=takeFooForBar:) BOOL fooForBar;
@end

@interface InstancetypeAccessor : NSObject
@property (class, readonly) InstancetypeAccessor *prop;
+ (instancetype)prop;
@end
15 changes: 15 additions & 0 deletions test/ClangImporter/objc_parse_verifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-sil -I %S/Inputs/custom-modules %s -verify > /dev/null

// REQUIRES: objc_interop
// expected-no-diagnostics

// This file tests the AST verifier, which performs extra checks when there are
// no errors emitted. Please do not add any.


import ObjCParseExtras

func test() {
// Properties with instancetype getters.
_ = InstancetypeAccessor.prop
}