Skip to content

Commit 7b76115

Browse files
committed
Remove the parent/sub type lookup logic
1 parent aa72ea8 commit 7b76115

File tree

2 files changed

+24
-98
lines changed

2 files changed

+24
-98
lines changed

lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -936,24 +936,8 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
936936
if (!specificTypeLookup.getSingleTypeResult()) {
937937
return nullptr;
938938
}
939-
940-
if (typeDecl->getDeclaredInterfaceType()->matches(
941-
specificTypeLookup.getSingleTypeResult()
942-
->getDeclaredInterfaceType(),
943-
TypeMatchFlags::AllowOverride)) {
944-
// If the Context Name contain the name of the subclass then we would
945-
// find the renamed in the superclass instead
946-
typeDecl = specificTypeLookup.getSingleTypeResult();
947-
} else if (!specificTypeLookup.getSingleTypeResult()
948-
->getDeclaredInterfaceType()
949-
->matches(typeDecl->getDeclaredInterfaceType(),
950-
TypeMatchFlags::AllowOverride)) {
951-
// Failed and print the raw renamed attributed when there is no
952-
// relationship between those 2 types
953-
return nullptr;
954-
}
955939
}
956-
940+
957941
const ValueDecl *renamedDecl = nullptr;
958942
SmallVector<ValueDecl *, 4> lookupResults;
959943
declContext->lookupQualified(typeDecl, renamedDeclName,
@@ -978,8 +962,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
978962
for (auto index : indices(*cParams)) {
979963
auto cParamsType = cParams->get(index)->getType();
980964
auto dParamsType = dParams->get(index)->getType();
981-
if (!cParamsType->matchesParameter(dParamsType,
982-
TypeMatchFlags::AllowOverride)) {
965+
if (!cParamsType->matchesParameter(dParamsType, TypeMatchOptions())) {
983966
hasSameParameterTypes = false;
984967
break;
985968
}

test/PrintAsObjC/availability.swift

Lines changed: 22 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@
177177
// CHECK-NEXT: - (void)deprecatedOnMacOSMethodInDeprecatedClassWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
178178
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedOnMacOSMethodInDeprecatedClassWithPrimitiveParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithPrimitiveParameters(first:second:)': use method in another class instead");
179179

180-
// CHECK-NEXT: - (void)deprecatedMethodInDeprecatedClassWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
181-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("use method in another class instead", "ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)")
182-
// CHECK-NEXT: - (void)deprecatedOnMacOSMethodInDeprecatedClassWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
183-
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedOnMacOSMethodInDeprecatedClassWithSuperclassObjectParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)': use method in another class instead");
180+
// CHECK-NEXT: - (void)deprecatedMethodInDeprecatedClassWithClassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
181+
// CHECK-SAME: SWIFT_DEPRECATED_MSG("use method in another class instead", "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
182+
// CHECK-NEXT: - (void)deprecatedOnMacOSMethodInDeprecatedClassWithClassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
183+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedOnMacOSMethodInDeprecatedClassWithClassObjectParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)': use method in another class instead");
184184

185185
// CHECK-NEXT: @end
186186

@@ -194,56 +194,31 @@
194194

195195
// CHECK-LABEL: @interface SWTReplacementAvailable
196196
// CHECK-NEXT: - (void)replacingMethodInReplacementClassWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second;
197-
// CHECK-NEXT: - (void)replacingMethodInReplacementClassWithSuperclassObjectParametersWithFirst:(SWTSubclassOfReplacementAvailable * _Nonnull)first second:(SWTSubclassOfReplacementAvailable * _Nonnull)second;
197+
// CHECK-NEXT: - (void)replacingMethodInReplacementClassWithClassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second;
198198
// CHECK-NEXT: - (void)deprecatedMethodReplacingInReplacementClassWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
199199
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - ContextName is self",
200200
// CHECK-SAME: "replacingMethodInReplacementClassWithPrimitiveParametersWithFirst:second:")
201-
// CHECK-NEXT: - (void)deprecatedmethodReplacingInReplacementClassWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
201+
// CHECK-NEXT: - (void)deprecatedmethodReplacingInReplacementClassWithClassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
202202
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - ContextName is self",
203-
// CHECK-SAME: "replacingMethodInReplacementClassWithSuperclassObjectParametersWithFirst:second:")
203+
// CHECK-SAME: "replacingMethodInReplacementClassWithClassObjectParametersWithFirst:second:")
204204
// CHECK-NEXT: @end
205205

206206
// CHECK-LABEL: @protocol SWTReplacementAvailableProtocol
207207
// CHECK-NEXT: - (void)replacingMethodInReplacementProtocolWithFirst:(NSInteger)first second:(NSInteger)second;
208208
// CHECK-NEXT: @end
209209

210210

211-
// CHECK-LABEL: @interface SWTSubclassOfReplacementAvailable : SWTReplacementAvailable
212-
// CHECK-NEXT: - (void)deprecatedMethodInSubclassOfReplacedInSuperclassWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
213-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - Rename to superclass's method", "replacingMethodInReplacementClassWithPrimitiveParametersWithFirst:second:");
214-
// CHECK-NEXT: - (void)deprecatedMethodInSubclassOfReplacedInSubclassButUnavilableWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
215-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - Rename to unavilable subclass's method",
216-
// CHECK-SAME: "SubclassOfSubclassOfReplacementAvailable.methodReplacingInSubclassOfSubclassOfReplacementClassWithPrimitiveParameters(first:second:)")
217-
// CHECK-NEXT: - (void)deprecatedMethodInSubclassOfReplacedInSubclassButAvilableWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
218-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - Rename to available subclass's method",
219-
// CHECK-SAME: "replacingMethodInReplacementClassWithPrimitiveParametersWithFirst:second:")
220-
221-
// CHECK-NEXT: - (void)deprecatedMethodInSubclassOfReplacedInSuperclassWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
222-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - Rename to superclass's method", "replacingMethodInReplacementClassWithSuperclassObjectParametersWithFirst:second:");
223-
// CHECK-NEXT: - (void)deprecatedMethodInSubclassOfReplacedInSubclassButUnavilableWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
224-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - Rename to unavilable subclass's method",
225-
// CHECK-SAME: "SubclassOfSubclassOfReplacementAvailable.methodReplacingInSubclassOfSubclassOfObjectClass(first:second:)")
226-
// CHECK-NEXT: - (void)deprecatedMethodInSubclassOfReplacedInSubclassButAvilableWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
227-
// CHECK-SAME: SWIFT_DEPRECATED_MSG("Deprecated method with the Context name in the renamed attribute - Rename to available subclass's method",
228-
// CHECK-SAME: "replacingMethodInReplacementClassWithSuperclassObjectParametersWithFirst:second:")
229-
230-
// CHECK-NEXT: @end
231-
232-
// CHECK-LABEL: @interface SWTSubclassOfSubclassOfReplacementAvailable : SWTSubclassOfReplacementAvailable
233-
// CHECK-NEXT: - (void)methodReplacingInSubclassOfSubclassOfReplacementClassWithFirst:(NSInteger)first second:(NSInteger)second;
234-
// CHECK-NEXT: @end
235-
236211
// CHECK-LABEL: SWIFT_AVAILABILITY(macos,unavailable,message="'UnavailableAvailability' has been renamed to 'SWTReplacementAvailable'")
237212
// CHECK-LABEL: @interface UnavailableAvailability
238213
// CHECK-NEXT: - (void)unavailableMethodInUnavailableClassWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
239214
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailableMethodInUnavailableClassWithPrimitiveParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithPrimitiveParameters(first:second:)': use method in another class instead")
240215
// CHECK-NEXT: - (void)unavailableOnMacOSMethodInUnavailableClassWithPrimitiveParametersWithFirst:(NSInteger)first second:(NSInteger)second
241216
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableOnMacOSMethodInUnavailableClassWithPrimitiveParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithPrimitiveParameters(first:second:)': use method in another class instead");
242217

243-
// CHECK-NEXT: - (void)unavailableMethodInUnavailableClassWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
244-
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailableMethodInUnavailableClassWithSuperclassObjectParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)': use method in another class instead")
245-
// CHECK-NEXT: - (void)unavailableOnMacOSMethodInUnavailableClassWithSuperclassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
246-
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableOnMacOSMethodInUnavailableClassWithSuperclassObjectParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)': use method in another class instead");
218+
// CHECK-NEXT: - (void)unavailableMethodInUnavailableClassWithClassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
219+
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailableMethodInUnavailableClassWithClassObjectParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)': use method in another class instead")
220+
// CHECK-NEXT: - (void)unavailableOnMacOSMethodInUnavailableClassWithClassObjectParametersWithFirst:(SWTReplacementAvailable * _Nonnull)first second:(SWTReplacementAvailable * _Nonnull)second
221+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableOnMacOSMethodInUnavailableClassWithClassObjectParameters' has been renamed to 'ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)': use method in another class instead");
247222
// CHECK-NEXT: @end
248223

