Skip to content

Follow ups for keypath function conversion PR #71372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,10 @@ ERROR(expr_smart_keypath_application_type_mismatch,none,
"key path of type %0 cannot be applied to a base of type %1",
(Type, Type))
ERROR(expr_keypath_root_type_mismatch, none,
"key path root type %0 cannot be converted to contextual type %1",
"cannot convert key path root type %0 to contextual type %1",
(Type, Type))
ERROR(expr_keypath_type_mismatch, none,
"key path of type %0 cannot be converted to contextual type %1",
"cannot convert key path of type %0 to contextual type %1",
(Type, Type))
ERROR(expr_keypath_application_root_type_mismatch, none,
"key path with root type %0 cannot be applied to a base of type %1",
Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12286,8 +12286,8 @@ ConstraintSystem::simplifyKeyPathConstraint(
auto paramFnTy = FunctionType::get(paramParam, fnTy->getResult(),
fnTy->getExtInfo());

return matchTypes(kpFnTy, paramFnTy, ConstraintKind::Conversion, subflags,
locator).isSuccess();
return !matchTypes(kpFnTy, paramFnTy, ConstraintKind::Conversion,
subflags, locator).isFailure();
}

assert(contextualRootTy && contextualValueTy);
Expand Down
4 changes: 2 additions & 2 deletions test/Constraints/keypath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func testVariadicKeypathAsFunc() {

// These are not okay, the KeyPath should have a base that matches the
// internal parameter type of the function, i.e (S...).
let _: (S...) -> Int = \S.i // expected-error {{key path root type 'S' cannot be converted to contextual type 'S...'}}
takesVariadicFnWithGenericRet(\S.i) // expected-error {{key path root type 'S' cannot be converted to contextual type 'S...'}}
let _: (S...) -> Int = \S.i // expected-error {{cannot convert key path root type 'S' to contextual type 'S...'}}
takesVariadicFnWithGenericRet(\S.i) // expected-error {{cannot convert key path root type 'S' to contextual type 'S...'}}
}

// rdar://problem/54322807
Expand Down