JCExpression cast ( JCExpression tree , Type target ) { int oldpos = make . pos ; make . at ( tree . pos ) ; if ( ! types . isSameType ( tree . type , target ) ) { if ( ! resolve . isAccessible ( env , target . tsym ) ) resolve . logAccessErrorInternal ( env , tree , target ) ; tree = make . TypeCast ( make . Type ( target ) , tree ) . setType ( target ) ; } make . pos = oldpos ; return tree ; }
Construct an attributed tree for a cast of expression to target type unless it already has precisely that type .