mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add trivial accessors to static properties (as well as instance properties).
This is a better fix for rdar://problem/19941580: by providing trivial accessors for all static properties, we have them there for any other type checking that might need them, including the Objective-C selector checking from the radar. Swift SVN r25730
This commit is contained in:
@@ -1813,7 +1813,7 @@ void swift::maybeAddMaterializeForSet(AbstractStorageDecl *storage,
|
||||
}
|
||||
|
||||
void swift::maybeAddAccessorsToVariable(VarDecl *var, TypeChecker &TC) {
|
||||
if (var->getGetter() || var->isStatic() || var->isBeingTypeChecked())
|
||||
if (var->getGetter() || var->isBeingTypeChecked())
|
||||
return;
|
||||
|
||||
// Lazy variables need accessors.
|
||||
|
||||
@@ -2655,12 +2655,7 @@ public:
|
||||
TC.diagnose(VD->getLoc(), diag::extension_stored_property);
|
||||
VD->setInvalid();
|
||||
VD->overwriteType(ErrorType::get(TC.Context));
|
||||
} // Objective-C compatible class types with static stored properties
|
||||
// can be accessed as Objective-C class methods but need accessors
|
||||
// to do so.
|
||||
else if (VD->isObjC() && VD->isStatic() && VD->hasStorage())
|
||||
if (!VD->hasAccessorFunctions())
|
||||
addTrivialAccessorsToStorage(VD, TC);
|
||||
}
|
||||
}
|
||||
|
||||
// Synthesize accessors for lazy, all checking already been performed.
|
||||
|
||||
@@ -31,3 +31,14 @@ public class SuperB : NSObject {
|
||||
public class SubB : SuperB {
|
||||
public override init(bar: String) { super.init(bar: bar) }
|
||||
}
|
||||
|
||||
// rdar://problem/19941580
|
||||
public class Foo : NSObject, FooProto {
|
||||
public static var staticEntityName: String = "yo"
|
||||
public var entityName: String = "yo"
|
||||
}
|
||||
|
||||
@objc public protocol FooProto {
|
||||
static var staticEntityName: String { get }
|
||||
var entityName: String { get }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse -parse-as-library -primary-file %S/Inputs/objc_multi_file_2.swift %s -verify
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse -parse-as-library -primary-file %s %S/Inputs/objc_multi_file_2.swift -verify
|
||||
|
||||
// RUN: rm -rf %t && mkdir %t
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module %S/Inputs/objc_multi_file_2.swift -DFAKE_UIIMAGE -o %t
|
||||
@@ -36,3 +37,8 @@ class SubSubB2 : SubB {
|
||||
// okay: doesn't conflict with hidden initializer
|
||||
func initWithWibble(s: String) { }
|
||||
}
|
||||
|
||||
// rdar://problem/19941580
|
||||
func rdar19941580(foo: Foo) {
|
||||
var fp: FooProto = foo
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user