Minor, move SpecialNames.isSafeIdentifier check a little earlier
This commit is contained in:
+3
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
@@ -47,6 +48,8 @@ class JvmPackageScope(
|
||||
}
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
if (!SpecialNames.isSafeIdentifier(name)) return null
|
||||
|
||||
recordLookup(location, name)
|
||||
|
||||
val javaClassifier = javaScope.getContributedClassifier(name, location)
|
||||
|
||||
+5
-8
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
|
||||
@@ -103,19 +102,17 @@ class LazyJavaPackageScope(
|
||||
override fun hashCode() = name.hashCode()
|
||||
}
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = findClassifier(name, null)
|
||||
|
||||
private fun findClassifier(name: Name, javaClass: JavaClass?): ClassDescriptor? {
|
||||
if (!SpecialNames.isSafeIdentifier(name)) return null
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassDescriptor? {
|
||||
val knownClassNamesInPackage = knownClassNamesInPackage()
|
||||
if (javaClass == null && knownClassNamesInPackage != null && name.asString() !in knownClassNamesInPackage) {
|
||||
if (knownClassNamesInPackage != null && name.asString() !in knownClassNamesInPackage) {
|
||||
return null
|
||||
}
|
||||
|
||||
return classes(FindClassRequest(name, javaClass))
|
||||
return findClassifier(name, null)
|
||||
}
|
||||
|
||||
private fun findClassifier(name: Name, javaClass: JavaClass?): ClassDescriptor? = classes(FindClassRequest(name, javaClass))
|
||||
|
||||
internal fun findClassifierByJavaClass(javaClass: JavaClass) = findClassifier(javaClass.name, javaClass)
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
|
||||
|
||||
+1
-3
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents
|
||||
@@ -49,8 +48,7 @@ open class DeserializedPackageMemberScope(
|
||||
= computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
if (SpecialNames.isSafeIdentifier(name) &&
|
||||
(name in classNames || c.components.fictitiousClassDescriptorFactory.shouldCreateClass(packageFqName, name))) {
|
||||
if (name in classNames || c.components.fictitiousClassDescriptorFactory.shouldCreateClass(packageFqName, name)) {
|
||||
return getClassDescriptor(name)
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user