249224
// CHECK-LABEL: SWIFT_AVAILABILITY(macos,unavailable,message="'UnavailableAvailabilityProtocol' has been renamed to 'SWTReplacementAvailableProtocol'")
@@ -598,8 +573,8 @@ extension Availability {
598573
@objc(replacingMethodInReplacementClassWithPrimitiveParametersWithFirst:second:)
599574
func methodReplacingInReplacementClassWithPrimitiveParameters(first: Int, second: Int) -> Void {}
600575

601-
@objc(replacingMethodInReplacementClassWithSuperclassObjectParametersWithFirst:second:)
602-
func methodReplacingInReplacementClassWithClassObjectParameters(first: SubclassOfReplacementAvailable, second: SubclassOfReplacementAvailable) -> Void {}
576+
@objc(replacingMethodInReplacementClassWithClassObjectParametersWithFirst:second:)
577+
func methodReplacingInReplacementClassWithClassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
603578

604579
@available(*, deprecated,
605580
message: "Deprecated method with the Context name in the renamed attribute - ContextName is self",
@@ -609,39 +584,7 @@ extension Availability {
609584
@available(*, deprecated,
610585
message: "Deprecated method with the Context name in the renamed attribute - ContextName is self",
611586
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
612-
@objc func deprecatedmethodReplacingInReplacementClassWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
613-
}
614-
615-
@objc(SWTSubclassOfReplacementAvailable) class SubclassOfReplacementAvailable : ReplacementAvailable {
616-
@available(*, deprecated,
617-
message: "Deprecated method with the Context name in the renamed attribute - Rename to superclass's method",
618-
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithPrimitiveParameters(first:second:)")
619-
@objc func deprecatedMethodInSubclassOfReplacedInSuperclassWithPrimitiveParameters(first: Int, second: Int) -> Void {}
620-
@available(*, deprecated,
621-
message: "Deprecated method with the Context name in the renamed attribute - Rename to unavilable subclass's method",
622-
renamed: "SubclassOfSubclassOfReplacementAvailable.methodReplacingInSubclassOfSubclassOfReplacementClassWithPrimitiveParameters(first:second:)")
623-
@objc func deprecatedMethodInSubclassOfReplacedInSubclassButUnavilableWithPrimitiveParameters(first: Int, second: Int) -> Void {}
624-
@available(*, deprecated,
625-
message: "Deprecated method with the Context name in the renamed attribute - Rename to available subclass's method",
626-
renamed: "SubclassOfSubclassOfReplacementAvailable.methodReplacingInReplacementClassWithPrimitiveParameters(first:second:)")
627-
@objc func deprecatedMethodInSubclassOfReplacedInSubclassButAvilableWithPrimitiveParameters(first: Int, second: Int) -> Void {}
628-
629-
@available(*, deprecated,
630-
message: "Deprecated method with the Context name in the renamed attribute - Rename to superclass's method",
631-
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
632-
@objc func deprecatedMethodInSubclassOfReplacedInSuperclassWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
633-
@available(*, deprecated,
634-
message: "Deprecated method with the Context name in the renamed attribute - Rename to unavilable subclass's method",
635-
renamed: "SubclassOfSubclassOfReplacementAvailable.methodReplacingInSubclassOfSubclassOfObjectClass(first:second:)")
636-
@objc func deprecatedMethodInSubclassOfReplacedInSubclassButUnavilableWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
637-
@available(*, deprecated,
638-
message: "Deprecated method with the Context name in the renamed attribute - Rename to available subclass's method",
639-
renamed: "SubclassOfSubclassOfReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
640-
@objc func deprecatedMethodInSubclassOfReplacedInSubclassButAvilableWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
641-
}
642-
643-
@objc(SWTSubclassOfSubclassOfReplacementAvailable) class SubclassOfSubclassOfReplacementAvailable : SubclassOfReplacementAvailable {
644-
@objc func methodReplacingInSubclassOfSubclassOfReplacementClass(first: Int, second: Int) -> Void {}
587+
@objc func deprecatedmethodReplacingInReplacementClassWithClassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
645588
}
646589

647590
@available(macOS, deprecated, renamed: "ReplacementAvailable")
@@ -654,11 +597,11 @@ extension Availability {
654597
@objc func deprecatedOnMacOSMethodInDeprecatedClassWithPrimitiveParameters(first: Int, second: Int) -> Void {}
655598

656599
@available(*, deprecated, message: "use method in another class instead",
657-
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)")
658-
@objc func deprecatedMethodInDeprecatedClassWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
600+
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
601+
@objc func deprecatedMethodInDeprecatedClassWithClassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
659602
@available(macOS, deprecated, message: "use method in another class instead",
660-
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)")
661-
@objc func deprecatedOnMacOSMethodInDeprecatedClassWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
603+
renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
604+
@objc func deprecatedOnMacOSMethodInDeprecatedClassWithClassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
662605
}
663606

664607
@available(macOS, unavailable, renamed: "ReplacementAvailable")
@@ -668,10 +611,10 @@ extension Availability {
668611
@available(macOS, unavailable, message: "use method in another class instead", renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithPrimitiveParameters(first:second:)")
669612
@objc func unavailableOnMacOSMethodInUnavailableClassWithPrimitiveParameters(first: Int, second: Int) -> Void {}
670613

671-
@available(*, unavailable, message: "use method in another class instead", renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)")
672-
@objc func unavailableMethodInUnavailableClassWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
673-
@available(macOS, unavailable, message: "use method in another class instead", renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithSuperclassObjectParameters(first:second:)")
674-
@objc func unavailableOnMacOSMethodInUnavailableClassWithSuperclassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
614+
@available(*, unavailable, message: "use method in another class instead", renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
615+
@objc func unavailableMethodInUnavailableClassWithClassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
616+
@available(macOS, unavailable, message: "use method in another class instead", renamed: "ReplacementAvailable.methodReplacingInReplacementClassWithClassObjectParameters(first:second:)")
617+
@objc func unavailableOnMacOSMethodInUnavailableClassWithClassObjectParameters(first: ReplacementAvailable, second: ReplacementAvailable) -> Void {}
675618
}
676619

677620
@objc(SWTReplacementAvailableProtocol) protocol ReplacementAvailableProtocol {

0 commit comments

Comments
 (0)