Skip to content

Commit 22bbb01

Browse files
committed
[AST] Preserve type constraint for identifier type
Type contraints need to be passed when creating generic parameters from identifier types.
1 parent 84f8dea commit 22bbb01

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/AST/NameLookup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,6 +2895,11 @@ createOpaqueParameterGenericParams(Evaluator &evaluator,GenericContext *genericC
28952895
{ TypeLoc(opaque->getConstraint()) }
28962896
};
28972897
gp->setInherited(ctx.AllocateCopy(inherited));
2898+
} else {
2899+
InheritedEntry inherited[1] = {
2900+
{ TypeLoc(repr) }
2901+
};
2902+
gp->setInherited(ctx.AllocateCopy(inherited));
28982903
}
28992904
implicitGenericParams.push_back(gp);
29002905
}

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3825,7 +3825,7 @@ TypeResolver::resolveIdentifierType(IdentTypeRepr *IdType,
38253825
auto *dc = getDeclContext();
38263826
auto &ctx = getASTContext();
38273827

3828-
if ( ctx.LangOpts.hasFeature(Feature::ImplicitSome)){
3828+
if ( ctx.LangOpts.hasFeature(Feature::ImplicitSome) & !options.is(TypeResolverContext::Inherited) ){
38293829
// Check whether any of the generic parameters in the context represents
38303830
// this opaque type. If so, return that generic parameter.
38313831
if (auto declDC = dc->getAsDecl()) {

0 commit comments

Comments
 (0)