@@ -175,12 +175,6 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(
175175 tildeLoc = consumeToken ();
176176 }
177177
178- // Eat any '-' preceding integer literals.
179- SourceLoc minusLoc;
180- if (Tok.isMinus () && peekToken ().is (tok::integer_literal)) {
181- minusLoc = consumeToken ();
182- }
183-
184178 switch (Tok.getKind ()) {
185179 case tok::kw_Self:
186180 case tok::identifier:
@@ -237,12 +231,6 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(
237231 }
238232 return makeParserCodeCompletionResult<TypeRepr>(
239233 ErrorTypeRepr::create (Context, consumeToken (tok::code_complete)));
240- case tok::integer_literal: {
241- auto text = copyAndStripUnderscores (Tok.getText ());
242- auto loc = consumeToken (tok::integer_literal);
243- ty = makeParserResult (new (Context) IntegerTypeRepr (text, loc, minusLoc));
244- break ;
245- }
246234 case tok::l_square: {
247235 ty = parseTypeCollection ();
248236 break ;
@@ -739,7 +727,8 @@ ParserStatus Parser::parseGenericArguments(SmallVectorImpl<TypeRepr *> &Args,
739727 // variadic generic types.
740728 if (!startsWithGreater (Tok)) {
741729 while (true ) {
742- ParserResult<TypeRepr> Ty = parseType (diag::expected_type);
730+ // Note: This can be a value type, e.g. 'Vector<3, Int>'.
731+ ParserResult<TypeRepr> Ty = parseTypeOrValue (diag::expected_type);
743732 if (Ty.isNull () || Ty.hasCodeCompletion ()) {
744733 // Skip until we hit the '>'.
745734 RAngleLoc = skipUntilGreaterInTypeList ();
@@ -1481,6 +1470,31 @@ Parser::parseTypeImplicitlyUnwrappedOptional(ParserResult<TypeRepr> base) {
14811470 return makeParserResult (ParserStatus (base), TyR);
14821471}
14831472
1473+ ParserResult<TypeRepr> Parser::parseTypeOrValue () {
1474+ return parseTypeOrValue (diag::expected_type);
1475+ }
1476+
1477+ ParserResult<TypeRepr> Parser::parseTypeOrValue (Diag<> MessageID,
1478+ ParseTypeReason reason,
1479+ bool fromASTGen) {
1480+ // Eat any '-' preceding integer literals.
1481+ SourceLoc minusLoc;
1482+ if (Tok.isMinus () && peekToken ().is (tok::integer_literal)) {
1483+ minusLoc = consumeToken ();
1484+ }
1485+
1486+ // Attempt to parse values first. Right now the only value that can be parsed
1487+ // as a type are integers.
1488+ if (Tok.is (tok::integer_literal)) {
1489+ auto text = copyAndStripUnderscores (Tok.getText ());
1490+ auto loc = consumeToken (tok::integer_literal);
1491+ return makeParserResult (new (Context) IntegerTypeRepr (text, loc, minusLoc));
1492+ }
1493+
1494+ // Otherwise, attempt to parse a regular type.
1495+ return parseType (MessageID, reason, fromASTGen);
1496+ }
1497+
14841498// ===----------------------------------------------------------------------===//
14851499// Speculative type list parsing
14861500// ===----------------------------------------------------------------------===//
0 commit comments