Lower UDRE to TypeValue if it references a value generic

This commit is contained in:
Alejandro Alonso
2024-08-01 10:22:43 -07:00
parent 7eb93b877a
commit 0df42e9841
16 changed files with 112 additions and 82 deletions

View File

@@ -760,6 +760,13 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
}
auto *LookupDC = Lookup[0].getDeclContext();
bool makeTypeValue = false;
if (isa<GenericTypeParamDecl>(D) &&
cast<GenericTypeParamDecl>(D)->isValue()) {
makeTypeValue = true;
}
if (UDRE->isImplicit()) {
return TypeExpr::createImplicitForDecl(
UDRE->getNameLoc(), D, LookupDC,
@@ -770,7 +777,11 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
LookupDC ? LookupDC->mapTypeIntoContext(D->getInterfaceType())
: D->getInterfaceType());
} else {
return TypeExpr::createForDecl(UDRE->getNameLoc(), D, LookupDC);
if (makeTypeValue) {
return TypeValueExpr::createForDecl(UDRE->getNameLoc(), D, LookupDC);
} else {
return TypeExpr::createForDecl(UDRE->getNameLoc(), D, LookupDC);
}
}
};