forked from OSchip/llvm-project
ObjectiveC migrator. If a class implements a protocol's
properties, then class conforms to that protocol. llvm-svn: 186460
This commit is contained in:
parent
305bb90442
commit
2bc3dda186
|
@ -250,17 +250,22 @@ ClassImplementsAllMethodsAndProperties(ASTContext &Ctx,
|
||||||
if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
|
if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
|
||||||
continue;
|
continue;
|
||||||
DeclContext::lookup_const_result R = IDecl->lookup(Property->getDeclName());
|
DeclContext::lookup_const_result R = IDecl->lookup(Property->getDeclName());
|
||||||
if (R.size() == 0)
|
if (R.size() == 0) {
|
||||||
return false;
|
// Relax the rule and look into class's implementation for a synthesize
|
||||||
for (unsigned I = 0, N = R.size(); I != N; ++I) {
|
// or dynamic declaration. Class is implementing a property coming from
|
||||||
if (ObjCPropertyDecl *ClassProperty = dyn_cast<ObjCPropertyDecl>(R[0])) {
|
// another protocol. This still makes the target protocol as conforming.
|
||||||
if (ClassProperty->getPropertyAttributes()
|
if (!ImpDecl->FindPropertyImplDecl(
|
||||||
!= Property->getPropertyAttributes())
|
Property->getDeclName().getAsIdentifierInfo()))
|
||||||
return false;
|
return false;
|
||||||
if (!Ctx.hasSameType(ClassProperty->getType(), Property->getType()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (ObjCPropertyDecl *ClassProperty = dyn_cast<ObjCPropertyDecl>(R[0])) {
|
||||||
|
if ((ClassProperty->getPropertyAttributes()
|
||||||
|
!= Property->getPropertyAttributes()) ||
|
||||||
|
!Ctx.hasSameType(ClassProperty->getType(), Property->getType()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// At this point, all required properties in this protocol conform to those
|
// At this point, all required properties in this protocol conform to those
|
||||||
// declared in the class.
|
// declared in the class.
|
||||||
|
|
|
@ -46,3 +46,18 @@
|
||||||
- (id) Meth1: (double) arg { return 0; }
|
- (id) Meth1: (double) arg { return 0; }
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
// Test5 - conforms to P3 because it implement's P3's property.
|
||||||
|
@protocol P3
|
||||||
|
@property (copy) id Prop;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol P4
|
||||||
|
@property (copy) id Prop;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface Test5 : NSObject<P3>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation Test5
|
||||||
|
@synthesize Prop=_XXX;
|
||||||
|
@end
|
||||||
|
|
|
@ -46,3 +46,18 @@
|
||||||
- (id) Meth1: (double) arg { return 0; }
|
- (id) Meth1: (double) arg { return 0; }
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
// Test5 - conforms to P3 because it implement's P3's property.
|
||||||
|
@protocol P3
|
||||||
|
@property (copy) id Prop;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol P4
|
||||||
|
@property (copy) id Prop;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface Test5 : NSObject<P3, P4>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation Test5
|
||||||
|
@synthesize Prop=_XXX;
|
||||||
|
@end
|
||||||
|
|
Loading…
Reference in New Issue