Author: dgregor Date: Tue Dec 8 16:45:17 2015 New Revision: 255066 URL: http://llvm.org/viewvc/llvm-project?rev=255066&view=rev Log: Objective-C properties: fix bogus use of "isa<>" on a QualType.
The code used "isa" to check the type and then "getAs" to look through sugar; we need to look through the sugar when checking, too, otherwise any kind of sugar (nullability qualifiers in the example; or a typedef) will thwart this semantic check. Fixes rdar://problem/23804250. Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=255066&r1=255065&r2=255066&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original) +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Dec 8 16:45:17 2015 @@ -1372,12 +1372,11 @@ bool Sema::DiagnosePropertyAccessorMisma QualType PropertyIvarType = property->getType().getNonReferenceType(); bool compat = Context.hasSameType(PropertyIvarType, GetterType); if (!compat) { - if (isa<ObjCObjectPointerType>(PropertyIvarType) && - isa<ObjCObjectPointerType>(GetterType)) - compat = - Context.canAssignObjCInterfaces( - GetterType->getAs<ObjCObjectPointerType>(), - PropertyIvarType->getAs<ObjCObjectPointerType>()); + const ObjCObjectPointerType *propertyObjCPtr = nullptr; + const ObjCObjectPointerType *getterObjCPtr = nullptr; + if ((propertyObjCPtr = PropertyIvarType->getAs<ObjCObjectPointerType>()) && + (getterObjCPtr = GetterType->getAs<ObjCObjectPointerType>())) + compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr); else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType) != Compatible) { Diag(Loc, diag::error_property_accessor_type) Modified: cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm?rev=255066&r1=255065&r2=255066&view=diff ============================================================================== --- cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm (original) +++ cfe/trunk/test/SemaObjCXX/property-type-mismatch.mm Tue Dec 8 16:45:17 2015 @@ -18,3 +18,13 @@ @property (assign) NSObject<P2> *prop; @end +@interface C<T> : NSObject +@end + +@interface D +@property (nonatomic,readonly,nonnull) C<D *> *property; +@end + +@interface D () +@property (nonatomic, setter=_setProperty:) C *property; // okay +@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits