Last active
June 15, 2016 11:59
-
-
Save taku0/4335f65eb20a54fb965fff58fd582878 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Z {} | |
interface N<T> {} | |
interface E<T> extends N<N<? super E<? super T>>> {} | |
// Changing E to the following, Oracle JDK 1.8.0_92 says | |
// `error: incompatible types: E<Z> cannot be converted to N<? super E<Z>>` | |
// interface E<T> extends N<N<? super E<T>>> {} | |
class GenericsLoop { | |
N<? super E<Z>> doit(E<Z> v) { | |
/* | |
E → NNE | |
EZ <: NEZ | |
↓ | |
NNEZ <: NEZ | |
↓ | |
EZ <: NEZ | |
*/ | |
return v; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Z {} | |
interface N<T> {} | |
interface E<T> extends N<N<? super E<N<T>>>> {} | |
class Main { | |
N<? super E<Z>> doit(E<Z> v) { | |
/* | |
E → NN?EN | |
EZ <: N?EZ | |
↓ | |
NN?ENZ <: N?EZ | |
↓ | |
EZ <: N?ENZ | |
↓ | |
NN?ENZ <: N?ENZ | |
↓ | |
ENZ <: N?ENZ | |
↓* | |
ENNZ <: N?ENNZ | |
↓* | |
ENNNZ <: N?ENNNZ | |
↓ | |
. | |
. | |
. | |
*/ | |
return v; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Z | |
trait N[T] | |
// error: illegal cyclic reference involving trait E | |
trait E[T] extends N[N[_ >: E[N[T]]]] | |
class Main { | |
def doit(v: E[Z]): N[_ >: E[Z]] = v | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Z | |
trait N[-T] | |
// error: class graph is not finitary because type parameter T is expansively recursive | |
trait E[-T] extends N[N[E[N[T]]]] | |
class Main { | |
def doit(v: E[Z]): N[E[Z]] = v | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Z | |
trait N[-T] | |
trait E[-T] extends N[N[E[_ >: T]]] | |
class Main { | |
def doit(v: E[Z]): N[E[Z]] = v | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment