Determine underlying property of inline class by its name

Previous way to distinguish "primary constructor properties" from other
 properties wasn't correct for deserialized properties, because currently
 we don't have special information about this in metadata
This commit is contained in:
Mikhail Zarechenskiy
2018-06-14 17:49:33 +03:00
parent dbd72ae53b
commit 3f462659d2
6 changed files with 38 additions and 15 deletions
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.types.KotlinType
@@ -39,3 +40,10 @@ fun KotlinType.isNullableUnderlyingType(): Boolean {
return TypeUtils.isNullableType(underlyingType)
}
fun PropertyDescriptor.isUnderlyingPropertyOfInlineClass(): Boolean {
val containingDeclaration = this.containingDeclaration
if (!containingDeclaration.isInlineClass()) return false
return (containingDeclaration as ClassDescriptor).underlyingRepresentation()?.name == this.name
}