ceylon/ceylon-compiler

Inconvertible types with switch is case involving useless type

lucaswerkmeister opened this issue · 1 comments

class Sup() {}
class Sub() extends Sup() {}
class Other() {}
void f1(Sup s) {
    switch (s)
    case (is Sub|Other) {}
    else {}
}
Integer f2(Sup s)
        => switch (s)
    case (is Sub|Other) 0
    else 1;

source/tmp/run.ceylon:5: error: inconvertible types

    switch (s)
    ^

required: Other
found: Sup
source/tmp/run.ceylon:10: error: inconvertible types

        => switch (s)
           ^

required: Other
found: Sup
2 errors

As always, generated code, @noanno’d. The compiler generates instanceof Other tests, which are illegal.

Actually, this bug is even useful, since there’s no typechecker warning about these useless types ;)