Skip to content

Commit 38e724b

Browse files
authored
Merge pull request swiftlang#33809 from xedin/rdar-68254165
[ConstraintSystem] Record generic fix if destination of a pointer con…
2 parents 56f6d9e + e4f6041 commit 38e724b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3829,8 +3829,11 @@ bool ConstraintSystem::repairFailures(
38293829
// If this is an implicit 'something-to-pointer' conversion
38303830
// it's going to be diagnosed by specialized fix which deals
38313831
// with generic argument mismatches.
3832-
if (matchKind == ConstraintKind::BindToPointerType)
3833-
break;
3832+
if (matchKind == ConstraintKind::BindToPointerType) {
3833+
auto *member = rhs->getAs<DependentMemberType>();
3834+
if (!(member && member->getBase()->hasHole()))
3835+
break;
3836+
}
38343837

38353838
// If this is a ~= operator implicitly generated by pattern matching
38363839
// let's not try to fix right-hand side of the operator because it's

test/Constraints/valid_pointer_conversions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ func SR12382(_ x: UnsafeMutablePointer<Double>??) {}
4141
var i = 0
4242
SR12382(&i) // expected-error {{cannot convert value of type 'UnsafeMutablePointer<Int>' to expected argument type 'UnsafeMutablePointer<Double>'}}
4343
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('Int' and 'Double') are expected to be equal}}
44+
45+
//problem/68254165 - Bad diagnostic when using String init(decodingCString:) with an incorrect pointer type
46+
func rdar68254165(ptr: UnsafeMutablePointer<Int8>) {
47+
_ = String(decodingCString: ptr, as: .utf8) // expected-error {{generic parameter 'Encoding' could not be inferred}}
48+
// expected-error@-1 {{type '_.Type' has no member 'utf8'}}
49+
}

0 commit comments

Comments
 (0)