Black box update
This commit is contained in:
committed by
Dmitry Jemerov
parent
40574d31ac
commit
496a21254b
@@ -25,8 +25,10 @@ fun box(): String {
|
||||
|
||||
// Java class without nested classes
|
||||
assertEquals(emptyList<String>(), nestedNames(Error::class))
|
||||
// Java interface with nested classes
|
||||
assertEquals(listOf("Entry"), nestedNames(java.util.Map::class))
|
||||
// Java class with nested classes
|
||||
assertEquals(listOf("State", "UncaughtExceptionHandler"), nestedNames(Thread::class))
|
||||
assertEquals(listOf("SimpleEntry", "SimpleImmutableEntry"), nestedNames(java.util.AbstractMap::class))
|
||||
|
||||
// Built-ins
|
||||
assertEquals(emptyList<String>(), nestedNames(Array<Any>::class))
|
||||
|
||||
Vendored
+3
-1
@@ -1,10 +1,12 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
// IGNORE_BACKEND: JS, NATIVE, JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
// See KT-11258 Incorrect resolution sequence for Java field
|
||||
|
||||
//SHOULD BE enabled after KT-16616 fix
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+5
-5
@@ -16,10 +16,10 @@ open class TypeLiteral<T> {
|
||||
inline fun <reified T> typeLiteral(): TypeLiteral<T> = object : TypeLiteral<T>() {}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("class java.lang.String", typeLiteral<String>().type.toString())
|
||||
assertEquals("java.lang.String", (typeLiteral<String>().type as Class<*>).canonicalName)
|
||||
assertEquals("java.util.List<?>", typeLiteral<List<*>>().type.toString())
|
||||
assertEquals("java.lang.String[]", typeLiteral<Array<String>>().type.toString())
|
||||
assertEquals("java.lang.Integer[]", typeLiteral<Array<Int>>().type.toString())
|
||||
assertEquals("java.lang.String[][]", typeLiteral<Array<Array<String>>>().type.toString())
|
||||
assertEquals("java.lang.String[]", (typeLiteral<Array<String>>().type as Class<*>).canonicalName)
|
||||
assertEquals("java.lang.Integer[]", (typeLiteral<Array<Int>>().type as Class<*>).canonicalName)
|
||||
assertEquals("java.lang.String[][]", (typeLiteral<Array<Array<String>>>().type as Class<*>).canonicalName)
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
// See KT-11258 Incorrect resolution sequence for Java field
|
||||
|
||||
//SHOULD BE deleted after KT-16616 fix
|
||||
import java.util.*
|
||||
|
||||
fun box(): String {
|
||||
listOf(
|
||||
ArrayList::class,
|
||||
LinkedList::class,
|
||||
AbstractList::class,
|
||||
HashSet::class,
|
||||
TreeSet::class,
|
||||
HashMap::class,
|
||||
TreeMap::class,
|
||||
AbstractMap::class,
|
||||
AbstractMap.SimpleEntry::class
|
||||
).map {
|
||||
it.members.map(Any::toString)
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
interface ImmutableCollection<out E> : Collection<E> {
|
||||
fun add(element: @UnsafeVariance E): ImmutableCollection<E>
|
||||
fun addAll(elements: Collection<@UnsafeVariance E>): ImmutableCollection<E>
|
||||
fun remove(element: @UnsafeVariance E): ImmutableCollection<E>
|
||||
}
|
||||
|
||||
class ImmutableCollectionmpl<E> : ImmutableCollection<E> {
|
||||
override val size: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
|
||||
override fun contains(element: E): Boolean {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<E>): Boolean {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<E> {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun add(element: E): ImmutableCollection<E> = this
|
||||
override fun addAll(elements: Collection<E>): ImmutableCollection<E> = this
|
||||
override fun remove(element: E): ImmutableCollection<E> = this
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = ImmutableCollectionmpl<String>()
|
||||
if (c.remove("") !== c) return "fail 1"
|
||||
if (c.add("") !== c) return "fail 2"
|
||||
if (c.addAll(java.util.ArrayList()) !== c) return "fail 3"
|
||||
|
||||
val method = c.javaClass.methods.single { it.name == "remove" && it.returnType == Boolean::class.javaPrimitiveType }
|
||||
|
||||
try {
|
||||
method.invoke(c, "")
|
||||
return "fail 4"
|
||||
} catch (e: java.lang.reflect.InvocationTargetException) {
|
||||
if (e.cause!!.message != "Operation is not supported for read-only collection") return "fail 5: ${e.cause!!.message}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
void foo(String s, int i) {}
|
||||
|
||||
static void bar(J j) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf(null, "arg0", "arg1"), J::foo.parameters.map { it.name })
|
||||
assertEquals(listOf("arg0"), J::bar.parameters.map { it.name })
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
@kotlin.Metadata
|
||||
public interface ImmutableCollection {
|
||||
public abstract @org.jetbrains.annotations.NotNull method add(p0: java.lang.Object): ImmutableCollection
|
||||
public abstract @org.jetbrains.annotations.NotNull method addAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): ImmutableCollection
|
||||
public abstract @org.jetbrains.annotations.NotNull method remove(p0: java.lang.Object): ImmutableCollection
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ImmutableCollectionmpl {
|
||||
public method <init>(): void
|
||||
public @org.jetbrains.annotations.NotNull method add(p0: java.lang.Object): ImmutableCollection
|
||||
public method add(p0: java.lang.Object): boolean
|
||||
public @org.jetbrains.annotations.NotNull method addAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): ImmutableCollection
|
||||
public method addAll(p0: java.util.Collection): boolean
|
||||
public method clear(): void
|
||||
public method contains(p0: java.lang.Object): boolean
|
||||
public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean
|
||||
public method getSize(): int
|
||||
public method isEmpty(): boolean
|
||||
public @org.jetbrains.annotations.NotNull method iterator(): java.util.Iterator
|
||||
public @org.jetbrains.annotations.NotNull method remove(p0: java.lang.Object): ImmutableCollection
|
||||
public method remove(p0: java.lang.Object): boolean
|
||||
public method removeAll(p0: java.util.Collection): boolean
|
||||
public method retainAll(p0: java.util.Collection): boolean
|
||||
public final method size(): int
|
||||
public method toArray(): java.lang.Object[]
|
||||
public method toArray(p0: java.lang.Object[]): java.lang.Object[]
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ImmutableRemoveKt {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
@kotlin.Metadata
|
||||
public final class KKt {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
Reference in New Issue
Block a user