mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-28 07:49:01 -04:00

The inference of _Nullable for weak Objective-C properties was broken in several ways: * It was back-patching the type information very late in the process of checking the attributes for an Objective-C property, which is just wrong. * It was using ad hoc checks to try to suppress the warning about missing nullability specifiers (-Wnullability-completeness), which didn't actual work in all cases (rdar://problem/22985457) * It was inferring _Nullable even outside of assumes-nonnull regions, which is wrong. Putting the inference of _Nullable for weak Objective-C properties in the same place as all of the other inference logic fixes all of these ills. llvm-svn: 249896
27 lines
658 B
Objective-C
27 lines
658 B
Objective-C
// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -Wnullable-to-nonnull-conversion %s -verify
|
|
|
|
|
|
// rdar://19985330
|
|
@interface NSObject @end
|
|
|
|
@class NSFoo;
|
|
void foo (NSFoo * _Nonnull);
|
|
|
|
@interface NSBar : NSObject
|
|
@property(weak) NSFoo *property1;
|
|
@end
|
|
|
|
#pragma clang assume_nonnull begin
|
|
@interface NSBar ()
|
|
@property(weak) NSFoo *property2;
|
|
@end
|
|
|
|
#pragma clang assume_nonnull end
|
|
|
|
@implementation NSBar
|
|
- (void) Meth {
|
|
foo (self.property1); // no warning because nothing is inferred
|
|
foo (self.property2); // expected-warning {{implicit conversion from nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * _Nonnull'}}
|
|
}
|
|
@end
|