Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] TypeReferences vs NameReferences in type cast expressions.

Hi Srikanth,

I've been wondering about the same bits before.

A look into the history shows that before 22/10/03 the grammar actually
had this rule (dead file java_1.5.g):

	-- Expression is here only in order to make the grammar LL1
	CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus
	/.$putCase consumeCastExpressionLL1(); $break ./

It could be that everything else is a left-over from those days?
Interestingly there are no changes in Parser.java that directly correspond
to the 22/10/03 commit of java_1.5.g.

Also related are these bits from CastExpression:

a comment in resolveType:

	// due to the fact an expression may start with ( and that a cast can also start with (
	// the field is an expression....it can be a TypeReference OR a NameReference Or
	// any kind of Expression <-- this last one is invalid.......

and the last branch

	} else { // expression as a cast
		TypeBinding expressionType = this.expression.resolveType(scope);
		if (expressionType == null) return null;
		scope.problemReporter().invalidTypeReference(this.type);
		return null;
	}

 
> I will make the change to TypeReference and see what breaks,

sounds like a good strategy. Alternatively one could just try hard
to trigger the above else branch.


If your observations are right, this could make the code simpler.

best,
Stephan


Back to the top