@@ -6426,51 +6426,6 @@ static void addMoveOnlyAttrIf(SourceLoc const &parsedTildeCopyable,
64266426 attrs.add (new (Context) MoveOnlyAttr (/* IsImplicit=*/ true ));
64276427}
64286428
6429- bool Parser::parseLegacyTildeCopyable (SourceLoc *parseTildeCopyable,
6430- ParserStatus &Status,
6431- SourceLoc &TildeCopyableLoc) {
6432- // Is suppression permitted?
6433- if (parseTildeCopyable) {
6434- // Try to find '~' 'Copyable'
6435- //
6436- // We do this knowing that Copyable is not a real type as of now, so we
6437- // can't rely on parseType.
6438- if (Tok.isTilde ()) {
6439- const auto &nextTok = peekToken (); // lookahead
6440- if (isIdentifier (nextTok, Context.Id_Copyable .str ())) {
6441- auto tildeLoc = consumeToken ();
6442- consumeToken (); // the 'Copyable' token
6443-
6444- if (TildeCopyableLoc)
6445- diagnose (tildeLoc, diag::already_suppressed, Context.Id_Copyable );
6446- else
6447- TildeCopyableLoc = tildeLoc;
6448-
6449- return true ;
6450- } else if (nextTok.is (tok::code_complete)) {
6451- consumeToken (); // consume '~'
6452- Status.setHasCodeCompletionAndIsError ();
6453- if (CodeCompletionCallbacks) {
6454- CodeCompletionCallbacks->completeWithoutConstraintType ();
6455- }
6456- consumeToken (tok::code_complete);
6457- }
6458-
6459- // can't suppress whatever is between '~' and ',' or '{'.
6460- diagnose (Tok, diag::only_suppress_copyable);
6461- consumeToken ();
6462- }
6463-
6464- } else if (Tok.isTilde ()) {
6465- // a suppression isn't allowed here, so emit an error eat the token to
6466- // prevent further parsing errors.
6467- diagnose (Tok, diag::cannot_suppress_here);
6468- consumeToken ();
6469- }
6470-
6471- return false ;
6472- }
6473-
64746429// / Parse an inheritance clause.
64756430// /
64766431// / \verbatim
@@ -6546,11 +6501,47 @@ ParserStatus Parser::parseInheritance(
65466501 continue ;
65476502 }
65486503
6549- if (!EnabledNoncopyableGenerics) {
6550- if (parseLegacyTildeCopyable (parseTildeCopyable,
6551- Status,
6552- TildeCopyableLoc))
6553- continue ;
6504+ if (!EnabledNoncopyableGenerics && Tok.isTilde ()) {
6505+ ErrorTypeRepr *error = nullptr ;
6506+ if (parseTildeCopyable) {
6507+ const auto &nextTok = peekToken (); // lookahead
6508+ if (isIdentifier (nextTok, Context.Id_Copyable .str ())) {
6509+ auto tildeLoc = consumeToken ();
6510+ consumeToken (); // the 'Copyable' token
6511+
6512+ if (TildeCopyableLoc)
6513+ Inherited.push_back (InheritedEntry (
6514+ ErrorTypeRepr::create (Context, tildeLoc,
6515+ diag::already_suppressed_copyable)));
6516+ else
6517+ TildeCopyableLoc = tildeLoc;
6518+
6519+ continue ; // success
6520+ }
6521+
6522+ if (nextTok.is (tok::code_complete)) {
6523+ consumeToken (); // consume '~'
6524+ Status.setHasCodeCompletionAndIsError ();
6525+ if (CodeCompletionCallbacks) {
6526+ CodeCompletionCallbacks->completeWithoutConstraintType ();
6527+ }
6528+ consumeToken (tok::code_complete);
6529+ }
6530+
6531+ // can't suppress whatever is between '~' and ',' or '{'.
6532+ error = ErrorTypeRepr::create (Context, consumeToken (),
6533+ diag::only_suppress_copyable);
6534+ } else {
6535+ // Otherwise, a suppression isn't allowed here unless noncopyable
6536+ // generics is enabled, so record a delayed error diagnostic and
6537+ // eat the token to prevent further parsing errors.
6538+ error = ErrorTypeRepr::create (Context, consumeToken (),
6539+ diag::cannot_suppress_here);
6540+ }
6541+
6542+ // Record the error parsing ~Copyable, but continue on to parseType.
6543+ if (error)
6544+ Inherited.push_back (InheritedEntry (error));
65546545 }
65556546
65566547 auto ParsedTypeResult = parseType ();
@@ -9665,7 +9656,7 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc,
96659656
96669657 if (ElementTy.isNull ()) {
96679658 // Always set an element type.
9668- ElementTy = makeParserResult (ElementTy, new (Context) ErrorTypeRepr ( ));
9659+ ElementTy = makeParserResult (ElementTy, ErrorTypeRepr::create (Context ));
96699660 }
96709661 }
96719662
0 commit comments