Skip to content

Commit 17f32ca

Browse files
authored
Merge pull request #69642 from xedin/rdar-117871338
[CSSimplify] Fix handling of holes by OptionalObject constraint
2 parents 844b46f + 8b5e384 commit 17f32ca

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9184,8 +9184,8 @@ ConstraintSystem::simplifyOptionalObjectConstraint(
91849184
}
91859185

91869186
if (optTy->isPlaceholder()) {
9187-
if (auto *typeVar = second->getAs<TypeVariableType>())
9188-
recordPotentialHole(typeVar);
9187+
// object type should be simplified because it could be already bound.
9188+
recordAnyTypeVarAsPotentialHole(simplifyType(second));
91899189
return SolutionKind::Solved;
91909190
}
91919191

test/stmt/switch_stmt2.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,25 @@ func fallthrough_not_last(i: Int) {
150150
break
151151
}
152152
}
153+
154+
// rdar://117871338 - incorrect diagnostic - type of expression is ambiguous when member is missing.
155+
func test_invalid_optional_chaining() {
156+
func test(_: (E) -> Void) {
157+
}
158+
159+
enum E {
160+
case a
161+
case b
162+
}
163+
164+
struct S {
165+
var prop: E
166+
}
167+
168+
test {
169+
switch $0.prop? { // expected-error {{value of type 'E' has no member 'prop'}}
170+
case .a: break
171+
case .b: break
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)