]> granicus.if.org Git - clang/commitdiff
[Objective-C Sema] Use canonical type of properties when comparing
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 8 Apr 2015 21:34:04 +0000 (21:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 8 Apr 2015 21:34:04 +0000 (21:34 +0000)
redeclaration of property in class extension and to avoid
bogus error. rdar://20469452

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234440 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaObjCProperty.cpp
test/SemaObjC/property-9.m

index f4f43360f5e1465e9c4fd4d538a9e8cd4f9ed70f..5e7b4b8b859dff92e060c4ed6871876ca91f10fb 100644 (file)
@@ -407,9 +407,11 @@ Sema::HandlePropertyInClassExtension(Scope *S,
     // this conversion is safe only because the wider type is for a 'readonly'
     // property in primary class and 'narrowed' type for a 'readwrite' property
     // in continuation class.
-    if (!isa<ObjCObjectPointerType>(PIDecl->getType()) ||
-        !isa<ObjCObjectPointerType>(PDecl->getType()) ||
-        (!isObjCPointerConversion(PDecl->getType(), PIDecl->getType(), 
+    QualType PrimaryClassPropertyT = Context.getCanonicalType(PIDecl->getType());
+    QualType ClassExtPropertyT = Context.getCanonicalType(PDecl->getType());
+    if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
+        !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
+        (!isObjCPointerConversion(ClassExtPropertyT, PrimaryClassPropertyT,
                                   ConvertedType, IncompatibleObjC))
         || IncompatibleObjC) {
       Diag(AtLoc, 
index 4bed8751b6a80cf9ff77ae7f8751a8c4382547a9..623143d54967bd9ce9d5fc81a49c75ae5b178e0d 100644 (file)
@@ -106,3 +106,18 @@ id f0(MDATestDocument *d) {
   return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance'}}
 }
 
+// rdar://20469452
+@interface UIView @end
+
+@interface FRFakeBannerView : UIView
+@end
+
+@interface FRAdCollectionViewCell
+@property (nonatomic, weak, readonly) UIView *bannerView;
+@end
+
+@interface FRAdCollectionViewCell () 
+
+@property (nonatomic, weak, readwrite) FRFakeBannerView *bannerView;
+
+@end