Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Backend errors refining interface with default method and type parameter #7438

Open
kingjon3377 opened this issue Nov 29, 2018 · 0 comments
Open

Comments

@kingjon3377
Copy link

kingjon3377 commented Nov 29, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant