From aedf854e33e4d660af7b6547b8f5ba0ddea1d549 Mon Sep 17 00:00:00 2001 From: Freddy Kellison-Linn Date: Sat, 3 Feb 2024 13:41:22 -0500 Subject: [PATCH] Follow ups for keypath function conversion PR --- include/swift/AST/DiagnosticsSema.def | 4 ++-- lib/Sema/CSSimplify.cpp | 4 ++-- test/Constraints/keypath.swift | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index d8209bc3592d4..c0c6f0b291766 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -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", diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 7c500c79a29e2..50c807dfd02a6 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -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); diff --git a/test/Constraints/keypath.swift b/test/Constraints/keypath.swift index 76f78dfeffb54..7b90c7d24a7b0 100644 --- a/test/Constraints/keypath.swift +++ b/test/Constraints/keypath.swift @@ -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