public Object evaluate ( ) { if ( ! isCompileTimeConstant ( ) ) { return super . evaluate ( ) ; } Object value = getLHS ( ) . evaluate ( ) ; IType argType = getType ( ) ; if ( value instanceof IType && argType instanceof IJavaType && JavaTypes . CLASS ( ) == TypeLord . getPureGenericType ( argType ) ) { // Don't force class loading during compilation return value ; } //============================================================================ // Special Types // TODO cgross: remove these special cases (came from ParsedElement#convertValue) // and allow the coercion manager to handle these cases //============================================================================ if ( argType == GosuParserTypes . NUMBER_TYPE ( ) ) { return CommonServices . getCoercionManager ( ) . makeDoubleFrom ( value ) ; } else if ( argType == GosuParserTypes . STRING_TYPE ( ) ) { return CommonServices . getCoercionManager ( ) . makeStringFrom ( value ) ; } else if ( argType == GosuParserTypes . DATETIME_TYPE ( ) ) { Date date = CommonServices . getCoercionManager ( ) . makeDateFrom ( value ) ; if ( date != null ) { return date ; } } //============================================================================ // This is really all we should be doing //============================================================================ if ( _coercer != null && ( value != null || _coercer . handlesNull ( ) ) ) { return _coercer . coerceValue ( argType , value ) ; } return value ; }
Perform a type cast .