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
object unsoundMini extends App { | |
trait A { type L >: Any} | |
def upcast(a: A, x: Any): a.L = x | |
val p: A { type L <: Nothing } = null | |
def coerce(x: Any): Nothing = upcast(p, x) | |
coerce("Uh oh!") | |
} |
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
class UnsoundSpec { | |
static class Constrain<A, B extends A> {} | |
static <A,B extends A> | |
A upcast(Constrain<A,B> constrain, B b) { | |
return b; | |
} | |
static <T,U> U coerce(T t) { | |
Constrain<U,? super T> constrain = null; | |
return upcast(constrain, t); | |
} |
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
(define anyo | |
(lambda (g) | |
(conde | |
(g) | |
((anyo g))))) |
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
(define ,A | |
(lambda (xs ys) | |
,C)) | |
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
class Unsound { | |
static class Constrain<A, B extends A> {} | |
static class Bind<A> { | |
<B extends A> | |
A upcast(Constrain<A,B> constrain, B b) { | |
return b; | |
} | |
} | |
static <T,U> U coerce(T t) { | |
Constrain<U,? super T> constrain = null; |
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
class Unsound { | |
static class Constrain<A, B extends A> {} | |
static class Bind<A> { | |
<B extends A> | |
A upcast(Constrain<A,B> constrain, B b) { | |
return b; | |
} | |
} | |
static <T,U> U coerce(T t) { | |
Constrain<U,? super T> constrain = null; |
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
class Unsound9<U,T> { | |
static class Type<A> { | |
class Constraint<B extends A> extends Type<B> {} | |
<B> Constraint<? super B> bad() { return null; } | |
<B> A coerce(B b) { | |
return pair(this.<B>bad(), b).value; | |
} | |
} | |
static class DependentSum<T> { | |
Type<T> type; |
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
class UnsoundSpec { | |
static class Constrain<A, B extends A> {} | |
static <A,B extends A> | |
A upcast(Constrain<A,B> constrain, B b) { | |
return b; | |
} | |
static <T,U> U coerce(T t) { | |
Constrain<U,? super T> constrain = null; | |
return upcast(constrain, t); | |
} |
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
class UnsoundSpec { | |
static class Constrain<A, B extends A> {} | |
static <A,B extends A> | |
A upcast(Constrain<A,B> constrain, B b) { | |
return b; | |
} | |
static <T,U> U coerce(T t) { | |
Constrain<U,? super T> constrain = null; | |
return upcast(constrain, t); | |
} |
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
class Unsound { | |
static class Constrain<A, B extends A> {} | |
static class Bind<A> { | |
<B extends A> | |
A upcast(Constrain<A,B> constrain, B b) { | |
return b; | |
} | |
} | |
static <T,U> U coerce(T t) { | |
Constrain<U,? super T> constrain = null; |
OlderNewer