ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

CCE working with Integer|Float #1406

Closed FroMage closed 9 years ago

FroMage commented 9 years ago

I guess this is valid code:

    variable Integer|Float iof = 1.0;
    iof += 1;
ceylon run: ceylon.language.Integer cannot be cast to ceylon.language.Float
java.lang.ClassCastException: ceylon.language.Integer cannot be cast to ceylon.language.Float
    at ceylon.language.Float.plus(Float.java:14)

Similar with:

    variable Integer|Float iof = 1;
    iof += 1.0;

and:

    variable Integer|Float iof = 1;
    iof += iof;

    /*
     Method plus in interface ceylon.language.Summable<Other> cannot be applied to given types;
     required: ceylon.language.Summable
     found: java.lang.Object
     reason: actual argument java.lang.Object cannot be converted to ceylon.language.Summable by method invocation conversion
     */
FroMage commented 9 years ago

Originally reported by @jvasileff at https://github.com/ceylon/ceylon-compiler/issues/2277

gavinking commented 9 years ago

OK, so my guess is that this is a new bug that has arisen because there is now a principal instantiation of Summable for Integer|Float. Before, the typechecker could not form the type Summable<out Integer|Float>, but now it can and does.

gavinking commented 9 years ago

Fixed!