mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 15:53:46 +00:00
Use wrappers around java.util.* to emulate kotlin.collection.* behaviour
Backend: If kotlin class extends kotlin.collection.List
write it as it's super interface (light class mode only)
IDE: Provide wrapper classes to java resolve
that try to emulate backend behaviour
For example if kotlin class implements kotlin.collections.Map,
we provide a superinterface that has abstract 'getEntries' method
and 'entrySet' method that is considered default.
In reality all those methods are generated in the class itself.
In IDE supporting this case without hacks is not feasible performance-wise
since kotlin.collection.* may not be an immediate supertype and we need
to compute all supertypes just to calculate own methods of the class
This commit is contained in:
44
idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/UsingReadOnlyInterfaces.kt
vendored
Normal file
44
idea/testData/kotlinAndJavaChecker/javaAgainstKotlin/UsingReadOnlyInterfaces.kt
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
class A
|
||||
class B
|
||||
|
||||
// kotlin.collections.Collection
|
||||
interface ICollection<Elem> : Collection<Elem>
|
||||
abstract class CCollection<Elem> : Collection<Elem> by emptyList<Elem>()
|
||||
abstract class SCollection : Collection<String> by emptyList<String>()
|
||||
abstract class ACollection : Collection<A> by emptyList<A>()
|
||||
|
||||
// kotlin.collections.Iterable
|
||||
interface IIterable<Elem> : Iterable<Elem>
|
||||
abstract class CIterable<Elem> : Iterable<Elem> by emptyList<Elem>()
|
||||
abstract class SIterable : Iterable<String> by emptyList<String>()
|
||||
abstract class AIterable : Iterable<A> by emptyList<A>()
|
||||
|
||||
// kotlin.collections.List
|
||||
interface IList<Elem> : List<Elem>
|
||||
abstract class CList<Elem> : List<Elem> by emptyList<Elem>()
|
||||
abstract class SList : List<String> by emptyList<String>()
|
||||
abstract class AList : List<A> by emptyList<A>()
|
||||
|
||||
// kotlin.collections.Set
|
||||
interface ISet<Elem> : Set<Elem>
|
||||
abstract class CSet<Elem> : Set<Elem> by emptySet<Elem>()
|
||||
abstract class SSet : Set<String> by emptySet<String>()
|
||||
abstract class ASet : Set<A> by emptySet<A>()
|
||||
|
||||
// kotlin.collections.Iterator
|
||||
interface IIterator<Elem> : Iterator<Elem>
|
||||
abstract class CIterator<Elem> : Iterator<Elem> by emptyList<Elem>().iterator()
|
||||
abstract class SIterator : Iterator<String> by emptyList<String>().iterator()
|
||||
abstract class AIterator : Iterator<A> by emptyList<A>().iterator()
|
||||
|
||||
// kotlin.collections.Map
|
||||
interface IMap<KElem, VElem> : Map<KElem, VElem>
|
||||
abstract class CMap<KElem, VElem> : Map<KElem, VElem> by emptyMap<KElem, VElem>()
|
||||
abstract class SMap<VElem> : Map<String, VElem> by emptyMap<String, VElem>()
|
||||
abstract class ABMap : Map<A, B> by emptyMap<A, B>()
|
||||
|
||||
// kotlin.collections.Map.Entry
|
||||
interface IMapEntry<KElem, VElem> : Map.Entry<KElem, VElem>
|
||||
abstract class CMapEntry<KElem, VElem> : Map.Entry<KElem, VElem> by emptyMap<KElem, VElem>().entries.first()
|
||||
abstract class SMapEntry<VElem> : Map.Entry<String, VElem> by emptyMap<String, VElem>().entries.first()
|
||||
abstract class ABMapEntry : Map.Entry<A, B> by emptyMap<A, B>().entries.first()
|
||||
Reference in New Issue
Block a user