mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSDiagnostics] Use simplified locator to find owner type of a requirement failure
Only simplified locator points to the right underlying expression. Resolves: rdar://116122902
This commit is contained in:
@@ -216,8 +216,7 @@ bool FailureDiagnostic::conformsToKnownProtocol(
|
||||
}
|
||||
|
||||
Type RequirementFailure::getOwnerType() const {
|
||||
auto anchor = getRawAnchor();
|
||||
|
||||
auto anchor = getAnchor();
|
||||
// If diagnostic is anchored at assignment expression
|
||||
// it means that requirement failure happened while trying
|
||||
// to convert source to destination, which means that
|
||||
|
||||
@@ -353,7 +353,7 @@ func existential_good<T: P1>(_: T.Type) {
|
||||
}
|
||||
|
||||
func existential_bad<T>(_: T.Type) {
|
||||
_ = Free<T>() as P2 // expected-error{{protocol 'P2' requires that 'T' conform to 'P1'}}
|
||||
_ = Free<T>() as P2 // expected-error{{generic struct 'Free' requires that 'T' conform to 'P1'}}
|
||||
}
|
||||
|
||||
// rdar://problem/35837054
|
||||
|
||||
@@ -45,7 +45,7 @@ func arraySameType() {
|
||||
|
||||
let _: SameType = arrayWorks as SameType
|
||||
let _: SameType = arrayFails as SameType
|
||||
// expected-error@-1 {{protocol 'SameType' requires the types 'Fails' and 'Works' be equivalent}}
|
||||
// expected-error@-1 {{generic struct 'Array' requires the types 'Fails' and 'Works' be equivalent}}
|
||||
}
|
||||
|
||||
func dictionarySameType() {
|
||||
@@ -70,7 +70,7 @@ func dictionarySameType() {
|
||||
|
||||
let _: SameType = dictWorks as SameType
|
||||
let _: SameType = dictFails as SameType
|
||||
// expected-error@-1 {{protocol 'SameType' requires the types 'Fails' and 'Works' be equivalent}}
|
||||
// expected-error@-1 {{generic struct 'Dictionary' requires the types 'Fails' and 'Works' be equivalent}}
|
||||
}
|
||||
|
||||
func arrayConforms() {
|
||||
@@ -91,11 +91,11 @@ func arrayConforms() {
|
||||
|
||||
let _: Conforms = [works] as Conforms
|
||||
let _: Conforms = [fails] as Conforms
|
||||
// expected-error@-1 {{protocol 'Conforms' requires that 'Fails' conform to 'Conforms'}}
|
||||
// expected-error@-1 {{generic struct 'Array' requires that 'Fails' conform to 'Conforms'}}
|
||||
|
||||
let _: Conforms = arrayWorks as Conforms
|
||||
let _: Conforms = arrayFails as Conforms
|
||||
// expected-error@-1 {{protocol 'Conforms' requires that 'Fails' conform to 'Conforms'}}
|
||||
// expected-error@-1 {{generic struct 'Array' requires that 'Fails' conform to 'Conforms'}}
|
||||
}
|
||||
|
||||
func dictionaryConforms() {
|
||||
@@ -116,11 +116,11 @@ func dictionaryConforms() {
|
||||
|
||||
let _: Conforms = [0 : works] as Conforms
|
||||
let _: Conforms = [0 : fails] as Conforms
|
||||
// expected-error@-1 {{protocol 'Conforms' requires that 'Fails' conform to 'Conforms'}}
|
||||
// expected-error@-1 {{generic struct 'Dictionary' requires that 'Fails' conform to 'Conforms'}}
|
||||
|
||||
let _: Conforms = dictWorks as Conforms
|
||||
let _: Conforms = dictFails as Conforms
|
||||
// expected-error@-1 {{protocol 'Conforms' requires that 'Fails' conform to 'Conforms'}}
|
||||
// expected-error@-1 {{generic struct 'Dictionary' requires that 'Fails' conform to 'Conforms'}}
|
||||
}
|
||||
|
||||
func combined() {
|
||||
@@ -133,6 +133,6 @@ func combined() {
|
||||
// expected-error@-1 {{type 'any Conforms' cannot conform to 'Conforms'}} expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
|
||||
|
||||
let _: Conforms = [[0: [1 : [fails]] as Conforms]]
|
||||
// expected-error@-1 {{protocol 'Conforms' requires that 'Fails' conform to 'Conforms'}}
|
||||
// expected-error@-1 {{generic struct 'Dictionary' requires that 'Fails' conform to 'Conforms'}}
|
||||
// expected-error@-2 {{type 'any Conforms' cannot conform to 'Conforms'}} expected-note@-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user