eclipse-archived/ceylon

Backend errors refining interface with default method and type parameter

Opened this issue · 0 comments

The following code fails to compile with two (contradictory?) backend errors:

interface ReferencedInterface {}
class ReferencedClass() satisfies ReferencedInterface {}
class SecondClass() satisfies ReferencedInterface {}
interface ExampleInterface<Parameter> given Parameter satisfies ReferencedInterface {
    shared default Parameter pairAccessor([Integer, Parameter] pair) => pair.rest.first;
}
class ExampleClass() satisfies ExampleInterface<ReferencedClass|SecondClass> {}

The backend errors are as follows:

source/defaultparameterized/run.ceylon:7: error: Ceylon backend error: ExampleClass is not abstract and does not override abstract method pairAccessor(Sequence) in ExampleInterface
class ExampleClass() satisfies ExampleInterface<ReferencedClass|SecondClass> {}
^
error: Ceylon backend error: pairAccessor(Sequence) in ExampleClass cannot implement pairAccessor(Sequence) in ExampleInterface
  return type Object is not compatible with ReferencedInterface
  where Parameter is a type-variable:
    Parameter extends ReferencedInterface declared in interface ExampleInterface

This does not happen if the type parameter of the class in question is not a union type, nor if the pairAccessor method has a return type that doesn't reference type type parameter, nor if the method is defined (even as default) in an abstract superclass rather than an interface.

The IntelliJ IDE (when I can get it to complete the typechecking/model-building process without aborting with the same error message as eclipse-archived/ceylon-ide-intellij#655 and eclipse-archived/ceylon-ide-intellij#654, which in IDEA 2017.2 just takes patience with repeated attempts until it succeeds once) passes the code from which I distilled the above without any complaints.

ceylon --version reports ceylon version 1.3.3 0d594b3 (Contents May Differ); it's installed on my Mac OS X machine via Homebrew.