1373 } |
1373 } |
1374 JCExpression t = qualident(); |
1374 JCExpression t = qualident(); |
1375 int oldmode = mode; |
1375 int oldmode = mode; |
1376 mode = TYPE; |
1376 mode = TYPE; |
1377 boolean diamondFound = false; |
1377 boolean diamondFound = false; |
|
1378 int lastTypeargsPos = -1; |
1378 if (S.token() == LT) { |
1379 if (S.token() == LT) { |
1379 checkGenerics(); |
1380 checkGenerics(); |
|
1381 lastTypeargsPos = S.pos(); |
1380 t = typeArguments(t, true); |
1382 t = typeArguments(t, true); |
1381 diamondFound = (mode & DIAMOND) != 0; |
1383 diamondFound = (mode & DIAMOND) != 0; |
1382 } |
1384 } |
1383 while (S.token() == DOT) { |
1385 while (S.token() == DOT) { |
1384 if (diamondFound) { |
1386 if (diamondFound) { |
1387 } |
1389 } |
1388 int pos = S.pos(); |
1390 int pos = S.pos(); |
1389 S.nextToken(); |
1391 S.nextToken(); |
1390 t = toP(F.at(pos).Select(t, ident())); |
1392 t = toP(F.at(pos).Select(t, ident())); |
1391 if (S.token() == LT) { |
1393 if (S.token() == LT) { |
|
1394 lastTypeargsPos = S.pos(); |
1392 checkGenerics(); |
1395 checkGenerics(); |
1393 t = typeArguments(t, true); |
1396 t = typeArguments(t, true); |
1394 diamondFound = (mode & DIAMOND) != 0; |
1397 diamondFound = (mode & DIAMOND) != 0; |
1395 } |
1398 } |
1396 } |
1399 } |
1397 mode = oldmode; |
1400 mode = oldmode; |
1398 if (S.token() == LBRACKET) { |
1401 if (S.token() == LBRACKET) { |
1399 JCExpression e = arrayCreatorRest(newpos, t); |
1402 JCExpression e = arrayCreatorRest(newpos, t); |
1400 if (typeArgs != null) { |
1403 if (diamondFound) { |
|
1404 reportSyntaxError(lastTypeargsPos, "cannot.create.array.with.diamond"); |
|
1405 return toP(F.at(newpos).Erroneous(List.of(e))); |
|
1406 } |
|
1407 else if (typeArgs != null) { |
1401 int pos = newpos; |
1408 int pos = newpos; |
1402 if (!typeArgs.isEmpty() && typeArgs.head.pos != Position.NOPOS) { |
1409 if (!typeArgs.isEmpty() && typeArgs.head.pos != Position.NOPOS) { |
1403 // note: this should always happen but we should |
1410 // note: this should always happen but we should |
1404 // not rely on this as the parser is continuously |
1411 // not rely on this as the parser is continuously |
1405 // modified to improve error recovery. |
1412 // modified to improve error recovery. |