Skip to content

Commit f205f46

Browse files
committed
[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.
1 parent dad2637 commit f205f46

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lib/Sema/CSSyntacticElement.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,11 @@ class SyntacticElementConstraintGenerator
801801
auto wrapperTy = cs.simplifyType(cs.getType(wrapperTypeExpr));
802802
if (auto *projectedVal = wrappedVar->getPropertyWrapperProjectionVar()) {
803803
auto projectedTy = computeProjectedValueType(wrappedVar, wrapperTy);
804+
// The projected type may have an error, make sure we turn it into a hole
805+
// if necessary.
806+
ASSERT(!projectedTy->hasUnboundGenericType() &&
807+
!projectedTy->hasPlaceholder());
808+
projectedTy = cs.replaceInferableTypesWithTypeVars(projectedTy, locator);
804809
cs.setType(projectedVal, projectedTy);
805810
}
806811
if (auto *backing = wrappedVar->getPropertyWrapperBackingProperty())
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// {"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"}
2+
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
3+
@propertyWrapper struct a<b {
4+
init(wrappedValue: b)
5+
projectedValue:
6+
var wrappedValue: b
7+
}
8+
{
9+
@a var c = false
10+
switch c {
11+
#^^#
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// {"kind":"typecheck","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"}
2+
// RUN: not %target-swift-frontend -typecheck %s
3+
@propertyWrapper struct a<b > {
4+
init(wrappedValue: b)
5+
projectedValue:
6+
var wrappedValue: b
7+
}
8+
{
9+
@a var c = false
10+
}

0 commit comments

Comments
 (0)