mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Unit obtained through a generic substitution should not be mapped to VOID
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
public class GenericUnit {
|
||||
public static class Key<T> {}
|
||||
|
||||
public static <T> T getNull(Key<T> key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T get(Key<T> key, T t) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import GenericUnit.*
|
||||
|
||||
val key = Key<Unit>()
|
||||
|
||||
fun box(): String {
|
||||
val n1 = getNull(key)
|
||||
if (n1 != null) return "Fail 1: $n1"
|
||||
|
||||
val n2 = get(key, null)
|
||||
if (n2 != null) return "Fail 2: $n2"
|
||||
|
||||
val n3 = get(key, Unit)
|
||||
if (n3 == null) return "Fail 3.0: $n3"
|
||||
if (n3 != Unit) return "Fail 3.1: $n3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user