Load additional JDK functions into built-ins member scope
#KT-5990 Fixed #KT-7127 Fixed #KT-10370 Fixed
This commit is contained in:
+6
@@ -16,13 +16,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
interface AdditionalClassPartsProvider {
|
||||
fun getSupertypes(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType>
|
||||
fun getFunctions(name: Name, classDescriptor: DeserializedClassDescriptor): Collection<SimpleFunctionDescriptor>
|
||||
fun getFunctionsNames(classDescriptor: DeserializedClassDescriptor): Collection<Name>
|
||||
|
||||
object None : AdditionalClassPartsProvider {
|
||||
override fun getSupertypes(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType> = emptyList()
|
||||
override fun getFunctions(name: Name, classDescriptor: DeserializedClassDescriptor): Collection<SimpleFunctionDescriptor> = emptyList()
|
||||
override fun getFunctionsNames(classDescriptor: DeserializedClassDescriptor): Collection<Name> = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -199,6 +199,8 @@ class DeserializedClassDescriptor(
|
||||
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
|
||||
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
}
|
||||
|
||||
functions.addAll(c.components.additionalClassPartsProvider.getFunctions(name, this@DeserializedClassDescriptor))
|
||||
generateFakeOverrides(name, fromSupertypes, functions)
|
||||
}
|
||||
|
||||
@@ -229,7 +231,7 @@ class DeserializedClassDescriptor(
|
||||
override fun getNonDeclaredFunctionNames(location: LookupLocation): Set<Name> {
|
||||
return classDescriptor.typeConstructor.supertypes.flatMapTo(LinkedHashSet()) {
|
||||
it.memberScope.getContributedDescriptors().filterIsInstance<SimpleFunctionDescriptor>().map { it.name }
|
||||
}
|
||||
} + c.components.additionalClassPartsProvider.getFunctionsNames(this@DeserializedClassDescriptor)
|
||||
}
|
||||
|
||||
override fun getNonDeclaredVariableNames(location: LookupLocation): Set<Name> {
|
||||
|
||||
Reference in New Issue
Block a user