mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Thin to thin is also allowed
This commit is contained in:
@@ -1367,6 +1367,15 @@ static bool matchFunctionRepresentations(FunctionTypeRepresentation rep1,
|
|||||||
if (!(last && last->is<LocatorPathElt::FunctionArgument>()))
|
if (!(last && last->is<LocatorPathElt::FunctionArgument>()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto isThin = [](FunctionTypeRepresentation rep) {
|
||||||
|
return rep == FunctionTypeRepresentation::CFunctionPointer ||
|
||||||
|
rep == FunctionTypeRepresentation::Thin;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Allowing "thin" (c, thin) to "thin" conventions
|
||||||
|
if (isThin(rep1) && isThin(rep2))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Allowing all to "thick" (swift, block) conventions
|
// Allowing all to "thick" (swift, block) conventions
|
||||||
// "thin" (c, thin) to "thick" or "thick" to "thick"
|
// "thin" (c, thin) to "thick" or "thick" to "thick"
|
||||||
if (rep2 == FunctionTypeRepresentation::Swift ||
|
if (rep2 == FunctionTypeRepresentation::Swift ||
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ func cContext() {
|
|||||||
|
|
||||||
let _ : (@convention(c) () -> Void) -> Void = c.function // OK
|
let _ : (@convention(c) () -> Void) -> Void = c.function // OK
|
||||||
|
|
||||||
let _ : (@convention(thin) () -> Void) -> Void = c.function
|
let _ : (@convention(thin) () -> Void) -> Void = c.function // OK
|
||||||
// expected-error@-1 {{cannot convert value of type '(@convention(c) () -> Void) -> Void' to specified type '(@convention(thin) () -> Void) -> Void'}}
|
|
||||||
|
|
||||||
let _ : (() -> Void) -> Void = c.function
|
let _ : (() -> Void) -> Void = c.function
|
||||||
// expected-error@-1 {{cannot convert value of type '(@convention(c) () -> Void) -> Void' to specified type '(() -> Void) -> Void'}}
|
// expected-error@-1 {{cannot convert value of type '(@convention(c) () -> Void) -> Void' to specified type '(() -> Void) -> Void'}}
|
||||||
@@ -59,8 +58,7 @@ func thinContext() {
|
|||||||
let _ : (@convention(block) () -> Void) -> Void = thin.function
|
let _ : (@convention(block) () -> Void) -> Void = thin.function
|
||||||
// expected-error@-1 {{cannot convert value of type '(@convention(thin) () -> Void) -> Void' to specified type '(@convention(block) () -> Void) -> Void'}}
|
// expected-error@-1 {{cannot convert value of type '(@convention(thin) () -> Void) -> Void' to specified type '(@convention(block) () -> Void) -> Void'}}
|
||||||
|
|
||||||
let _ : (@convention(c) () -> Void) -> Void = thin.function
|
let _ : (@convention(c) () -> Void) -> Void = thin.function // OK
|
||||||
// expected-error@-1 {{cannot convert value of type '(@convention(thin) () -> Void) -> Void' to specified type '(@convention(c) () -> Void) -> Void'}}
|
|
||||||
|
|
||||||
let _ : (@convention(thin) () -> Void) -> Void = thin.function // OK
|
let _ : (@convention(thin) () -> Void) -> Void = thin.function // OK
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user