[CSSimplify] Thin to thin is also allowed

This commit is contained in:
Luciano Almeida
2020-06-05 06:11:01 -03:00
parent baccbde0d1
commit d6bf34e65c
2 changed files with 12 additions and 5 deletions

View File

@@ -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 ||

View File

@@ -42,9 +42,8 @@ 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