JUG Milano - http://www.jugmilano.it/ Il canale di Gitter dedicato al JVM User Group
allora ho una classe:
import io.atlassian.fugue.Either;
public class E1 {
public Either<Exception, String> example() {
return Either.right("");
}
}
e la estendo come:
import io.atlassian.fugue.Either;
public class E2 extends E1 {
@Override
public Either<String, Exception> example() {
return Either.left(new Exception());
}
}
notate che in E2 la signature del tipo di ritorno ha i generici invbertiti, e tutto cio' con mia enorme sorpresa compila
la dipendenza e':
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>4.7.1</version>
</dependency>
con interfacce e classi definite da me nonn riesco a riprodurre
il pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>example</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
e mvn compile
javac MainFUgue.java -cp ~/.m2/repository/io/atlassian/fugue/fugue/4.7.1/fugue-4.7.1.jar
MainFUgue.java:23: error: example() in E2 cannot override example() in E1
public Either<String, Exception> example() {
^
return type Either<String,Exception> is not compatible with Either<Exception,String>
MainFUgue.java:22: error: method does not override or implement a method from a supertype
@Override
^
MainFUgue.java:24: error: incompatible types: inference variable L has incompatible bounds
return Either.left(new Exception());
^
equality constraints: String
lower bounds: Exception
where L,R are type-variables:
L extends Object declared in method <L,R>left(L)
R extends Object declared in method <L,R>left(L)
3 errors
Stress da rientro? Ansia da "domani è Lunedì" ? Non disperate, we at JUGMilano got you covered ;) riprendiamo gli appuntamenti e siamo lieti di annunciarvi che il prossimo incontro del JUG Milano si terrà Giovedì 26 Settembre 2019.
Questo il programma:
h 19:00 - JUG news e attività in corso
h 19:10 - "Come e perchè ho trasformato il mio vecchio progetto Java in un componente per un'architettura serverless", a cura di Mario Fusco
h ~20:30 - Chiusura lavori, estrazione licenza JetBrains/IntelliJ Idea(*) ed eventuali
Potete trovare maggiori dettagli e registrarvi per l'incontro direttamente sul nostro sito:
http://www.jugmilano.it/meeting-114.html
Dopo l'incontro, per chi vorrà, ci mangeremo una pizza condita da chiacchiere tecnologiche.
Vi aspettiamo!