eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
396 stars 62 forks source link

Compile error on interface that satisfies another interface twice, with refined generic covariant return #2191

Open CeylonMigrationBot opened 9 years ago

CeylonMigrationBot commented 9 years ago

[@jvasileff] This may look complicated, but it's basically what you get when satisfying List twice, with its repeat refinement causing the trouble.

interface Foo {}
interface Bar {}

interface ProducerSuper<out I> {
    shared default ProducerSuper<I> self() => this;
}

interface ProducerSub<out I> satisfies ProducerSuper<I> {
    shared actual default ProducerSub<I> self() => this;
}

interface FooProducer satisfies ProducerSub<Foo> {}
interface BarProducer satisfies ProducerSub<Bar> {}

interface FooBarProducer satisfies FooProducer & BarProducer {}
$ ceylon compile --suppress-warning
warning: It looks like you are using class files from a Java newer than 1.7.
  Everything should work well, but if not, let us know at https://github.com/ceylon/ceylon-compiler/issues.
  In the near future, the Ceylon compiler will be upgraded to handle Java 1.8.
source/simple/run.ceylon:13: error: self() in FooBarProducer clashes with self() in ProducerSub
interface BarProducer satisfies ProducerSub<Bar> {}
^
  return type ProducerSuper<? extends Foo> is not compatible with ProducerSub<? extends Foo>
  where I is a type-variable:
    I extends Object declared in interface ProducerSub
1 error
1 warning
Note: Created module simple/1.0.0
ceylon compile: There was 1 error

[Migrated from ceylon/ceylon-compiler#2191]

CeylonMigrationBot commented 9 years ago

[@FroMage] Moving to 1.3.