Skip to content

Attributes whose type is a type variable are not handled correctly #288

@raner

Description

@raner

Example:

    static interface Quantity<VALUE extends Number>
    {
        VALUE value();
    }

    static interface RealQuantity extends Quantity<Double>
    {
    	// No additional methods
    }

    @Test
    public void testRealQuantityWithGenericType()
    {
    	Number fortyTwo = Double.valueOf(42D);
    	RealQuantity quantity = Projo.builder(RealQuantity.class).with(Quantity::value, fortyTwo).build();
        assertEquals(Double.valueOf(42D), quantity.value());
    }

    @Test
    public void testRealQuantityWithGenericTypeButSpecificValue()
    {
    	RealQuantity quantity = Projo.builder(RealQuantity.class).with(Quantity::value, Double.valueOf(42D)).build();
    	assertEquals(Double.valueOf(42D), quantity.value());
    }

    @Test
    public void testRealQuantityWithSpecificType()
    {
    	RealQuantity quantity = Projo.builder(RealQuantity.class).with(RealQuantity::value, Double.valueOf(42D)).build();
    	assertEquals(Double.valueOf(42D), quantity.value());
    }

The tests fail for both proxy-based implementation as well as for runtime code generation, though for slightly different reasons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions