mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Property Wrappers] Use the outermost wrapper attribute type as the
contextual type for property wrapper initialization
This commit is contained in:
@@ -4219,6 +4219,7 @@ void SolutionApplicationTarget::maybeApplyPropertyWrapper() {
|
|||||||
// the initializer type later.
|
// the initializer type later.
|
||||||
expression.wrappedVar = singleVar;
|
expression.wrappedVar = singleVar;
|
||||||
expression.expression = backingInitializer;
|
expression.expression = backingInitializer;
|
||||||
|
expression.convertType = outermostWrapperAttr->getTypeLoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
SolutionApplicationTarget SolutionApplicationTarget::forInitialization(
|
SolutionApplicationTarget SolutionApplicationTarget::forInitialization(
|
||||||
|
|||||||
@@ -19,3 +19,18 @@ let _: A<Int>.C = 0
|
|||||||
// expected-error@-1 {{'A<Int>.C' (aka 'Int') requires the types 'Int' and 'Int32' be equivalent}}
|
// expected-error@-1 {{'A<Int>.C' (aka 'Int') requires the types 'Int' and 'Int32' be equivalent}}
|
||||||
let _: A<Int>.B.E = 0
|
let _: A<Int>.B.E = 0
|
||||||
// expected-error@-1 {{'A<Int>.B' requires the types 'Int' and 'Int32' be equivalent}}
|
// expected-error@-1 {{'A<Int>.B' requires the types 'Int' and 'Int32' be equivalent}}
|
||||||
|
|
||||||
|
|
||||||
|
protocol P {}
|
||||||
|
|
||||||
|
@propertyWrapper
|
||||||
|
struct Wrapper<T: P> { // expected-note {{where 'T' = 'Int'}}
|
||||||
|
var wrappedValue: T
|
||||||
|
}
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static let i = 1
|
||||||
|
|
||||||
|
@Wrapper // expected-error{{generic struct 'Wrapper' requires that 'Int' conform to 'P'}}
|
||||||
|
var value = C.i
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user