mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintSystem] Record generic fix if destination of a pointer conversion is invalid
If the right-hand side (destination) of value-to-pointer conversion is incorrect e.g. base type of member is a hole, let's record a generic "invalid conversion" failure. Resolves: rdar://problem/68254165
This commit is contained in:
@@ -3829,8 +3829,11 @@ bool ConstraintSystem::repairFailures(
|
|||||||
// If this is an implicit 'something-to-pointer' conversion
|
// If this is an implicit 'something-to-pointer' conversion
|
||||||
// it's going to be diagnosed by specialized fix which deals
|
// it's going to be diagnosed by specialized fix which deals
|
||||||
// with generic argument mismatches.
|
// with generic argument mismatches.
|
||||||
if (matchKind == ConstraintKind::BindToPointerType)
|
if (matchKind == ConstraintKind::BindToPointerType) {
|
||||||
break;
|
auto *member = rhs->getAs<DependentMemberType>();
|
||||||
|
if (!(member && member->getBase()->hasHole()))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// If this is a ~= operator implicitly generated by pattern matching
|
// If this is a ~= operator implicitly generated by pattern matching
|
||||||
// let's not try to fix right-hand side of the operator because it's
|
// let's not try to fix right-hand side of the operator because it's
|
||||||
|
|||||||
@@ -41,3 +41,9 @@ func SR12382(_ x: UnsafeMutablePointer<Double>??) {}
|
|||||||
var i = 0
|
var i = 0
|
||||||
SR12382(&i) // expected-error {{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Double>'}}
|
SR12382(&i) // expected-error {{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Double>'}}
|
||||||
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
|
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
|
||||||
|
|
||||||
|
//problem/68254165 - Bad diagnostic when using String init(decodingCString:) with an incorrect pointer type
|
||||||
|
func rdar68254165(ptr: UnsafeMutablePointer<Int8>) {
|
||||||
|
_ = String(decodingCString: ptr, as: .utf8) // expected-error {{generic parameter 'Encoding' could not be inferred}}
|
||||||
|
// expected-error@-1 {{type '_.Type' has no member 'utf8'}}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user