Create special descriptor for an object corresponding to type alias.
This commit is contained in:
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForTypeAliasObject
|
||||
import org.jetbrains.kotlin.resolve.coroutine.CoroutineReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.coroutine.createCoroutineSuspensionFunctionView
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
||||
@@ -273,7 +274,12 @@ private fun ResolutionScope.getContributedObjectVariables(name: Name, location:
|
||||
fun getFakeDescriptorForObject(classifier: ClassifierDescriptor?): FakeCallableDescriptorForObject? =
|
||||
when (classifier) {
|
||||
is TypeAliasDescriptor ->
|
||||
getFakeDescriptorForObject(classifier.classDescriptor)
|
||||
classifier.classDescriptor?.let { classDescriptor ->
|
||||
if (classDescriptor.hasClassValueDescriptor)
|
||||
FakeCallableDescriptorForTypeAliasObject(classifier)
|
||||
else
|
||||
null
|
||||
}
|
||||
is ClassDescriptor ->
|
||||
if (classifier.hasClassValueDescriptor)
|
||||
FakeCallableDescriptorForObject(classifier)
|
||||
|
||||
+4
-2
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.*
|
||||
|
||||
class FakeCallableDescriptorForObject(
|
||||
open class FakeCallableDescriptorForObject(
|
||||
val classDescriptor: ClassDescriptor
|
||||
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
|
||||
|
||||
@@ -34,7 +34,9 @@ class FakeCallableDescriptorForObject(
|
||||
|
||||
}
|
||||
|
||||
fun getReferencedDescriptor(): ClassDescriptor = classDescriptor.getClassObjectReferenceTarget()
|
||||
open fun getReferencedDescriptor(): ClassifierDescriptorWithTypeParameters = classDescriptor.getClassObjectReferenceTarget()
|
||||
|
||||
fun getReferencedObject(): ClassDescriptor = classDescriptor.getClassObjectReferenceTarget()
|
||||
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.util
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||
|
||||
class FakeCallableDescriptorForTypeAliasObject(val typeAliasDescriptor: TypeAliasDescriptor) :
|
||||
FakeCallableDescriptorForObject(typeAliasDescriptor.classDescriptor!!) {
|
||||
override fun getReferencedDescriptor() =
|
||||
typeAliasDescriptor
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FakeCallableDescriptorForTypeAliasObject &&
|
||||
typeAliasDescriptor == other.typeAliasDescriptor
|
||||
|
||||
override fun hashCode(): Int =
|
||||
typeAliasDescriptor.hashCode()
|
||||
}
|
||||
Reference in New Issue
Block a user