Unit obtained through a generic substitution should not be mapped to VOID

This commit is contained in:
Andrey Breslav
2014-10-06 21:45:12 +04:00
parent f5aed51fd0
commit 5be4dda58b
4 changed files with 48 additions and 2 deletions

View File

@@ -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;
}
}

View File

@@ -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"
}