Permalink
Browse files

Always parsing tuples as errors.

  • Loading branch information...
1 parent 1236327 commit 84bc74894a5cebd373d3404e4a7d42a9ae054610 Evgeny Gerashchenko committed Mar 19, 2013
@@ -1608,7 +1608,7 @@ private void parseParenthesizedExpression() {
* : "#" "(" (((SimpleName "=")? expression){","})? ")"
* ;
*/
- @Deprecated // Tuples are to be removed in Kotlin M4
+ @Deprecated // Tuples are dropped, but parsing is left to minimize surprising. This code should be removed some time (in Kotlin 1.0?)
private void parseTupleExpression() {
assert _at(HASH);
PsiBuilder.Marker mark = mark();
@@ -1619,15 +1619,13 @@ private void parseTupleExpression() {
if (!at(RPAR)) {
while (true) {
while (at(COMMA)) {
- errorAndAdvance("Expecting a tuple entry (element)");
+ advance();
}
if (at(IDENTIFIER) && lookahead(1) == EQ) {
- PsiBuilder.Marker entry = mark();
advance(); // IDENTIFIER
advance(); // EQ
parseExpression();
- entry.done(LABELED_TUPLE_ENTRY);
}
else {
parseExpression();
@@ -1637,16 +1635,15 @@ private void parseTupleExpression() {
advance(); // COMMA
if (at(RPAR)) {
- error("Expecting a tuple entry (element)");
break;
}
}
}
- expect(RPAR, "Expecting ')'");
+ consumeIf(RPAR);
myBuilder.restoreNewlinesState();
- mark.done(TUPLE);
+ mark.error("Tuples are not supported. Use data classes instead.");
}
/*
@@ -1564,15 +1564,15 @@ private void parseModifierListWithShortAnnotations(JetNodeType modifierList, Tok
* : "#" "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility
* ;
*/
- @Deprecated // Tuples are to be removed in Kotlin M4
+ @Deprecated // Tuples are dropped, but parsing is left to minimize surprising. This code should be removed some time (in Kotlin 1.0?)
private void parseTupleType() {
assert _at(HASH);
PsiBuilder.Marker tuple = mark();
myBuilder.disableNewlines();
advance(); // HASH
- expect(LPAR, "Expecting a tuple type in the form of '#(...)");
+ consumeIf(LPAR);
if (!at(RPAR)) {
while (true) {
@@ -1581,11 +1581,9 @@ private void parseTupleType() {
}
if (at(IDENTIFIER) && lookahead(1) == COLON) {
- PsiBuilder.Marker labeledEntry = mark();
advance(); // IDENTIFIER
advance(); // COLON
parseTypeRef();
- labeledEntry.done(LABELED_TUPLE_TYPE_ENTRY);
}
else if (TYPE_REF_FIRST.contains(tt())) {
parseTypeRef();
@@ -1599,10 +1597,10 @@ else if (TYPE_REF_FIRST.contains(tt())) {
}
}
- expect(RPAR, "Expecting ')");
+ consumeIf(RPAR);
myBuilder.restoreNewlinesState();
- tuple.done(TUPLE_TYPE);
+ tuple.error("Tuples are not supported. Use data classes instead.");
}
/*
@@ -15,7 +15,7 @@ JetFile: ShebangIncorrect.ktscript
PsiElement(SEMICOLON)(';')
PsiWhiteSpace(' ')
BINARY_EXPRESSION
- TUPLE
+ PsiErrorElement:Tuples are not supported. Use data classes instead.
PsiElement(HASH)('#')
PsiElement(EXCL)('!')
PsiErrorElement:Expecting an expression
@@ -26,7 +26,7 @@ JetFile: ShebangIncorrect.ktscript
PsiElement(IDENTIFIER)('usr')
PsiWhiteSpace('\n\n')
BINARY_EXPRESSION
- TUPLE
+ PsiErrorElement:Tuples are not supported. Use data classes instead.
PsiElement(HASH)('#')
PsiElement(EXCL)('!')
PsiErrorElement:Expecting an expression

0 comments on commit 84bc748

Please sign in to comment.