[Parse] Allow named opaque types in more places

- Allow named opaque types in typed patterns and subscripts
- Fix inheritance clause printing for `GenericParamList`
- clang-format changes from previous commit on this branch
This commit is contained in:
Benjamin Driscoll
2021-06-24 10:59:28 -04:00
parent dddf0eceb0
commit deb0457032
12 changed files with 164 additions and 153 deletions

View File

@@ -824,7 +824,7 @@ Parser::parseFunctionArguments(SmallVectorImpl<Identifier> &NamePieces,
/// func-signature:
/// func-arguments ('async'|'reasync')? func-throws? func-signature-result?
/// func-signature-result:
/// '->' generic-params? type
/// '->' type
///
/// Note that this leaves retType as null if unspecified.
ParserStatus
@@ -865,22 +865,10 @@ Parser::parseFunctionSignature(Identifier SimpleName,
arrowLoc = consumeToken(tok::colon);
}
// Check for effect specifiers after the arrow, but before the generic
// parameters, and correct it.
// Check for effect specifiers after the arrow, but before the return type,
// and correct it.
parseEffectsSpecifiers(arrowLoc, asyncLoc, &reasync, throwsLoc, &rethrows);
GenericParamList *genericParams = nullptr;
if (Context.LangOpts.EnableExperimentalOpaqueReturnTypes) {
auto genericParamsResult = maybeParseGenericParams();
genericParams = genericParamsResult.getPtrOrNull();
Status |= genericParamsResult;
// Check for effect specifiers after the generic parameters, but before
// the return type, and correct it.
parseEffectsSpecifiers(arrowLoc, asyncLoc, &reasync, throwsLoc,
&rethrows);
}
ParserResult<TypeRepr> ResultType =
parseDeclResultType(diag::expected_type_function_result);
retType = ResultType.getPtrOrNull();
@@ -888,11 +876,6 @@ Parser::parseFunctionSignature(Identifier SimpleName,
if (Status.isErrorOrHasCompletion())
return Status;
if (genericParams != nullptr) {
retType = new (Context)
NamedOpaqueReturnTypeRepr(retType, genericParams);
}
// Check for effect specifiers after the type and correct it.
parseEffectsSpecifiers(arrowLoc, asyncLoc, &reasync, throwsLoc, &rethrows);
} else {