llvm-project/clang/test/SemaObjC/method-conflict-2.m
Aaron Ballman 0f1c1be196 [clang] Remove rdar links; NFC
We have a new policy in place making links to private resources
something we try to avoid in source and test files. Normally, we'd
organically switch to the new policy rather than make a sweeping change
across a project. However, Clang is in a somewhat special circumstance
currently: recently, I've had several new contributors run into rdar
links around test code which their patch was changing the behavior of.
This turns out to be a surprisingly bad experience, especially for
newer folks, for a handful of reasons: not understanding what the link
is and feeling intimidated by it, wondering whether their changes are
actually breaking something important to a downstream in some way,
having to hunt down strangers not involved with the patch to impose on
them for help, accidental pressure from asking for potentially private
IP to be made public, etc. Because folks run into these links entirely
by chance (through fixing bugs or working on new features), there's not
really a set of problematic links to focus on -- all of the links have
basically the same potential for causing these problems. As a result,
this is an omnibus patch to remove all such links.

This was not a mechanical change; it was done by manually searching for
rdar, radar, radr, and other variants to find all the various
problematic links. From there, I tried to retain or reword the
surrounding comments so that we would lose as little context as
possible. However, because most links were just a plain link with no
supporting context, the majority of the changes are simple removals.

Differential Review: https://reviews.llvm.org/D158071
2023-08-28 12:13:42 -04:00

114 lines
2.7 KiB
Objective-C

// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
// RUN: %clang_cc1 -x objective-c++ -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
@interface A @end
@interface B : A @end
@interface Test1 {}
- (void) test1:(A*) object; // expected-note {{previous definition is here}}
- (void) test2:(B*) object;
@end
@implementation Test1
- (void) test1:(B*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
- (void) test2:(A*) object {}
@end
@interface Test2 {}
- (void) test1:(id) object; // expected-note {{previous definition is here}}
- (void) test2:(A*) object;
@end
@implementation Test2
- (void) test1:(A*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
- (void) test2:(id) object {}
@end
@interface Test3 {}
- (A*) test1;
- (B*) test2; // expected-note {{previous definition is here}}
@end
@implementation Test3
- (B*) test1 { return 0; }
- (A*) test2 { return 0; } // expected-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
@end
// The particular case of overriding with an id return is permitted.
@interface Test4 {}
- (id) test1;
- (A*) test2;
@end
@implementation Test4
- (A*) test1 { return 0; }
- (id) test2 { return 0; }
@end
typedef int int32_t;
typedef long long int64_t;
@interface NSObject @end
@protocol CKMessage
@property (nonatomic,readonly,assign) int64_t sequenceNumber; // expected-note {{previous definition is here}}
@end
@protocol CKMessage;
@interface CKIMMessage : NSObject<CKMessage>
@end
@implementation CKIMMessage
- (int32_t)sequenceNumber { // expected-warning {{conflicting return type in implementation of 'sequenceNumber': 'int64_t' (aka 'long long') vs 'int32_t' (aka 'int')}}
return 0;
}
@end
// Tests that property inherited indirectly from a nested protocol
// is seen by the method implementation type matching logic before
// method in super class is seen. This fixes the warning coming
// out of that method mismatch.
@interface NSObject (NSDict)
- (void)setValue:(id)value;
- (id)value;
@end
@protocol ProtocolWithValue
@property (nonatomic) unsigned value;
@end
@protocol InterveningProtocol <ProtocolWithValue>
@end
@interface UsesProtocolWithValue : NSObject <ProtocolWithValue>
@end
@implementation UsesProtocolWithValue
@synthesize value=_value;
- (unsigned) value
{
return _value;
}
- (void) setValue:(unsigned)value
{
_value = value;
}
@end
@interface UsesInterveningProtocol : NSObject <InterveningProtocol>
@end
@implementation UsesInterveningProtocol
@synthesize value=_value;
- (unsigned) value
{
return _value;
}
- (void) setValue:(unsigned)value
{
_value = value;
}
@end