From f205f469a983de289fbfd6750234241d25e37cb9 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Wed, 5 Nov 2025 20:29:15 +0000 Subject: [PATCH] [CS] Replace error type with hole for projected value Missed this in my previous patch, make sure we replace an error with a hole if necessary. --- lib/Sema/CSSyntacticElement.cpp | 5 +++++ .../ConstraintSystem-applySolution-bbfc02.swift | 11 +++++++++++ .../ConstraintSystem-applySolution-082642.swift | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 validation-test/IDE/crashers_fixed/ConstraintSystem-applySolution-bbfc02.swift create mode 100644 validation-test/compiler_crashers_fixed/ConstraintSystem-applySolution-082642.swift diff --git a/lib/Sema/CSSyntacticElement.cpp b/lib/Sema/CSSyntacticElement.cpp index bc2b064ca07ee..e90859f7805ba 100644 --- a/lib/Sema/CSSyntacticElement.cpp +++ b/lib/Sema/CSSyntacticElement.cpp @@ -801,6 +801,11 @@ class SyntacticElementConstraintGenerator auto wrapperTy = cs.simplifyType(cs.getType(wrapperTypeExpr)); if (auto *projectedVal = wrappedVar->getPropertyWrapperProjectionVar()) { auto projectedTy = computeProjectedValueType(wrappedVar, wrapperTy); + // The projected type may have an error, make sure we turn it into a hole + // if necessary. + ASSERT(!projectedTy->hasUnboundGenericType() && + !projectedTy->hasPlaceholder()); + projectedTy = cs.replaceInferableTypesWithTypeVars(projectedTy, locator); cs.setType(projectedVal, projectedTy); } if (auto *backing = wrappedVar->getPropertyWrapperBackingProperty()) diff --git a/validation-test/IDE/crashers_fixed/ConstraintSystem-applySolution-bbfc02.swift b/validation-test/IDE/crashers_fixed/ConstraintSystem-applySolution-bbfc02.swift new file mode 100644 index 0000000000000..5bec87c9dee3c --- /dev/null +++ b/validation-test/IDE/crashers_fixed/ConstraintSystem-applySolution-bbfc02.swift @@ -0,0 +1,11 @@ +// {"kind":"complete","original":"3da7ab26","signature":"swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget)","signatureAssert":"Assertion failed: (isValidType(solution.simplifyType(type)) && \"node type has invalid type\"), function applySolution"} +// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s +@propertyWrapper struct a { + init(wrappedValue: b) +projectedValue: + var wrappedValue: b +} +{ + @a var c = false +}