Change return type of KtScope.getProperties()
This commit is contained in:
@@ -78,7 +78,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return if (call.getValueArgumentList() == null && call.getValueArguments().isEmpty()) {
|
||||
listOf(createDynamicProperty(owner, name, call))
|
||||
}
|
||||
|
||||
+6
-9
@@ -17,10 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
import com.google.common.collect.Sets
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -51,7 +48,7 @@ protected constructor(
|
||||
protected val storageManager: StorageManager = c.storageManager
|
||||
private val classDescriptors: MemoizedFunctionToNotNull<Name, List<ClassDescriptor>> = storageManager.createMemoizedFunction { resolveClassDescriptor(it) }
|
||||
private val functionDescriptors: MemoizedFunctionToNotNull<Name, Collection<FunctionDescriptor>> = storageManager.createMemoizedFunction { doGetFunctions(it) }
|
||||
private val propertyDescriptors: MemoizedFunctionToNotNull<Name, Collection<VariableDescriptor>> = storageManager.createMemoizedFunction { doGetProperties(it) }
|
||||
private val propertyDescriptors: MemoizedFunctionToNotNull<Name, Collection<PropertyDescriptor>> = storageManager.createMemoizedFunction { doGetProperties(it) }
|
||||
|
||||
private fun resolveClassDescriptor(name: Name): List<ClassDescriptor> {
|
||||
return declarationProvider.getClassOrObjectDeclarations(name).map {
|
||||
@@ -97,13 +94,13 @@ protected constructor(
|
||||
|
||||
protected abstract fun getNonDeclaredFunctions(name: Name, result: MutableSet<FunctionDescriptor>)
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return propertyDescriptors(name)
|
||||
}
|
||||
|
||||
public fun doGetProperties(name: Name): Collection<VariableDescriptor> {
|
||||
val result = LinkedHashSet<VariableDescriptor>()
|
||||
public fun doGetProperties(name: Name): Collection<PropertyDescriptor> {
|
||||
val result = LinkedHashSet<PropertyDescriptor>()
|
||||
|
||||
val declarations = declarationProvider.getPropertyDeclarations(name)
|
||||
for (propertyDeclaration in declarations) {
|
||||
@@ -122,7 +119,7 @@ protected constructor(
|
||||
return result.toReadOnlyList()
|
||||
}
|
||||
|
||||
protected abstract fun getNonDeclaredProperties(name: Name, result: MutableSet<VariableDescriptor>)
|
||||
protected abstract fun getNonDeclaredProperties(name: Name, result: MutableSet<PropertyDescriptor>)
|
||||
|
||||
protected fun computeDescriptorsFromDeclaredElements(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
|
||||
+7
-9
@@ -152,7 +152,7 @@ public open class LazyClassMemberScope(
|
||||
val properties = getProperties(parameter.name, location)
|
||||
if (properties.isEmpty()) continue
|
||||
|
||||
val property = properties.iterator().next() as PropertyDescriptor
|
||||
val property = properties.iterator().next()
|
||||
|
||||
++componentIndex
|
||||
|
||||
@@ -175,7 +175,7 @@ public open class LazyClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
// TODO: this should be handled by lazy property descriptors
|
||||
val properties = super.getProperties(name, location)
|
||||
resolveUnknownVisibilitiesForMembers(properties as Collection<CallableMemberDescriptor>)
|
||||
@@ -191,20 +191,19 @@ public open class LazyClassMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
protected override fun getNonDeclaredProperties(name: Name, result: MutableSet<VariableDescriptor>) {
|
||||
protected override fun getNonDeclaredProperties(name: Name, result: MutableSet<PropertyDescriptor>) {
|
||||
createPropertiesFromPrimaryConstructorParameters(name, result)
|
||||
|
||||
// Members from supertypes
|
||||
val fromSupertypes = ArrayList<PropertyDescriptor>()
|
||||
for (supertype in thisDescriptor.typeConstructor.supertypes) {
|
||||
fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED) as Collection<PropertyDescriptor>)
|
||||
fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
}
|
||||
result.addAll(generateDelegatingDescriptors(name, EXTRACT_PROPERTIES, result))
|
||||
generateFakeOverrides(name, fromSupertypes, result as MutableCollection<PropertyDescriptor>, javaClass<PropertyDescriptor>())
|
||||
generateFakeOverrides(name, fromSupertypes, result, javaClass<PropertyDescriptor>())
|
||||
}
|
||||
|
||||
protected open fun createPropertiesFromPrimaryConstructorParameters(name: Name, result: MutableSet<VariableDescriptor>) {
|
||||
protected open fun createPropertiesFromPrimaryConstructorParameters(name: Name, result: MutableSet<PropertyDescriptor>) {
|
||||
val classInfo = declarationProvider.getOwnerInfo()
|
||||
|
||||
// From primary constructor parameters
|
||||
@@ -322,8 +321,7 @@ public open class LazyClassMemberScope(
|
||||
|
||||
private val EXTRACT_PROPERTIES: MemberExtractor<PropertyDescriptor> = object : MemberExtractor<PropertyDescriptor> {
|
||||
override fun extract(extractFrom: KotlinType, name: Name): Collection<PropertyDescriptor> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED) as Collection<PropertyDescriptor>
|
||||
return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class LazyPackageMemberScope(
|
||||
// No extra functions
|
||||
}
|
||||
|
||||
override fun getNonDeclaredProperties(name: Name, result: MutableSet<VariableDescriptor>) {
|
||||
override fun getNonDeclaredProperties(name: Name, result: MutableSet<PropertyDescriptor>) {
|
||||
// No extra properties
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ public class LazyScriptClassMemberScope protected constructor(
|
||||
|
||||
private fun getPropertiesForScriptParameters() = getPrimaryConstructor()!!.valueParameters.flatMap { getProperties(it.name, NoLookupLocation.FOR_SCRIPT) }
|
||||
|
||||
override fun getNonDeclaredProperties(name: Name, result: MutableSet<VariableDescriptor>) {
|
||||
override fun getNonDeclaredProperties(name: Name, result: MutableSet<PropertyDescriptor>) {
|
||||
super.getNonDeclaredProperties(name, result)
|
||||
|
||||
if (name.asString() == ScriptDescriptor.LAST_EXPRESSION_VALUE_FIELD_NAME) {
|
||||
@@ -60,7 +60,7 @@ public class LazyScriptClassMemberScope protected constructor(
|
||||
|
||||
public fun getScriptResultProperty(): PropertyDescriptor = scriptResultProperty()
|
||||
|
||||
override fun createPropertiesFromPrimaryConstructorParameters(name: Name, result: MutableSet<VariableDescriptor>) {
|
||||
override fun createPropertiesFromPrimaryConstructorParameters(name: Name, result: MutableSet<PropertyDescriptor>) {
|
||||
val scriptInfo = declarationProvider.getOwnerInfo() as JetScriptInfo
|
||||
|
||||
// From primary constructor parameters
|
||||
|
||||
Reference in New Issue
Block a user