PY-71002 PEP-696: Support new syntax for default types of Type Parameters in new-style declarations

- PEP-696 adds a new syntax for declaring the default types of Type Parameters in new-new style generic classes, functions and type alias statements. Support these grammar changes.
- Store info about default types in stubs for Type Parameters
- Increment the stub version counter in PyFileElementType

GitOrigin-RevId: b6b22e3eaa86ce06132885781e5775a89bf4b840
This commit is contained in:
Daniil Kalinin
2024-08-12 10:49:01 +02:00
committed by intellij-monorepo-bot
parent d73bf77d9a
commit 7751fceaed
30 changed files with 393 additions and 23 deletions

View File

@@ -1056,7 +1056,7 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper {
nextToken();
}
if (!parseIdentifierOrSkip(PyTokenTypes.RBRACKET, PyTokenTypes.COMMA, PyTokenTypes.COLON)) {
if (!parseIdentifierOrSkip(PyTokenTypes.RBRACKET, PyTokenTypes.COMMA, PyTokenTypes.COLON, PyTokenTypes.EQ)) {
typeParamMarker.drop();
return false;
}
@@ -1066,6 +1066,12 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper {
myBuilder.error(PyParsingBundle.message("PARSE.expected.expression"));
}
}
if (matchToken(PyTokenTypes.EQ)) {
if (!myContext.getExpressionParser().parseSingleExpression(false)) {
myBuilder.error(PyParsingBundle.message("PARSE.expected.expression"));
}
}
typeParamMarker.done(PyElementTypes.TYPE_PARAMETER);
return true;
}