diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index a6563aa7fa550..86ae993fb893d 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -3829,8 +3829,11 @@ bool ConstraintSystem::repairFailures( // If this is an implicit 'something-to-pointer' conversion // it's going to be diagnosed by specialized fix which deals // with generic argument mismatches. - if (matchKind == ConstraintKind::BindToPointerType) - break; + if (matchKind == ConstraintKind::BindToPointerType) { + auto *member = rhs->getAs(); + if (!(member && member->getBase()->hasHole())) + break; + } // 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 diff --git a/test/Constraints/valid_pointer_conversions.swift b/test/Constraints/valid_pointer_conversions.swift index 3a3bd9ea9cbc4..1cb1fb4ff1887 100644 --- a/test/Constraints/valid_pointer_conversions.swift +++ b/test/Constraints/valid_pointer_conversions.swift @@ -41,3 +41,9 @@ func SR12382(_ x: UnsafeMutablePointer??) {} var i = 0 SR12382(&i) // expected-error {{cannot convert value of type 'UnsafeMutablePointer' to expected argument type 'UnsafeMutablePointer'}} // 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) { + _ = String(decodingCString: ptr, as: .utf8) // expected-error {{generic parameter 'Encoding' could not be inferred}} + // expected-error@-1 {{type '_.Type' has no member 'utf8'}} +}