2887 } |
2887 } |
2888 |
2888 |
2889 /** Unbox an object to a primitive value. */ |
2889 /** Unbox an object to a primitive value. */ |
2890 JCExpression unbox(JCExpression tree, Type primitive) { |
2890 JCExpression unbox(JCExpression tree, Type primitive) { |
2891 Type unboxedType = types.unboxedType(tree.type); |
2891 Type unboxedType = types.unboxedType(tree.type); |
2892 // note: the "primitive" parameter is not used. There muse be |
2892 if (unboxedType.tag == NONE) { |
2893 // a conversion from unboxedType to primitive. |
2893 unboxedType = primitive; |
|
2894 if (!unboxedType.isPrimitive()) |
|
2895 throw new AssertionError(unboxedType); |
|
2896 make_at(tree.pos()); |
|
2897 tree = make.TypeCast(types.boxedClass(unboxedType).type, tree); |
|
2898 } else { |
|
2899 // There must be a conversion from unboxedType to primitive. |
|
2900 if (!types.isSubtype(unboxedType, primitive)) |
|
2901 throw new AssertionError(tree); |
|
2902 } |
2894 make_at(tree.pos()); |
2903 make_at(tree.pos()); |
2895 Symbol valueSym = lookupMethod(tree.pos(), |
2904 Symbol valueSym = lookupMethod(tree.pos(), |
2896 unboxedType.tsym.name.append(names.Value), // x.intValue() |
2905 unboxedType.tsym.name.append(names.Value), // x.intValue() |
2897 tree.type, |
2906 tree.type, |
2898 List.<Type>nil()); |
2907 List.<Type>nil()); |