Skip to content

Explore the option to implement automatic conversion of primitive numeric types to their counterpart reference types #19

Description

@slavchev

byte -> java.lang.Byte
short -> java.lang.Short
int -> java.lang.Integer
long -> java.lang.Long
float -> java.lang.Float
double -> java.lang.Double

Module team found this issue in the following example:

function createReminder()
{
    var beginTime = java.util.Calendar.getInstance();
    beginTime.set(2012, 9, 14, 7, 30);
    var startMillis = beginTime.getTimeInMillis();
    var values = new android.content.ContentValues();
    // !!!
    values.put(android.provider.CalendarContract.Events.DTSTART, startMillis);
}

Workaround: for example long -> java.lang.Long.valueOf(...)

Activity

  1. Plamen5kov commented on Dec 14, 2015

    @Plamen5kov
    Contributor

    We decided it's best to force the user to explicitly use the specific data type, because the runtime will sometimes be unable to figure out what conversion to make.
    Example:
    method put of android.content.ContentValues takes parameters float and double. In this case the user has to specify what overload he wants to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions