-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#47136
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsFeature: expressionsidentifiersFeature: IdentifiersFeature: Identifiersmissing warningBug: Missing warningBug: Missing warningselfFeature → expressions: The 'self' expressionFeature → expressions: The 'self' expressionswift 5.6type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
| Previous ID | SR-8440 |
| Radar | None |
| Original Reporter | kanersan (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Duplicate |
Environment
Xcode 9.4.1 - Swift 4.1
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: e2dca743fabfb653f26fcddaaaf02779
duplicates:
Issue Description:
Using self inside an initializer causes compiler error, which makes sense.
However, trying to use self to hookup a touchUpInside action on a UIKit object (for example UIButton) which is a let computed property doesn't cause compiler errors.
Below code is what I mean:
let someButton: UIButton = {
let button = UIButton()
button.addTarget(self, action: #selector(buttonTappedFunction), for: .touchUpInside)
}()And the action doesn't work but the code compiles and runs.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of ImplementationexpressionsFeature: expressionsFeature: expressionsidentifiersFeature: IdentifiersFeature: Identifiersmissing warningBug: Missing warningBug: Missing warningselfFeature → expressions: The 'self' expressionFeature → expressions: The 'self' expressionswift 5.6type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis