@@ -13768,6 +13768,19 @@ ConstraintSystem::simplifyPointerToCPointerRestriction(
13768
13768
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
13769
13769
};
13770
13770
13771
+ auto elementLoc = locator.withPathElement(LocatorPathElt::GenericArgument(0));
13772
+
13773
+ if (swiftPtr->isTypeVariableOrMember()) {
13774
+ // Inference between the equivalent pointer kinds is
13775
+ // handled by regular pointer conversions.
13776
+ if (swiftPtrKind == cPtrKind)
13777
+ return SolutionKind::Error;
13778
+
13779
+ addConstraint(ConstraintKind::BindToPointerType, swiftPtr, cPtr,
13780
+ elementLoc);
13781
+ return markSupported();
13782
+ }
13783
+
13771
13784
// If pointers have the same element type there is nothing to do.
13772
13785
if (swiftPtr->isEqual(cPtr))
13773
13786
return markSupported();
@@ -13783,15 +13796,10 @@ ConstraintSystem::simplifyPointerToCPointerRestriction(
13783
13796
// Unsafe[Mutable]Pointer<T> -> Unsafe[Mutable]Pointer<[U]Int8>
13784
13797
if (cPtr->isInt8() || cPtr->isUInt8()) {
13785
13798
// <T> can default to the type of C pointer.
13786
- addConstraint(
13787
- ConstraintKind::Defaultable, swiftPtr, cPtr,
13788
- locator.withPathElement(LocatorPathElt::GenericArgument(0)));
13799
+ addConstraint(ConstraintKind::Defaultable, swiftPtr, cPtr, elementLoc);
13789
13800
return markSupported();
13790
13801
}
13791
13802
13792
- auto elementLoc =
13793
- locator.withPathElement(LocatorPathElt::GenericArgument(0));
13794
-
13795
13803
// Unsafe[Mutable]Pointer<Int{8, 16, ...}> <->
13796
13804
// Unsafe[Mutable]Pointer<UInt{8, 16, ...}>
13797
13805
if (swiftPtr->isInt() || swiftPtr->isUInt()) {
0 commit comments