mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The computation that determined whether an access to a `let` instance property within a constructor should be an initialization conflated the cases of "we don't have a base expression" and "the base expression is not something that could be `self`", and incorrectly identified rvalue bases as being "initializable". Make the interface properly separate out these cases, so we don't turn an lvalue into an rvalue access. Fixes rdar://128661833.
23 lines
556 B
Swift
23 lines
556 B
Swift
// RUN: %target-swift-frontend -typecheck -dump-ast %s | %FileCheck %s
|
|
|
|
public struct Data {
|
|
init(_ bytes: [UInt8]) { }
|
|
}
|
|
|
|
internal struct Item {
|
|
public let data: Data
|
|
|
|
public init(tag: UInt8) {
|
|
self.data = Data([tag << 2])
|
|
}
|
|
|
|
// CHECK-LABEL: constructor_decl{{.*}}"init(tag:value:)"
|
|
public init(tag: UInt8, value: UInt) {
|
|
// CHECK: assign_expr
|
|
// CHECK: member_ref_expr type="@lvalue Data"
|
|
// CHECK-NEXT: declref_expr type="@lvalue Item"
|
|
// CHECK-NEXT: member_ref_expr type="Data"
|
|
self.data = Self(tag: tag).data
|
|
}
|
|
}
|