Simplified code
This commit is contained in:
@@ -19,18 +19,16 @@ package org.jetbrains.jet.lang.resolve.scopes
|
|||||||
import org.jetbrains.jet.lang.descriptors.*
|
import org.jetbrains.jet.lang.descriptors.*
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name
|
import org.jetbrains.jet.lang.resolve.name.Name
|
||||||
import org.jetbrains.jet.lang.types.TypeSubstitutor
|
import org.jetbrains.jet.lang.types.TypeSubstitutor
|
||||||
import org.jetbrains.jet.utils.Printer
|
|
||||||
import org.jetbrains.jet.utils.*
|
import org.jetbrains.jet.utils.*
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.Map
|
import kotlin.properties.Delegates
|
||||||
import kotlin.Collection
|
|
||||||
import kotlin.List
|
|
||||||
|
|
||||||
public class SubstitutingScope(private val workerScope: JetScope, private val substitutor: TypeSubstitutor) : JetScope {
|
public class SubstitutingScope(private val workerScope: JetScope, private val substitutor: TypeSubstitutor) : JetScope {
|
||||||
|
|
||||||
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null
|
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null
|
||||||
private var allDescriptors: Collection<DeclarationDescriptor>? = null
|
|
||||||
|
private val _allDescriptors by Delegates.lazy { substitute(workerScope.getAllDescriptors()) }
|
||||||
|
|
||||||
private fun <D : DeclarationDescriptor> substitute(descriptor: D?): D? {
|
private fun <D : DeclarationDescriptor> substitute(descriptor: D?): D? {
|
||||||
if (descriptor == null) return null
|
if (descriptor == null) return null
|
||||||
@@ -86,12 +84,7 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
|
|||||||
throw UnsupportedOperationException() // TODO
|
throw UnsupportedOperationException() // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAllDescriptors(): Collection<DeclarationDescriptor> {
|
override fun getAllDescriptors() = _allDescriptors
|
||||||
if (allDescriptors == null) {
|
|
||||||
allDescriptors = substitute(workerScope.getAllDescriptors())
|
|
||||||
}
|
|
||||||
return allDescriptors!!
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getOwnDeclaredDescriptors() = substitute(workerScope.getOwnDeclaredDescriptors())
|
override fun getOwnDeclaredDescriptors() = substitute(workerScope.getOwnDeclaredDescriptors())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user