__auto_type does not infer nullability annotation

Number:rdar://36877120 Date Originated:January 25 2018, 11:50 AM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Other Bug Reproducible:Always
Using __auto_type in Obj-C does not infer the nullability annotation. 

1. It doesn't propagate any nullability annotations from the initializer expression, and
2. If you add an explicit nullability annotation it ignores it.

Steps to Reproduce:
Try to compile the following code with -Wnullable-to-nonnull-conversion:

#import <Foundation/Foundation.h>

void foo(NSObject * _Nullable x) {
    __auto_type y = x;
    NSObject * _Nonnull z = y;
    // this should warn about nullable-to-nonnull conversion

int main(int argc, char *argv[]) {

I've attached a zipfile that contains this source and a Makefile so you just run `make`.

Expected Results:
It should warn about a nullable-to-nonnull conversion.

Actual Results:
There is no warning.

Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0



https://reviews.llvm.org/D110216 was the fix. https://reviews.llvm.org/D116342 only fixed a crash introduced by D110216 when printing a warning.

By ryan.brown at April 4, 2023, 6:08 p.m. (reply...)

This appears to be fixed in version 17.0.0

My first guess is that https://reviews.llvm.org/D116342 was the fix.

By ellis.sparky.hoag at March 1, 2023, 1:31 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!