Add equality constraints without subtyping
^KT-42195 Fixed ^KT-41741 Fixed
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: Simple.java
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -CAST_NEVER_SUCCEEDS -UNUSED_VARIABLE
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Simple<K, V, C extends E, E extends Collection<V>> {
|
||||
public Simple(Map<K, C> backingMap, Supplier<? extends C> innerCollectionCreator) {
|
||||
// TODO
|
||||
}
|
||||
public final void add(K key, V value) {
|
||||
//TODO
|
||||
}
|
||||
public static class ListSimple<K, V> extends Simple<K, V, List<V>, List<V>> {
|
||||
public ListSimple(Map<K, List<V>> backingMap, Supplier<? extends List<V>> innerCollectionCreator) {
|
||||
super(backingMap, innerCollectionCreator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import java.util.*
|
||||
|
||||
fun <K, V, C : E, E : Collection<V>, B: Simple<K, V, C, E>> Iterable<V>.groupByTo(destination: B, keySelector: (V) -> K) = null as B
|
||||
|
||||
enum class Format { Foo, Bar }
|
||||
|
||||
class Instance(val format: Format)
|
||||
|
||||
fun main(x: List<Instance>) {
|
||||
val doesntWork = x.groupByTo(
|
||||
Simple.ListSimple(EnumMap<Format, List<Instance>>(Format::class.java), ::LinkedList)
|
||||
) { it.format } // Internal Error occurred while analyzing this expression
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ x: kotlin.collections.List<Instance>): kotlin.Unit
|
||||
public fun </*0*/ K, /*1*/ V, /*2*/ C : E, /*3*/ E : kotlin.collections.Collection<V>, /*4*/ B : Simple<K, V, C, E>> kotlin.collections.Iterable<V>.groupByTo(/*0*/ destination: B, /*1*/ keySelector: (V) -> K): B
|
||||
|
||||
public final enum class Format : kotlin.Enum<Format> {
|
||||
enum entry Foo
|
||||
|
||||
enum entry Bar
|
||||
|
||||
private constructor Format()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Format): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<Format!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Format
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<Format>
|
||||
}
|
||||
|
||||
public final class Instance {
|
||||
public constructor Instance(/*0*/ format: Format)
|
||||
public final val format: Format
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Simple</*0*/ K : kotlin.Any!, /*1*/ V : kotlin.Any!, /*2*/ C : E!, /*3*/ E : kotlin.collections.(Mutable)Collection<V!>!> {
|
||||
public constructor Simple</*0*/ K : kotlin.Any!, /*1*/ V : kotlin.Any!, /*2*/ C : E!, /*3*/ E : kotlin.collections.(Mutable)Collection<V!>!>(/*0*/ backingMap: kotlin.collections.(Mutable)Map<K!, C!>!, /*1*/ innerCollectionCreator: java.util.function.Supplier<out C!>!)
|
||||
public final fun add(/*0*/ key: K!, /*1*/ value: V!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public open class ListSimple</*0*/ K : kotlin.Any!, /*1*/ V : kotlin.Any!> : Simple<K!, V!, kotlin.collections.(Mutable)List<V!>!, kotlin.collections.(Mutable)List<V!>!> {
|
||||
public constructor ListSimple</*0*/ K : kotlin.Any!, /*1*/ V : kotlin.Any!>(/*0*/ backingMap: kotlin.collections.(Mutable)Map<K!, kotlin.collections.(Mutable)List<V!>!>!, /*1*/ innerCollectionCreator: java.util.function.Supplier<out kotlin.collections.(Mutable)List<V!>!>!)
|
||||
public final override /*1*/ /*fake_override*/ fun add(/*0*/ key: K!, /*1*/ value: V!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
sealed class Tree<TIndex, out TCommon, out TInner, out TLeaf> {
|
||||
abstract val value: TCommon
|
||||
abstract val children: Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
|
||||
|
||||
data class Inner<TIndex, TCommon, TInner, TLeaf>(
|
||||
override val value: TCommon,
|
||||
val innerValue: TInner,
|
||||
override val children: Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
|
||||
) : Tree<TIndex, TCommon, TInner, TLeaf>()
|
||||
|
||||
data class Leaf<TIndex, TCommon, TLeaf>(
|
||||
override val value: TCommon,
|
||||
val leafValue: TLeaf
|
||||
) : Tree<TIndex, TCommon, Nothing, TLeaf>() {
|
||||
override val children: Map<TIndex, Tree<TIndex, TCommon, Nothing, TLeaf>> get() = emptyMap()
|
||||
}
|
||||
}
|
||||
|
||||
val tree = Tree.Inner(
|
||||
"root",
|
||||
Unit,
|
||||
mapOf(
|
||||
1 to Tree.Leaf("1", 1),
|
||||
2 to Tree.Inner(
|
||||
"2",
|
||||
Unit,
|
||||
mapOf(
|
||||
1 to Tree.Leaf("21", 2),
|
||||
2 to Tree.Inner(
|
||||
"22",
|
||||
Unit,
|
||||
mapOf(1 to Tree.Leaf("221", 3))
|
||||
),
|
||||
3 to Tree.Leaf("23", 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package
|
||||
|
||||
public val tree: Tree.Inner<kotlin.Int, kotlin.String, kotlin.Unit, kotlin.Int>
|
||||
|
||||
public sealed class Tree</*0*/ TIndex, /*1*/ out TCommon, /*2*/ out TInner, /*3*/ out TLeaf> {
|
||||
private constructor Tree</*0*/ TIndex, /*1*/ out TCommon, /*2*/ out TInner, /*3*/ out TLeaf>()
|
||||
public abstract val children: kotlin.collections.Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
|
||||
public abstract val value: TCommon
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final data class Inner</*0*/ TIndex, /*1*/ TCommon, /*2*/ TInner, /*3*/ TLeaf> : Tree<TIndex, TCommon, TInner, TLeaf> {
|
||||
public constructor Inner</*0*/ TIndex, /*1*/ TCommon, /*2*/ TInner, /*3*/ TLeaf>(/*0*/ value: TCommon, /*1*/ innerValue: TInner, /*2*/ children: kotlin.collections.Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>)
|
||||
public open override /*1*/ val children: kotlin.collections.Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
|
||||
public final val innerValue: TInner
|
||||
public open override /*1*/ val value: TCommon
|
||||
public final operator /*synthesized*/ fun component1(): TCommon
|
||||
public final operator /*synthesized*/ fun component2(): TInner
|
||||
public final operator /*synthesized*/ fun component3(): kotlin.collections.Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>>
|
||||
public final /*synthesized*/ fun copy(/*0*/ value: TCommon = ..., /*1*/ innerValue: TInner = ..., /*2*/ children: kotlin.collections.Map<TIndex, Tree<TIndex, TCommon, TInner, TLeaf>> = ...): Tree.Inner<TIndex, TCommon, TInner, TLeaf>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final data class Leaf</*0*/ TIndex, /*1*/ TCommon, /*2*/ TLeaf> : Tree<TIndex, TCommon, kotlin.Nothing, TLeaf> {
|
||||
public constructor Leaf</*0*/ TIndex, /*1*/ TCommon, /*2*/ TLeaf>(/*0*/ value: TCommon, /*1*/ leafValue: TLeaf)
|
||||
public open override /*1*/ val children: kotlin.collections.Map<TIndex, Tree<TIndex, TCommon, kotlin.Nothing, TLeaf>>
|
||||
public final val leafValue: TLeaf
|
||||
public open override /*1*/ val value: TCommon
|
||||
public final operator /*synthesized*/ fun component1(): TCommon
|
||||
public final operator /*synthesized*/ fun component2(): TLeaf
|
||||
public final /*synthesized*/ fun copy(/*0*/ value: TCommon = ..., /*1*/ leafValue: TLeaf = ...): Tree.Leaf<TIndex, TCommon, TLeaf>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user