Skip to content

Commit b378e38

Browse files
committed
[Fixit] Also add & to bridge T and UnsafeMutablePointer<T>.
1 parent f19e6cb commit b378e38

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3491,7 +3491,8 @@ bool FailureDiagnosis::diagnoseContextualConversionError() {
34913491
return true;
34923492
}
34933493
}
3494-
} else if (contextDecl == CS->TC.Context.getUnsafePointerDecl()) {
3494+
} else if (contextDecl == CS->TC.Context.getUnsafePointerDecl() ||
3495+
contextDecl == CS->TC.Context.getUnsafeMutablePointerDecl()) {
34953496
SmallVector<Type, 4> scratch;
34963497
for (Type arg : contextualType->getAllGenericArgs(scratch)) {
34973498
if (arg->isEqual(exprType)) {

test/Sema/diag_type_conversion.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
func foo1(_ a: [Int]) {}
44
func foo2(_ a : UnsafePointer<Int>) {}
5+
func foo4(_ a : UnsafeMutablePointer<Int>) {}
56
func foo3 () {
67
foo1(1) // expected-error {{cannot convert value of type 'Int' to expected argument type '[Int]'}} {{8-8=[}} {{9-9=]}}
78
foo2(1) // expected-error {{cannot convert value of type 'Int' to expected argument type 'UnsafePointer<Int>'}} {{8-8=&}}
89
var j = 3
910
foo2(j) // expected-error {{cannot convert value of type 'Int' to expected argument type 'UnsafePointer<Int>'}} {{8-8=&}}
11+
foo4(j) // expected-error {{cannot convert value of type 'Int' to expected argument type 'UnsafeMutablePointer<Int>'}} {{8-8=&}}
1012
}

0 commit comments

Comments
 (0)