Unexpected pre-declaration of `self` when inheriting from UIViewController before subclass is initialized

Originator:alheureux
Number:rdar://38884833 Date Originated:3/26/2018
Status:Duplicate Open (24223414) Resolved:
Product:UIKit Product Version:
Classification:Serious Bug Reproducible:Always
 
Summary:
Inheriting from UIViewController appears to come with an unexpected redeclaration of `self` before initialization of the superclass. In the example attached, a UIBarButtonItem can be initialized with a target of `self` before `self` should be valid/available. If you use it in this way, the selector will never receive a message because whatever `self` it refers to is definitely not the instance we are creating.

Steps to Reproduce:
Open playground, notice that self can be used before super initialization. Note that whatever self it is is not this instance as if you try to use that UIBarButtonItem it will not work.

Expected Results:
Compiler error.

Actual Results:
Compiles fine and silently fails because of apparent declaration of self prior to initialization.

Version/Build:
iOS 11.2.6

Configuration:
Playground / Simulator / etc

-----------------------------

Since the attached playground isn't on openradar, here's a screenshot: https://i.imgur.com/YVd6dP3.png

Comments


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!