[FIR TEST]: two more tests on forEach potential ambiguity (both passing)
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
import java.util.*
|
||||||
|
import java.util.function.BiConsumer
|
||||||
|
|
||||||
|
private val DEBUG = true
|
||||||
|
|
||||||
|
abstract class SomeHashTable<K : Any, V : Any> : AbstractMutableMap<K, V>() {
|
||||||
|
override fun forEach(action: BiConsumer<in K, in V>) {}
|
||||||
|
|
||||||
|
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
|
||||||
|
get() {
|
||||||
|
if (DEBUG) {
|
||||||
|
return Collections.unmodifiableSet(
|
||||||
|
mutableSetOf<MutableMap.MutableEntry<K, V>>().apply {
|
||||||
|
forEach { key, value -> add(Entry(key, value)) }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Entry<K, V>(override val key: K, override val value: V) : MutableMap.MutableEntry<K, V> {
|
||||||
|
override fun setValue(newValue: V): V = throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
FILE: hashTableWithForEach.kt
|
||||||
|
private final val DEBUG: R|kotlin/Boolean| = Boolean(true)
|
||||||
|
private get(): R|kotlin/Boolean|
|
||||||
|
public abstract class SomeHashTable<K : R|kotlin/Any|, V : R|kotlin/Any|> : R|kotlin/collections/AbstractMutableMap<K, V>| {
|
||||||
|
public constructor<K : R|kotlin/Any|, V : R|kotlin/Any|>(): R|SomeHashTable<K, V>| {
|
||||||
|
super<R|kotlin/collections/AbstractMutableMap<K, V>|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public open override fun forEach(action: R|java/util/function/BiConsumer<in K, in V>|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
|
||||||
|
public open override val entries: R|kotlin/collections/MutableSet<kotlin/collections/MutableMap.MutableEntry<K, V>>|
|
||||||
|
public get(): R|kotlin/collections/MutableSet<kotlin/collections/MutableMap.MutableEntry<K, V>>| {
|
||||||
|
when () {
|
||||||
|
R|/DEBUG| -> {
|
||||||
|
^ Q|java/util/Collections|.R|java/util/Collections.unmodifiableSet|<R|kotlin/collections/MutableMap.MutableEntry<K, V>|>(R|kotlin/collections/mutableSetOf|<R|kotlin/collections/MutableMap.MutableEntry<K, V>|>().R|kotlin/apply|<R|kotlin/collections/MutableSet<kotlin/collections/MutableMap.MutableEntry<K, V>>|>(<L> = apply@fun R|kotlin/collections/MutableSet<kotlin/collections/MutableMap.MutableEntry<K, V>>|.<anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
|
this@R|/SomeHashTable|.R|FakeOverride</SomeHashTable.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|K!|, value: R|V!|): R|kotlin/Unit| {
|
||||||
|
this@R|kotlin/collections/MutableSet|.R|FakeOverride<kotlin/collections/MutableSet.add: R|kotlin/Boolean|>|(R|/SomeHashTable.Entry.Entry|<R|K|, R|V|>(R|<local>/key|, R|<local>/value|))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw R|java/lang/UnsupportedOperationException.UnsupportedOperationException|()
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class Entry<K, V> : R|kotlin/collections/MutableMap.MutableEntry<K, V>| {
|
||||||
|
public constructor<K, V>(key: R|K|, value: R|V|): R|SomeHashTable.Entry<K, V>| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final override val key: R|K| = R|<local>/key|
|
||||||
|
public get(): R|K|
|
||||||
|
|
||||||
|
public final override val value: R|V| = R|<local>/value|
|
||||||
|
public get(): R|V|
|
||||||
|
|
||||||
|
public final override fun setValue(newValue: R|V|): R|V| {
|
||||||
|
^setValue throw R|java/lang/UnsupportedOperationException.UnsupportedOperationException|()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import java.util.*
|
||||||
|
|
||||||
|
interface ArgsInfo
|
||||||
|
|
||||||
|
class ArgsInfoImpl : ArgsInfo {
|
||||||
|
constructor(info: ArgsInfo) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias Arguments = Map<String, ArgsInfo>
|
||||||
|
|
||||||
|
fun Arguments.deepCopy(): Arguments {
|
||||||
|
val result = HashMap<String, ArgsInfo>()
|
||||||
|
this.forEach { key, value -> result[key] = ArgsInfoImpl(value) }
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FILE: typeAliasWithForEach.kt
|
||||||
|
public abstract interface ArgsInfo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public final class ArgsInfoImpl : R|ArgsInfo| {
|
||||||
|
public constructor(info: R|ArgsInfo|): R|ArgsInfoImpl| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final typealias Arguments = R|kotlin/collections/Map<kotlin/String, ArgsInfo>|
|
||||||
|
public final fun R|Arguments|.deepCopy(): R|Arguments| {
|
||||||
|
lval result: R|java/util/HashMap<kotlin/String, ArgsInfo>| = R|java/util/HashMap.HashMap|<R|kotlin/String|, R|ArgsInfo|>()
|
||||||
|
this@R|/deepCopy|.R|FakeOverride<java/util/Map.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|kotlin/String!|, value: R|ArgsInfo!|): R|kotlin/Unit| {
|
||||||
|
R|<local>/result|.R|kotlin/collections/set|<R|kotlin/String|, R|ArgsInfo|>(R|<local>/key|, R|/ArgsInfoImpl.ArgsInfoImpl|(R|<local>/value|))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
^deepCopy R|<local>/result|
|
||||||
|
}
|
||||||
Generated
+10
@@ -98,6 +98,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
|||||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/hashSet.kt");
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/hashSet.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hashTableWithForEach.kt")
|
||||||
|
public void testHashTableWithForEach() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/hashTableWithForEach.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("helloWorld.kt")
|
@TestMetadata("helloWorld.kt")
|
||||||
public void testHelloWorld() throws Exception {
|
public void testHelloWorld() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/helloWorld.kt");
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/helloWorld.kt");
|
||||||
@@ -173,6 +178,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
|||||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/typeAliasDeserialization.kt");
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/typeAliasDeserialization.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeAliasWithForEach.kt")
|
||||||
|
public void testTypeAliasWithForEach() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/typeAliasWithForEach.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("typeParameterDerived.kt")
|
@TestMetadata("typeParameterDerived.kt")
|
||||||
public void testTypeParameterDerived() throws Exception {
|
public void testTypeParameterDerived() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/typeParameterDerived.kt");
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/typeParameterDerived.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user