From 7e95eee9f17cfcbd481e4d1b251630296b6f8567 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 20 Mar 2018 01:23:31 +0300 Subject: [PATCH] FIR: Introduce new classifier descriptors aka 'cones' --- .../descriptors/ConeClassifierDescriptor.kt | 31 +++++++++++++++++++ .../descriptors/AbstractFirBasedDescriptor.kt | 19 ++++++++++++ .../kotlin/fir/FirBasedDescriptor.kt | 13 ++++++++ .../kotlin/fir/FirDescriptorOwner.kt | 10 ++++++ 4 files changed, 73 insertions(+) create mode 100644 compiler/fir/cones/src/org/jetbrains/kotlin/fir/descriptors/ConeClassifierDescriptor.kt create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/descriptors/AbstractFirBasedDescriptor.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBasedDescriptor.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDescriptorOwner.kt diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/descriptors/ConeClassifierDescriptor.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/descriptors/ConeClassifierDescriptor.kt new file mode 100644 index 00000000000..f890ba35fff --- /dev/null +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/descriptors/ConeClassifierDescriptor.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.descriptors + +import org.jetbrains.kotlin.fir.UnambiguousFqName +import org.jetbrains.kotlin.fir.types.ConeKotlinType + + +interface ConeDescriptor + +interface ConeClassifierDescriptor : ConeDescriptor + +interface ConeClassifierDescriptorWithTypeParameters : ConeClassifierDescriptor { + val typeParameters: List + + val fqName: UnambiguousFqName +} + +interface ConeTypeParameterDescriptor : ConeClassifierDescriptor + +interface ConeTypeAliasDescriptor : ConeClassifierDescriptorWithTypeParameters { + val expandedType: ConeKotlinType +} + +interface ConeClassDescriptor : ConeClassifierDescriptorWithTypeParameters { + val superTypes: List + val nestedClassifiers: List +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/descriptors/AbstractFirBasedDescriptor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/descriptors/AbstractFirBasedDescriptor.kt new file mode 100644 index 00000000000..e42b098626a --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/descriptors/AbstractFirBasedDescriptor.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.descriptors + +import org.jetbrains.kotlin.fir.FirBasedDescriptor +import org.jetbrains.kotlin.fir.FirDescriptorOwner +import org.jetbrains.kotlin.fir.FirElement + +abstract class AbstractFirBasedDescriptor : FirBasedDescriptor where E : FirElement, E : FirDescriptorOwner { + + override lateinit var fir: E + + override fun bind(e: E) { + fir = e + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBasedDescriptor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBasedDescriptor.kt new file mode 100644 index 00000000000..42fe2a60f6b --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirBasedDescriptor.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir + +import org.jetbrains.kotlin.fir.descriptors.ConeDescriptor + +interface FirBasedDescriptor : ConeDescriptor where E : FirElement, E : FirDescriptorOwner { + val fir: E + fun bind(e: E) +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDescriptorOwner.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDescriptorOwner.kt new file mode 100644 index 00000000000..c9570fb214d --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDescriptorOwner.kt @@ -0,0 +1,10 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir + +interface FirDescriptorOwner where TElem : FirElement, TElem : FirDescriptorOwner { + val descriptor: FirBasedDescriptor +} \ No newline at end of file