Skip to content

Commit a1e31c0

Browse files
committed
[Sema] Make explicit that resolveInverseType doesn't look through parens
Check for `isParenType` on the TypeRepr to avoid relying on getting that behavior by casting the type pointer.
1 parent 0b783a8 commit a1e31c0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5898,14 +5898,17 @@ NeverNullType TypeResolver::resolveInverseType(InverseTypeRepr *repr,
58985898
TypeResolutionOptions options) {
58995899
auto subOptions = options.withoutContext(true)
59005900
.withContext(TypeResolverContext::Inverted);
5901-
auto ty = resolveType(repr->getConstraint(), subOptions);
5901+
auto *constraintRepr = repr->getConstraint();
5902+
auto ty = resolveType(constraintRepr, subOptions);
59025903
if (ty->hasError())
59035904
return ErrorType::get(getASTContext());
59045905

59055906
// If the inverted type is an existential metatype, unwrap the existential
59065907
// metatype so we can look at the instance type. We'll re-wrap at the end.
5907-
ExistentialMetatypeType *existentialTy =
5908-
dyn_cast<ExistentialMetatypeType>(ty.get().getPointer());
5908+
// Note we don't look through parens.
5909+
ExistentialMetatypeType *existentialTy = nullptr;
5910+
if (!constraintRepr->isParenType())
5911+
existentialTy = dyn_cast<ExistentialMetatypeType>(ty.get().getPointer());
59095912
if (existentialTy) {
59105913
ty = existentialTy->getInstanceType();
59115914
}

0 commit comments

Comments
 (0)