Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AST, Sema] Replace HoleType with PlaceholderType #35589

Merged
merged 14 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Disable PlaceholderType parsing
  • Loading branch information
Jumhyn committed Feb 17, 2021
commit 1819d33f57d8245d33a820e76bd6e53d037d18be
7 changes: 0 additions & 7 deletions lib/Parse/ParseType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ LayoutConstraint Parser::parseLayoutConstraint(Identifier LayoutConstraintID) {
/// type-simple '!'
/// type-collection
/// type-array
/// '_'
ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID) {
ParserResult<TypeRepr> ty;

Expand Down Expand Up @@ -183,9 +182,6 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID) {
ty = parseTypeCollection();
break;
}
case tok::kw__:
ty = makeParserResult(new (Context) PlaceholderTypeRepr(consumeToken()));
break;
case tok::kw_protocol:
if (startsWithLess(peekToken())) {
ty = parseOldStyleProtocolComposition();
Expand Down Expand Up @@ -1443,9 +1439,6 @@ bool Parser::canParseType() {
if (!consumeIf(tok::r_square))
return false;
break;
case tok::kw__:
consumeToken();
break;


default:
Expand Down
10 changes: 2 additions & 8 deletions lib/Sema/PreCheckExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,12 +1476,8 @@ TypeExpr *PreCheckExpression::simplifyTypeExpr(Expr *E) {
return simplifyNestedTypeExpr(UDE);
}

// Fold '_' into a placeholder type.
if (auto *DAE = dyn_cast<DiscardAssignmentExpr>(E)) {
auto *placeholderRepr =
new (getASTContext()) PlaceholderTypeRepr(DAE->getLoc());
return new (getASTContext()) TypeExpr(placeholderRepr);
}
// TODO: Fold DiscardAssignmentExpr into a placeholder type here once parsing
// them is supported.

// Fold T? into an optional type when T is a TypeExpr.
if (isa<OptionalEvaluationExpr>(E) || isa<BindOptionalExpr>(E)) {
Expand Down Expand Up @@ -1688,8 +1684,6 @@ TypeExpr *PreCheckExpression::simplifyTypeExpr(Expr *E) {
return nullptr;
if (auto *TyE = dyn_cast<TypeExpr>(E))
return TyE->getTypeRepr();
if (auto *DAE = dyn_cast<DiscardAssignmentExpr>(E))
return new (getASTContext()) PlaceholderTypeRepr(DAE->getLoc());
if (auto *TE = dyn_cast<TupleExpr>(E))
if (TE->getNumElements() == 0)
return TupleTypeRepr::createEmpty(ctx, TE->getSourceRange());
Expand Down
2 changes: 2 additions & 0 deletions lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
if (!options.is(TypeResolverContext::TypeAliasDecl)) {
// If the resolution object carries an opener, attempt to open
// the unbound generic type.
// TODO: We should be able to just open the generic arguments as N
// different PlaceholderTypes.
if (const auto openerFn = resolution.getUnboundTypeOpener())
if (const auto boundTy = openerFn(unboundTy))
return boundTy;
Expand Down