Skip to content

Commit 84f8dea

Browse files
committed
[Sema] Create reference to id reprs for type resolution
1 parent e29b10f commit 84f8dea

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,6 +3822,24 @@ TypeResolver::resolveIdentifierType(IdentTypeRepr *IdType,
38223822
return ErrorType::get(getASTContext());
38233823
}
38243824

3825+
auto *dc = getDeclContext();
3826+
auto &ctx = getASTContext();
3827+
3828+
if ( ctx.LangOpts.hasFeature(Feature::ImplicitSome)){
3829+
// Check whether any of the generic parameters in the context represents
3830+
// this opaque type. If so, return that generic parameter.
3831+
if (auto declDC = dc->getAsDecl()) {
3832+
if (auto genericContext = declDC->getAsGenericContext()) {
3833+
if (auto genericParams = genericContext->getGenericParams()) {
3834+
for (auto genericParam : *genericParams) {
3835+
if (genericParam->getOpaqueTypeRepr() == IdType)
3836+
return genericParam->getDeclaredInterfaceType();
3837+
}
3838+
}
3839+
}
3840+
}
3841+
}
3842+
38253843
if (result->isConstraintType() &&
38263844
options.isConstraintImplicitExistential()) {
38273845
return ExistentialType::get(result);

0 commit comments

Comments
 (0)