本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeBinding.isBaseType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeBinding.isBaseType方法的具体用法?Java TypeBinding.isBaseType怎么用?Java TypeBinding.isBaseType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeBinding
的用法示例。
在下文中一共展示了TypeBinding.isBaseType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typeBindingToSignature
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
private static String typeBindingToSignature(TypeBinding binding) {
binding = binding.erasure();
if (binding != null && binding.isBaseType()) {
return new String (binding.sourceName());
} else if (binding instanceof ReferenceBinding) {
String pkg = binding.qualifiedPackageName() == null ? "" : new String(binding.qualifiedPackageName());
String qsn = binding.qualifiedSourceName() == null ? "" : new String(binding.qualifiedSourceName());
return pkg.isEmpty() ? qsn : (pkg + "." + qsn);
} else if (binding instanceof ArrayBinding) {
StringBuilder out = new StringBuilder();
out.append(typeBindingToSignature(binding.leafComponentType()));
for (int i = 0; i < binding.dimensions(); i++) out.append("[]");
return out.toString();
}
return "";
}
示例2: checkNeedForEnclosingInstanceCast
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* Casting an enclosing instance will considered as useful if removing it would actually bind to a different type
*/
public static void checkNeedForEnclosingInstanceCast(BlockScope scope, Expression enclosingInstance, TypeBinding enclosingInstanceType, TypeBinding memberType) {
if (scope.compilerOptions().getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return;
TypeBinding castedExpressionType = ((CastExpression)enclosingInstance).expression.resolvedType;
if (castedExpressionType == null) return; // cannot do better
// obvious identity cast
if (TypeBinding.equalsEquals(castedExpressionType, enclosingInstanceType)) {
scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance);
} else if (castedExpressionType == TypeBinding.NULL){
return; // tolerate null enclosing instance cast
} else {
TypeBinding alternateEnclosingInstanceType = castedExpressionType;
if (castedExpressionType.isBaseType() || castedExpressionType.isArrayType()) return; // error case
if (TypeBinding.equalsEquals(memberType, scope.getMemberType(memberType.sourceName(), (ReferenceBinding) alternateEnclosingInstanceType))) {
scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance);
}
}
}
示例3: checkNeedForEnclosingInstanceCast
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* Casting an enclosing instance will considered as useful if removing it would actually bind to a different type
*/
public static void checkNeedForEnclosingInstanceCast(BlockScope scope, Expression enclosingInstance, TypeBinding enclosingInstanceType, TypeBinding memberType) {
if (scope.compilerOptions().getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return;
TypeBinding castedExpressionType = ((CastExpression)enclosingInstance).expression.resolvedType;
if (castedExpressionType == null) return; // cannot do better
// obvious identity cast
if (castedExpressionType == enclosingInstanceType) {
scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance);
} else if (castedExpressionType == TypeBinding.NULL){
return; // tolerate null enclosing instance cast
} else {
TypeBinding alternateEnclosingInstanceType = castedExpressionType;
if (castedExpressionType.isBaseType() || castedExpressionType.isArrayType()) return; // error case
if (memberType == scope.getMemberType(memberType.sourceName(), (ReferenceBinding) alternateEnclosingInstanceType)) {
scope.problemReporter().unnecessaryCast((CastExpression)enclosingInstance);
}
}
}
示例4: isTypeUseDeprecated
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public final boolean isTypeUseDeprecated(TypeBinding type, Scope scope) {
if (type.isArrayType()) {
type = ((ArrayBinding) type).leafComponentType;
}
if (type.isBaseType())
return false;
ReferenceBinding refType = (ReferenceBinding) type;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=397888
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=385780
if ((this.bits & ASTNode.InsideJavadoc) == 0 && refType instanceof TypeVariableBinding) {
refType.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
}
// ignore references insing Javadoc comments
if ((this.bits & ASTNode.InsideJavadoc) == 0 && refType.isOrEnclosedByPrivateType() && !scope.isDefinedInType(refType)) {
// ignore cases where type is used from inside itself
((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
}
if (refType.hasRestrictedAccess()) {
AccessRestriction restriction = scope.environment().getAccessRestriction(type.erasure());
if (restriction != null) {
scope.problemReporter().forbiddenReference(type, this, restriction.classpathEntryType,
restriction.classpathEntryName, restriction.getProblemId());
}
}
// force annotations resolution before deciding whether the type may be deprecated
refType.initializeDeprecatedAnnotationTagBits();
if (!refType.isViewedAsDeprecated()) return false;
// inside same unit - no report
if (scope.isDefinedInSameUnit(refType)) return false;
// if context is deprecated, may avoid reporting
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
return true;
}
示例5: sIsMoreSpecific
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope) {
if (super.sIsMoreSpecific(s, t, scope))
return true;
if (this.exactMethodBinding == null || t.findSuperTypeOriginatingFrom(s) != null)
return false;
s = s.capture(this.enclosingScope, this.sourceEnd);
MethodBinding sSam = s.getSingleAbstractMethod(this.enclosingScope, true);
if (sSam == null || !sSam.isValidBinding())
return false;
TypeBinding r1 = sSam.returnType;
MethodBinding tSam = t.getSingleAbstractMethod(this.enclosingScope, true);
if (tSam == null || !tSam.isValidBinding())
return false;
TypeBinding r2 = tSam.returnType;
if (r2.id == TypeIds.T_void)
return true;
if (r1.id == TypeIds.T_void)
return false;
// r1 <: r2
if (r1.isCompatibleWith(r2, scope))
return true;
return r1.isBaseType() != r2.isBaseType() && r1.isBaseType() == this.exactMethodBinding.returnType.isBaseType();
}
示例6: computeConversion
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.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);
}
示例7: computeConversion
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
*/
public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) {
if (runtimeTimeType == null || compileTimeType == null)
return;
// set the generic cast after the fact, once the type expectation is fully known (no need for strict cast)
if (this.binding != null && this.binding.isValidBinding()) {
FieldBinding originalBinding = this.binding.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 = originalBinding.type.genericCast(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);
}
示例8: computeConversion
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
*/
public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) {
if (runtimeTimeType == null || compileTimeType == null)
return;
// set the generic cast after the fact, once the type expectation is fully known (no need for strict cast)
if (this.binding != null && this.binding.isValidBinding()) {
MethodBinding originalBinding = this.binding.original();
TypeBinding originalType = originalBinding.returnType;
// extra cast needed if method return type is type variable
if (originalType.leafComponentType().isTypeVariable()) {
TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType())
? compileTimeType // unboxing: checkcast before conversion
: runtimeTimeType;
this.valueCast = originalType.genericCast(targetType);
} else if (this.binding == scope.environment().arrayClone
&& runtimeTimeType.id != TypeIds.T_JavaLangObject
&& scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
// from 1.5 source level on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast
this.valueCast = runtimeTimeType;
}
if (this.valueCast instanceof ReferenceBinding) {
ReferenceBinding referenceCast = (ReferenceBinding) this.valueCast;
if (!referenceCast.canBeSeenBy(scope)) {
scope.problemReporter().invalidType(this,
new ProblemReferenceBinding(
CharOperation.splitOn('.', referenceCast.shortReadableName()),
referenceCast,
ProblemReasons.NotVisible));
}
}
}
super.computeConversion(scope, runtimeTimeType, compileTimeType);
}
示例9: generateCode
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
int pc = codeStream.position;
MethodBinding codegenBinding = this.binding.original();
ReferenceBinding allocatedType = codegenBinding.declaringClass;
if (codegenBinding.canBeSeenBy(allocatedType, this, currentScope)) {
codeStream.new_(this.type, allocatedType);
if (valueRequired) {
codeStream.dup();
}
// better highlight for allocation: display the type individually
codeStream.recordPositionsFrom(pc, this.type.sourceStart);
// handling innerclass instance allocation - enclosing instance arguments
if (allocatedType.isNestedType()) {
codeStream.generateSyntheticEnclosingInstanceValues(
currentScope,
allocatedType,
enclosingInstance(),
this);
}
// generate the arguments for constructor
if (this.arguments != null) {
for (int i = 0, count = this.arguments.length; i < count; i++) {
this.arguments[i].generateCode(currentScope, codeStream, true);
}
}
// handling innerclass instance allocation - outer local arguments
if (allocatedType.isNestedType()) {
codeStream.generateSyntheticOuterArgumentValues(
currentScope,
allocatedType,
this);
}
// invoke constructor
codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */, this.typeArguments);
} else {
// private emulation using reflect
codeStream.generateEmulationForConstructor(currentScope, codegenBinding);
// generate arguments
if (this.arguments != null) {
int argsLength = this.arguments.length;
codeStream.generateInlinedValue(argsLength);
codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1));
codeStream.dup();
for (int i = 0; i < argsLength; i++) {
codeStream.generateInlinedValue(i);
this.arguments[i].generateCode(currentScope, codeStream, true);
TypeBinding parameterBinding = codegenBinding.parameters[i];
if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
codeStream.generateBoxingConversion(codegenBinding.parameters[i].id);
}
codeStream.aastore();
if (i < argsLength - 1) {
codeStream.dup();
}
}
} else {
codeStream.generateInlinedValue(0);
codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1));
}
codeStream.invokeJavaLangReflectConstructorNewInstance();
codeStream.checkcast(allocatedType);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:67,代码来源:CodeSnippetAllocationExpression.java
示例10: sIsMoreSpecific
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope skope) {
// 15.12.2.5
if (super.sIsMoreSpecific(s, t, skope))
return true;
if (argumentsTypeElided() || t.findSuperTypeOriginatingFrom(s) != null)
return false;
s = s.capture(this.enclosingScope, this.sourceEnd);
MethodBinding sSam = s.getSingleAbstractMethod(this.enclosingScope, true);
if (sSam == null || !sSam.isValidBinding())
return false;
TypeBinding r1 = sSam.returnType;
MethodBinding tSam = t.getSingleAbstractMethod(this.enclosingScope, true);
if (tSam == null || !tSam.isValidBinding())
return false;
TypeBinding r2 = tSam.returnType;
if (r2.id == TypeIds.T_void)
return true;
if (r1.id == TypeIds.T_void)
return false;
// r1 <: r2
if (r1.isCompatibleWith(r2, skope))
return true;
Expression [] returnExpressions = this.resultExpressions;
int returnExpressionsLength = returnExpressions == null ? 0 : returnExpressions.length;
int i;
// r1 is a primitive type, r2 is a reference type, and each result expression is a standalone expression (15.2) of a primitive type
if (r1.isBaseType() && !r2.isBaseType()) {
for (i = 0; i < returnExpressionsLength; i++) {
if (returnExpressions[i].isPolyExpression() || !returnExpressions[i].resolvedType.isBaseType())
break;
}
if (i == returnExpressionsLength)
return true;
}
if (!r1.isBaseType() && r2.isBaseType()) {
for (i = 0; i < returnExpressionsLength; i++) {
if (returnExpressions[i].resolvedType.isBaseType())
break;
}
if (i == returnExpressionsLength)
return true;
}
if (r1.isFunctionalInterface(this.enclosingScope) && r2.isFunctionalInterface(this.enclosingScope)) {
for (i = 0; i < returnExpressionsLength; i++) {
Expression resultExpression = returnExpressions[i];
if (!resultExpression.sIsMoreSpecific(r1, r2, skope))
break;
}
if (i == returnExpressionsLength)
return true;
}
return false;
}
示例11: computeConversion
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* Base types need that the widening is explicitly done by the compiler using some bytecode like i2f.
* Also check unsafe type operations.
*/
public void computeConversion(Scope scope, TypeBinding runtimeType, TypeBinding compileTimeType) {
if (runtimeType == null || compileTimeType == null)
return;
if (this.implicitConversion != 0) return; // already set independently
// it is possible for a Byte to be unboxed to a byte & then converted to an int
// but it is not possible for a byte to become Byte & then assigned to an Integer,
// or to become an int before boxed into an Integer
if (runtimeType != TypeBinding.NULL && runtimeType.isBaseType()) {
if (!compileTimeType.isBaseType()) {
TypeBinding unboxedType = scope.environment().computeBoxingType(compileTimeType);
this.implicitConversion = TypeIds.UNBOXING;
scope.problemReporter().autoboxing(this, compileTimeType, runtimeType);
compileTimeType = unboxedType;
}
} else if (compileTimeType != TypeBinding.NULL && compileTimeType.isBaseType()) {
TypeBinding boxedType = scope.environment().computeBoxingType(runtimeType);
if (TypeBinding.equalsEquals(boxedType, runtimeType)) // Object o = 12;
boxedType = compileTimeType;
this.implicitConversion = TypeIds.BOXING | (boxedType.id << 4) + compileTimeType.id;
scope.problemReporter().autoboxing(this, compileTimeType, scope.environment().computeBoxingType(boxedType));
return;
} else if (this.constant != Constant.NotAConstant && this.constant.typeID() != TypeIds.T_JavaLangString) {
this.implicitConversion = TypeIds.BOXING;
return;
}
int compileTimeTypeID, runtimeTypeID;
if ((compileTimeTypeID = compileTimeType.id) >= TypeIds.T_LastWellKnownTypeId) { // e.g. ? extends String ==> String (103227); >= TypeIds.T_LastWellKnownTypeId implies TypeIds.NoId
compileTimeTypeID = compileTimeType.erasure().id == TypeIds.T_JavaLangString ? TypeIds.T_JavaLangString : TypeIds.T_JavaLangObject;
} else if (runtimeType.isPrimitiveType() && compileTimeType instanceof ReferenceBinding && !compileTimeType.isBoxedPrimitiveType()) {
compileTimeTypeID = TypeIds.T_JavaLangObject; // treatment is the same as for jlO.
}
switch (runtimeTypeID = runtimeType.id) {
case T_byte :
case T_short :
case T_char :
if (compileTimeTypeID == TypeIds.T_JavaLangObject) {
this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID;
} else {
this.implicitConversion |= (TypeIds.T_int << 4) + compileTimeTypeID;
}
break;
case T_JavaLangString :
case T_float :
case T_boolean :
case T_double :
case T_int : //implicitConversion may result in i2i which will result in NO code gen
case T_long :
this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID;
break;
default : // regular object ref
// if (compileTimeType.isRawType() && runtimeTimeType.isBoundParameterizedType()) {
// scope.problemReporter().unsafeRawExpression(this, compileTimeType, runtimeTimeType);
// }
}
}
示例12: sIsMoreSpecific
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope) {
if (super.sIsMoreSpecific(s, t, scope))
return true;
return isPolyExpression() ? !s.isBaseType() && t.isBaseType() : false;
}
示例13: generateCode
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
int pc = codeStream.position;
MethodBinding codegenBinding = this.binding.original();
ReferenceBinding allocatedType = codegenBinding.declaringClass;
if (codegenBinding.canBeSeenBy(allocatedType, this, currentScope)) {
codeStream.new_(allocatedType);
if (valueRequired) {
codeStream.dup();
}
// better highlight for allocation: display the type individually
codeStream.recordPositionsFrom(pc, this.type.sourceStart);
// handling innerclass instance allocation - enclosing instance arguments
if (allocatedType.isNestedType()) {
codeStream.generateSyntheticEnclosingInstanceValues(
currentScope,
allocatedType,
enclosingInstance(),
this);
}
// generate the arguments for constructor
if (this.arguments != null) {
for (int i = 0, count = this.arguments.length; i < count; i++) {
this.arguments[i].generateCode(currentScope, codeStream, true);
}
}
// handling innerclass instance allocation - outer local arguments
if (allocatedType.isNestedType()) {
codeStream.generateSyntheticOuterArgumentValues(
currentScope,
allocatedType,
this);
}
// invoke constructor
codeStream.invoke(Opcodes.OPC_invokespecial, codegenBinding, null /* default declaringClass */);
} else {
// private emulation using reflect
codeStream.generateEmulationForConstructor(currentScope, codegenBinding);
// generate arguments
if (this.arguments != null) {
int argsLength = this.arguments.length;
codeStream.generateInlinedValue(argsLength);
codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1));
codeStream.dup();
for (int i = 0; i < argsLength; i++) {
codeStream.generateInlinedValue(i);
this.arguments[i].generateCode(currentScope, codeStream, true);
TypeBinding parameterBinding = codegenBinding.parameters[i];
if (parameterBinding.isBaseType() && parameterBinding != TypeBinding.NULL) {
codeStream.generateBoxingConversion(codegenBinding.parameters[i].id);
}
codeStream.aastore();
if (i < argsLength - 1) {
codeStream.dup();
}
}
} else {
codeStream.generateInlinedValue(0);
codeStream.newArray(currentScope.createArrayType(currentScope.getType(TypeConstants.JAVA_LANG_OBJECT, 3), 1));
}
codeStream.invokeJavaLangReflectConstructorNewInstance();
codeStream.checkcast(allocatedType);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:67,代码来源:CodeSnippetAllocationExpression.java
示例14: computeConversion
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
/**
* Base types need that the widening is explicitly done by the compiler using some bytecode like i2f.
* Also check unsafe type operations.
*/
public void computeConversion(Scope scope, TypeBinding runtimeType, TypeBinding compileTimeType) {
if (runtimeType == null || compileTimeType == null)
return;
if (this.implicitConversion != 0) return; // already set independantly
// it is possible for a Byte to be unboxed to a byte & then converted to an int
// but it is not possible for a byte to become Byte & then assigned to an Integer,
// or to become an int before boxed into an Integer
if (runtimeType != TypeBinding.NULL && runtimeType.isBaseType()) {
if (!compileTimeType.isBaseType()) {
TypeBinding unboxedType = scope.environment().computeBoxingType(compileTimeType);
this.implicitConversion = TypeIds.UNBOXING;
scope.problemReporter().autoboxing(this, compileTimeType, runtimeType);
compileTimeType = unboxedType;
}
} else if (compileTimeType != TypeBinding.NULL && compileTimeType.isBaseType()) {
TypeBinding boxedType = scope.environment().computeBoxingType(runtimeType);
if (boxedType == runtimeType) // Object o = 12;
boxedType = compileTimeType;
this.implicitConversion = TypeIds.BOXING | (boxedType.id << 4) + compileTimeType.id;
scope.problemReporter().autoboxing(this, compileTimeType, scope.environment().computeBoxingType(boxedType));
return;
} else if (this.constant != Constant.NotAConstant && this.constant.typeID() != TypeIds.T_JavaLangString) {
this.implicitConversion = TypeIds.BOXING;
return;
}
int compileTimeTypeID, runtimeTypeID;
if ((compileTimeTypeID = compileTimeType.id) == TypeIds.NoId) { // e.g. ? extends String ==> String (103227)
compileTimeTypeID = compileTimeType.erasure().id == TypeIds.T_JavaLangString ? TypeIds.T_JavaLangString : TypeIds.T_JavaLangObject;
}
switch (runtimeTypeID = runtimeType.id) {
case T_byte :
case T_short :
case T_char :
if (compileTimeTypeID == TypeIds.T_JavaLangObject) {
this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID;
} else {
this.implicitConversion |= (TypeIds.T_int << 4) + compileTimeTypeID;
}
break;
case T_JavaLangString :
case T_float :
case T_boolean :
case T_double :
case T_int : //implicitConversion may result in i2i which will result in NO code gen
case T_long :
this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID;
break;
default : // regular object ref
// if (compileTimeType.isRawType() && runtimeTimeType.isBoundParameterizedType()) {
// scope.problemReporter().unsafeRawExpression(this, compileTimeType, runtimeTimeType);
// }
}
}