Skip to content

Java generic type constraints translated incorrectly #16

Description

@paulirwin

Input:

public class Foo {
    public static <T extends number> boolean isNegative(T number) {
        return number.longValue() < 0;
    }
}

Output (incorrect):

public class Foo
{
    public static bool IsNegative<T extends number>(T number)
    {
        return number.LongValue() < 0;
    }
}

Output (expected; syntactically correct but might be wrong):

public class Foo
{
    public static bool IsNegative<T>(T number)
    {
        return number.LongValue() < 0;
    }
}

Note that in this case there is no C# equivalent of constraining a generic type parameter to be a number, but at least we can make it syntactically correct.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions