[SR-7981] self
available without backticks in let initialization closure of NSObject
#50515
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
duplicate
Resolution: Duplicates another issue
expressions
Feature: expressions
identifiers
Feature: Identifiers
missing warning
Bug: Missing warning
self
Feature → expressions: The 'self' expression
swift 5.6
type checker
Area → compiler: Semantic analysis
Environment
Xcode 9.3.0.
Additional Detail from JIRA
md5: 8bc95e194233eeaad7dd08b80e745ab5
duplicates:
Issue Description:
This code compiles. In Xcode, it even colors
self
as though it's a keyword.But
self
is actuallyNSObject.self
, which is a function.Note that in a non-NSObject subclass, this code does not compile, with the error "error: use of unresolved identifier 'self'". So I'm guessing that the compiler currently has a hack of some sort to prevent
self
from referring toNSObject.self
as in the class object in this context, since that would be confusing. And that that's why the compiler allowsNSObject.self
to not be backticked.Note that
also doesn't compile, nor does refering to a
func `self`()
function without backticks, so allowing this is clearly wrong.The text was updated successfully, but these errors were encountered: