Douglas Gregor | 813a066 | 2015-06-19 18:14:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -Wnullable-to-nonnull-conversion %s -verify |
| 2 | |
| 3 | |
| 4 | // rdar://19985330 |
| 5 | @interface NSObject @end |
| 6 | |
| 7 | @class NSFoo; |
Douglas Gregor | aea7afd | 2015-06-24 22:02:08 +0000 | [diff] [blame] | 8 | void foo (NSFoo * _Nonnull); |
Douglas Gregor | 813a066 | 2015-06-19 18:14:38 +0000 | [diff] [blame] | 9 | |
| 10 | @interface NSBar : NSObject |
| 11 | @property(weak) NSFoo *property1; |
| 12 | @end |
| 13 | |
Douglas Gregor | d4f2afa | 2015-10-09 20:36:17 +0000 | [diff] [blame] | 14 | #pragma clang assume_nonnull begin |
| 15 | @interface NSBar () |
| 16 | @property(weak) NSFoo *property2; |
| 17 | @end |
| 18 | |
| 19 | #pragma clang assume_nonnull end |
| 20 | |
Douglas Gregor | 813a066 | 2015-06-19 18:14:38 +0000 | [diff] [blame] | 21 | @implementation NSBar |
| 22 | - (void) Meth { |
Douglas Gregor | d4f2afa | 2015-10-09 20:36:17 +0000 | [diff] [blame] | 23 | foo (self.property1); // no warning because nothing is inferred |
| 24 | foo (self.property2); // expected-warning {{implicit conversion from nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * _Nonnull'}} |
Douglas Gregor | 813a066 | 2015-06-19 18:14:38 +0000 | [diff] [blame] | 25 | } |
| 26 | @end |