Skip to content

[SR-2203] Implicit self doesn't work in initializer of lazy var #44810

@harlanhaskins

Description

@harlanhaskins
Previous ID SR-2203
Radar None
Original Reporter @harlanhaskins
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 43f8e5edd99fb3c2f4f93df15da91423

is duplicated by:

  • SR-2329 self unavailable in closures to initialize lazy properties unless type specified
  • SR-4356 Type Interface could not resolve lazy var without type annotation.

relates to:

  • SR-4663 Bad diagnostic when missing explicit type in lazy property declaration
  • SR-48 Create warning for missing self in lazy var initialization

Issue Description:

struct Foo {
  let bar: Int
  lazy var baz: Int = {
    return /* self. */bar
  }()
}

Does not work unless I add a `self`before 'bar'

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions