From 8fb7cfcea97af440830d256cc18ccd978f218e1d Mon Sep 17 00:00:00 2001 From: Volodymyr Sapsai Date: Tue, 7 Apr 2020 17:41:30 -0700 Subject: [PATCH] Revert "[ObjC generics] Fix not inheriting type bounds in categories/extensions." This reverts commit a8c8b627f23f204fb621bd2a8c495cfc8bc16ae7. It causes intermittent Clang :: SemaObjC/parameterized_classes_subst.m test failures on various bots. --- clang/include/clang/AST/ASTContext.h | 2 -- clang/lib/AST/ASTContext.cpp | 11 ----------- clang/lib/AST/Type.cpp | 1 - clang/lib/Sema/SemaDeclObjC.cpp | 6 ++++-- .../SemaObjC/parameterized_classes_collection_literal.m | 10 +--------- clang/test/SemaObjC/parameterized_classes_subst.m | 14 -------------- 6 files changed, 5 insertions(+), 39 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 6360f18..6813ab5 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1442,8 +1442,6 @@ public: QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef protocols) const; - void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, - ObjCTypeParamDecl *New) const; bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl); diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 06dcb6f..1e81e0a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4874,17 +4874,6 @@ ASTContext::getObjCTypeParamType(const ObjCTypeParamDecl *Decl, return QualType(newType, 0); } -void ASTContext::adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, - ObjCTypeParamDecl *New) const { - New->setTypeSourceInfo(getTrivialTypeSourceInfo(Orig->getUnderlyingType())); - // Update TypeForDecl after updating TypeSourceInfo. - auto NewTypeParamTy = cast(New->getTypeForDecl()); - SmallVector protocols; - protocols.append(NewTypeParamTy->qual_begin(), NewTypeParamTy->qual_end()); - QualType UpdatedTy = getObjCTypeParamType(New, protocols); - New->setTypeForDecl(UpdatedTy.getTypePtr()); -} - /// ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's /// protocol list adopt all protocols in QT's qualified-id protocol /// list. diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 7c65378..3428437 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -3534,7 +3534,6 @@ void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID, const ObjCTypeParamDecl *OTPDecl, ArrayRef protocols) { ID.AddPointer(OTPDecl); - ID.AddPointer(OTPDecl->getUnderlyingType().getAsOpaquePtr()); ID.AddInteger(protocols.size()); for (auto proto : protocols) ID.AddPointer(proto); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 6db5789..934e1a2 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -938,7 +938,8 @@ static bool checkTypeParamListConsistency(Sema &S, // Override the new type parameter's bound type with the previous type, // so that it's consistent. - S.Context.adjustObjCTypeParamBoundType(prevTypeParam, newTypeParam); + newTypeParam->setTypeSourceInfo( + S.Context.getTrivialTypeSourceInfo(prevTypeParam->getUnderlyingType())); continue; } @@ -965,7 +966,8 @@ static bool checkTypeParamListConsistency(Sema &S, } // Update the new type parameter's bound to match the previous one. - S.Context.adjustObjCTypeParamBoundType(prevTypeParam, newTypeParam); + newTypeParam->setTypeSourceInfo( + S.Context.getTrivialTypeSourceInfo(prevTypeParam->getUnderlyingType())); } return false; diff --git a/clang/test/SemaObjC/parameterized_classes_collection_literal.m b/clang/test/SemaObjC/parameterized_classes_collection_literal.m index 034d2e8..472746e0 100644 --- a/clang/test/SemaObjC/parameterized_classes_collection_literal.m +++ b/clang/test/SemaObjC/parameterized_classes_collection_literal.m @@ -29,9 +29,7 @@ __attribute__((objc_root_class)) @end @interface NSDictionary : NSObject -+ (instancetype)dictionaryWithObjects:(const V [])objects - forKeys:(const K [])keys - count:(NSUInteger)cnt; ++ (instancetype)dictionaryWithObjects:(const V [])objects forKeys:(const K [])keys count:(NSUInteger)cnt; @end void testArrayLiteral(void) { @@ -52,9 +50,3 @@ void testDictionaryLiteral(void) { @"world" : @"blah" // expected-warning{{object of type 'NSString *' is not compatible with dictionary value type 'NSNumber *'}} }; } - -void testCastingInDictionaryLiteral(NSString *arg) { - NSDictionary *dict = @{ - (id)arg : @"foo", - }; -} diff --git a/clang/test/SemaObjC/parameterized_classes_subst.m b/clang/test/SemaObjC/parameterized_classes_subst.m index b6d8847..d14a6e9 100644 --- a/clang/test/SemaObjC/parameterized_classes_subst.m +++ b/clang/test/SemaObjC/parameterized_classes_subst.m @@ -467,17 +467,3 @@ void bar(MyMutableDictionary *stringsByString, - (void)mapUsingBlock2:(id)block { // expected-warning{{conflicting parameter types in implementation}} } @end - -// -------------------------------------------------------------------------- -// Use a type parameter as a type argument. -// -------------------------------------------------------------------------- -// Type bounds in a category/extension are omitted. rdar://problem/54329242 -@interface ParameterizedContainer> -- (ParameterizedContainer *)inInterface; -@end -@interface ParameterizedContainer (Cat) -- (ParameterizedContainer *)inCategory; -@end -@interface ParameterizedContainer () -- (ParameterizedContainer *)inExtension; -@end -- 2.7.4