|
Lines 1177-1182
Link Here
|
| 1177 |
length); |
1177 |
length); |
| 1178 |
} |
1178 |
} |
| 1179 |
alloc.type = getTypeReference(0); |
1179 |
alloc.type = getTypeReference(0); |
|
|
1180 |
if (this.options.sourceLevel >= ClassFileConstants.JDK1_7) { |
| 1181 |
checkForDiamond(alloc.type); |
| 1182 |
} |
| 1180 |
|
1183 |
|
| 1181 |
//the default constructor with the correct number of argument |
1184 |
//the default constructor with the correct number of argument |
| 1182 |
//will be created and added by the TC (see createsInternalConstructorWithBinding) |
1185 |
//will be created and added by the TC (see createsInternalConstructorWithBinding) |
|
Lines 1197-1202
Link Here
|
| 1197 |
this.astLengthPtr--; |
1200 |
this.astLengthPtr--; |
| 1198 |
} |
1201 |
} |
| 1199 |
} |
1202 |
} |
|
|
1203 |
private void checkForDiamond(TypeReference allocType) { |
| 1204 |
if (allocType instanceof ParameterizedSingleTypeReference) { |
| 1205 |
ParameterizedSingleTypeReference type = (ParameterizedSingleTypeReference) allocType; |
| 1206 |
if (type.typeArguments == TypeReference.NO_TYPE_ARGUMENTS) { |
| 1207 |
type.bits |= ASTNode.IsDiamond; |
| 1208 |
} |
| 1209 |
} |
| 1210 |
else if (allocType instanceof ParameterizedQualifiedTypeReference) { |
| 1211 |
ParameterizedQualifiedTypeReference type = (ParameterizedQualifiedTypeReference) allocType; |
| 1212 |
if (type.typeArguments[type.typeArguments.length - 1] == TypeReference.NO_TYPE_ARGUMENTS) { // Don't care for X<>.Y<> and X<>.Y<String> |
| 1213 |
type.bits |= ASTNode.IsDiamond; |
| 1214 |
} |
| 1215 |
} |
| 1216 |
} |
| 1200 |
protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim) { |
1217 |
protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim) { |
| 1201 |
int nameSize = this.identifierLengthStack[this.identifierLengthPtr]; |
1218 |
int nameSize = this.identifierLengthStack[this.identifierLengthPtr]; |
| 1202 |
int tokensSize = nameSize; |
1219 |
int tokensSize = nameSize; |
|
Lines 2440-2446
Link Here
|
| 2440 |
length); |
2457 |
length); |
| 2441 |
} |
2458 |
} |
| 2442 |
alloc.type = getTypeReference(0); |
2459 |
alloc.type = getTypeReference(0); |
| 2443 |
|
2460 |
if (this.options.sourceLevel >= ClassFileConstants.JDK1_7) { |
|
|
2461 |
checkForDiamond(alloc.type); |
| 2462 |
} |
| 2444 |
length = this.genericsLengthStack[this.genericsLengthPtr--]; |
2463 |
length = this.genericsLengthStack[this.genericsLengthPtr--]; |
| 2445 |
this.genericsPtr -= length; |
2464 |
this.genericsPtr -= length; |
| 2446 |
System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length); |
2465 |
System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length); |
|
Lines 2504-2509
Link Here
|
| 2504 |
length); |
2523 |
length); |
| 2505 |
} |
2524 |
} |
| 2506 |
alloc.type = getTypeReference(0); |
2525 |
alloc.type = getTypeReference(0); |
|
|
2526 |
if (this.options.sourceLevel >= ClassFileConstants.JDK1_7) { |
| 2527 |
checkForDiamond(alloc.type); |
| 2528 |
} |
| 2507 |
|
2529 |
|
| 2508 |
length = this.genericsLengthStack[this.genericsLengthPtr--]; |
2530 |
length = this.genericsLengthStack[this.genericsLengthPtr--]; |
| 2509 |
this.genericsPtr -= length; |
2531 |
this.genericsPtr -= length; |
|
Lines 3956-3961
Link Here
|
| 3956 |
// zero type arguments == <> |
3978 |
// zero type arguments == <> |
| 3957 |
pushOnGenericsLengthStack(-1); |
3979 |
pushOnGenericsLengthStack(-1); |
| 3958 |
concatGenericsLists(); |
3980 |
concatGenericsLists(); |
|
|
3981 |
this.intPtr--; // pop the null dimension pushed in by consumeReferenceType, as we have no type between <>, getTypeReference won't kick in |
| 3959 |
} |
3982 |
} |
| 3960 |
protected void consumeImportDeclaration() { |
3983 |
protected void consumeImportDeclaration() { |
| 3961 |
// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';' |
3984 |
// SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';' |
|
Lines 8900-8907
Link Here
|
| 8900 |
if (identifierLength == 1 && numberOfIdentifiers == 1) { |
8923 |
if (identifierLength == 1 && numberOfIdentifiers == 1) { |
| 8901 |
int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--]; |
8924 |
int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--]; |
| 8902 |
TypeReference[] typeArguments = null; |
8925 |
TypeReference[] typeArguments = null; |
| 8903 |
boolean isDiamond = currentTypeArgumentsLength < 0; |
8926 |
if (currentTypeArgumentsLength < 0) { |
| 8904 |
if (isDiamond) { |
|
|
| 8905 |
typeArguments = TypeReference.NO_TYPE_ARGUMENTS; |
8927 |
typeArguments = TypeReference.NO_TYPE_ARGUMENTS; |
| 8906 |
} else { |
8928 |
} else { |
| 8907 |
typeArguments = new TypeReference[currentTypeArgumentsLength]; |
8929 |
typeArguments = new TypeReference[currentTypeArgumentsLength]; |
|
Lines 8912-8920
Link Here
|
| 8912 |
if (dim != 0) { |
8934 |
if (dim != 0) { |
| 8913 |
parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition; |
8935 |
parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition; |
| 8914 |
} |
8936 |
} |
| 8915 |
if (isDiamond) { |
8937 |
/* We used to eagerly mark the PSTR as constituting diamond usage if we encountered <>, but that is too eager and |
| 8916 |
parameterizedSingleTypeReference.bits |= ASTNode.IsDiamond; |
8938 |
complicates error handling by making it hard to distinguish legitimate use cases from ill formed ones. We are |
| 8917 |
} |
8939 |
more discriminating now and tag a type as being diamond only where <> can legally occur. |
|
|
8940 |
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=339478#c11 |
| 8941 |
*/ |
| 8918 |
return parameterizedSingleTypeReference; |
8942 |
return parameterizedSingleTypeReference; |
| 8919 |
} else { |
8943 |
} else { |
| 8920 |
TypeReference[][] typeArguments = new TypeReference[numberOfIdentifiers][]; |
8944 |
TypeReference[][] typeArguments = new TypeReference[numberOfIdentifiers][]; |
|
Lines 8922-8928
Link Here
|
| 8922 |
long[] positions = new long[numberOfIdentifiers]; |
8946 |
long[] positions = new long[numberOfIdentifiers]; |
| 8923 |
int index = numberOfIdentifiers; |
8947 |
int index = numberOfIdentifiers; |
| 8924 |
int currentIdentifiersLength = identifierLength; |
8948 |
int currentIdentifiersLength = identifierLength; |
| 8925 |
boolean isDiamond = false; |
|
|
| 8926 |
while (index > 0) { |
8949 |
while (index > 0) { |
| 8927 |
int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--]; |
8950 |
int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--]; |
| 8928 |
if (currentTypeArgumentsLength > 0) { |
8951 |
if (currentTypeArgumentsLength > 0) { |
|
Lines 8931-8937
Link Here
|
| 8931 |
} else if (currentTypeArgumentsLength < 0) { |
8954 |
} else if (currentTypeArgumentsLength < 0) { |
| 8932 |
// diamond case for qualified type reference (java.util.ArrayList<>) |
8955 |
// diamond case for qualified type reference (java.util.ArrayList<>) |
| 8933 |
typeArguments[index - 1] = TypeReference.NO_TYPE_ARGUMENTS; |
8956 |
typeArguments[index - 1] = TypeReference.NO_TYPE_ARGUMENTS; |
| 8934 |
isDiamond = true; |
|
|
| 8935 |
} |
8957 |
} |
| 8936 |
switch(currentIdentifiersLength) { |
8958 |
switch(currentIdentifiersLength) { |
| 8937 |
case 1 : |
8959 |
case 1 : |
|
Lines 8954-8962
Link Here
|
| 8954 |
if (dim != 0) { |
8976 |
if (dim != 0) { |
| 8955 |
parameterizedQualifiedTypeReference.sourceEnd = this.endStatementPosition; |
8977 |
parameterizedQualifiedTypeReference.sourceEnd = this.endStatementPosition; |
| 8956 |
} |
8978 |
} |
| 8957 |
if (isDiamond) { |
8979 |
/* We used to eagerly mark the PQTR as constituting diamond usage if we encountered <>, but that is too eager and |
| 8958 |
parameterizedQualifiedTypeReference.bits |= ASTNode.IsDiamond; |
8980 |
complicates error handling by making it hard to distinguish legitimate use cases from ill formed ones. We are |
| 8959 |
} |
8981 |
more discriminating now and tag a type as being diamond only where <> can legally occur. |
|
|
8982 |
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=339478#c11 |
| 8983 |
*/ |
| 8960 |
return parameterizedQualifiedTypeReference; |
8984 |
return parameterizedQualifiedTypeReference; |
| 8961 |
} |
8985 |
} |
| 8962 |
} |
8986 |
} |