Fix mutable collection stub methods generation for corner case
The problem is that `override fun remove(element: E): CollectionWithRemove<E>` seems to be illegal from Java's point of view, while it's OK for JVM These declarations have the same signature (return type is isgnored) - override fun remove(element: E): CollectionWithRemove<E> - override fun remove(element: E): Boolean When we meet such declaration we choose random declaration for fake override in synthetic class that may lead to signature clash
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
@kotlin.Metadata
|
||||
public interface ImmutableCollection {
|
||||
public abstract @org.jetbrains.annotations.NotNull method add(p0: java.lang.Object): ImmutableCollection
|
||||
public abstract method add(p0: java.lang.Object): boolean
|
||||
public abstract @org.jetbrains.annotations.NotNull method addAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): ImmutableCollection
|
||||
public abstract method addAll(p0: java.util.Collection): boolean
|
||||
public abstract method clear(): void
|
||||
public abstract method iterator(): java.util.Iterator
|
||||
public abstract @org.jetbrains.annotations.NotNull method remove(p0: java.lang.Object): ImmutableCollection
|
||||
public abstract method remove(p0: java.lang.Object): boolean
|
||||
public abstract method removeAll(p0: java.util.Collection): boolean
|
||||
public abstract method retainAll(p0: java.util.Collection): boolean
|
||||
}
|
||||
|
||||
@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[]
|
||||
}
|
||||
Reference in New Issue
Block a user