ceylon/ceylon-compiler — Issue #260: "Nothing x" should be able to refine "T? x"
Author: gavinking
Created: 2011-12-04 15:40:46+00:00
State: open
Labels: BUG, high priority

Consider the following well-typed code:

class Pair(String one, String two) satisfies Iterable {
shared actual object iterator satisfies Iterator {
shared actual String head = one;
shared actual object tail satisfies Iterator {
shared actual String head = two;
shared actual Nothing tail = null;
}
}
shared actual Boolean empty = false;
}

If I try to instantiate `Pair` I get an `AbstractMethodError` because the inner definition of `tail` is declared with type `Nothing` which gets erased to `Object` which is not a subtype of the type of the supertype method `Iterator`.

So instead of erasing to `Object` in this case, we should keep the type of the supertype method, perhaps the raw type `Iterator`.