/** * @see * org.eclipse.che.ide.ext.java.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup.Scope, * org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup.TypeBinding, * org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup .TypeBinding) */ public void computeConversion( Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) { if (runtimeTimeType == null || compileTimeType == null) return; if ((this.bits & Binding.FIELD) != 0 && this.binding != null && this.binding.isValidBinding()) { // set the generic cast after the fact, once the type expectation is fully known (no need for // strict cast) FieldBinding field = (FieldBinding) this.binding; FieldBinding originalBinding = field.original(); TypeBinding originalType = originalBinding.type; // extra cast needed if field type is type variable if (originalType.leafComponentType().isTypeVariable()) { TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) ? compileTimeType // unboxing: checkcast before conversion : runtimeTimeType; this.genericCast = originalType.genericCast(scope.boxing(targetType)); if (this.genericCast instanceof ReferenceBinding) { ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast; if (!referenceCast.canBeSeenBy(scope)) { scope .problemReporter() .invalidType( this, new ProblemReferenceBinding( CharOperation.splitOn('.', referenceCast.shortReadableName()), referenceCast, ProblemReasons.NotVisible)); } } } } super.computeConversion(scope, runtimeTimeType, compileTimeType); }
protected TypeBinding getTypeBinding(Scope scope) { if (this.resolvedType != null) return this.resolvedType; this.resolvedType = scope.getType(this.token); if (scope.kind == Scope.CLASS_SCOPE && this.resolvedType.isValidBinding()) if (((ClassScope) scope).detectHierarchyCycle(this.resolvedType, this)) return null; return this.resolvedType; }
/** * @see * org.eclipse.che.ide.ext.java.jdt.internal.compiler.ast.Expression#postConversionType(Scope) */ public TypeBinding postConversionType(Scope scope) { TypeBinding convertedType = this.resolvedType; if (this.genericCast != null) convertedType = this.genericCast; int runtimeType = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4; switch (runtimeType) { case T_boolean: convertedType = TypeBinding.BOOLEAN; break; case T_byte: convertedType = TypeBinding.BYTE; break; case T_short: convertedType = TypeBinding.SHORT; break; case T_char: convertedType = TypeBinding.CHAR; break; case T_int: convertedType = TypeBinding.INT; break; case T_float: convertedType = TypeBinding.FLOAT; break; case T_long: convertedType = TypeBinding.LONG; break; case T_double: convertedType = TypeBinding.DOUBLE; break; default: } if ((this.implicitConversion & TypeIds.BOXING) != 0) { convertedType = scope.environment().computeBoxingType(convertedType); } return convertedType; }