code cleanup: core modules

This commit is contained in:
Dmitry Jemerov
2015-07-21 15:41:57 +02:00
parent 6a6f369e5d
commit aa1f6f2252
37 changed files with 62 additions and 65 deletions
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.JetType
public trait SamConversionResolver { public interface SamConversionResolver {
public companion object EMPTY : SamConversionResolver { public companion object EMPTY : SamConversionResolver {
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D) = null override fun <D : FunctionDescriptor> resolveSamAdapter(original: D) = null
override fun resolveSamConstructor(name: Name, scope: JetScope) = null override fun resolveSamConstructor(name: Name, scope: JetScope) = null
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import kotlin.properties.Delegates import kotlin.properties.Delegates
import javax.inject.Inject import javax.inject.Inject
public trait ModuleClassResolver { public interface ModuleClassResolver {
public fun resolveClass(javaClass: JavaClass): ClassDescriptor? public fun resolveClass(javaClass: JavaClass): ClassDescriptor?
} }
@@ -16,16 +16,15 @@
package org.jetbrains.kotlin.load.java.lazy.descriptors package org.jetbrains.kotlin.load.java.lazy.descriptors
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
import org.jetbrains.kotlin.load.java.structure.JavaPackage import org.jetbrains.kotlin.load.java.structure.JavaPackage
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
import kotlin.properties.Delegates
class LazyJavaPackageFragment( class LazyJavaPackageFragment(
private val c: LazyJavaResolverContext, private val c: LazyJavaResolverContext,
private val jPackage: JavaPackage private val jPackage: JavaPackage
) : PackageFragmentDescriptorImpl(c.module, jPackage.getFqName()) { ) : PackageFragmentDescriptorImpl(c.module, jPackage.getFqName()) {
private val scope by Delegates.lazy { LazyPackageFragmentScopeForJavaPackage(c, jPackage, this) } private val scope by lazy { LazyPackageFragmentScopeForJavaPackage(c, jPackage, this) }
override fun getMemberScope() = scope override fun getMemberScope() = scope
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils
import org.jetbrains.kotlin.utils.valuesToMap import org.jetbrains.kotlin.utils.valuesToMap
import java.util.HashSet import java.util.HashSet
trait MemberIndex { interface MemberIndex {
fun findMethodsByName(name: Name): Collection<JavaMethod> fun findMethodsByName(name: Name): Collection<JavaMethod>
fun getMethodNames(nameFilter: (Name) -> Boolean): Collection<Name> fun getMethodNames(nameFilter: (Name) -> Boolean): Collection<Name>
@@ -29,11 +29,11 @@ import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.utils.mapToIndex import org.jetbrains.kotlin.utils.mapToIndex
//TODO: (module refactoring) usages of this interface should be replaced by ModuleClassResolver //TODO: (module refactoring) usages of this interface should be replaced by ModuleClassResolver
trait LazyJavaClassResolver { interface LazyJavaClassResolver {
fun resolveClass(javaClass: JavaClass): ClassDescriptor? fun resolveClass(javaClass: JavaClass): ClassDescriptor?
} }
trait TypeParameterResolver { interface TypeParameterResolver {
object EMPTY : TypeParameterResolver { object EMPTY : TypeParameterResolver {
override fun resolveTypeParameter(javaTypeParameter: JavaTypeParameter): TypeParameterDescriptor? = null override fun resolveTypeParameter(javaTypeParameter: JavaTypeParameter): TypeParameterDescriptor? = null
} }
@@ -347,7 +347,7 @@ class LazyJavaTypeResolver(
} }
trait JavaTypeAttributes { interface JavaTypeAttributes {
val howThisTypeIsUsed: TypeUsage val howThisTypeIsUsed: TypeUsage
val howThisTypeIsUsedAccordingToAnnotations: TypeUsage val howThisTypeIsUsedAccordingToAnnotations: TypeUsage
val isMarkedNotNull: Boolean val isMarkedNotNull: Boolean
@@ -19,10 +19,10 @@ package org.jetbrains.kotlin.load.java.sources
import org.jetbrains.kotlin.load.java.structure.JavaElement import org.jetbrains.kotlin.load.java.structure.JavaElement
import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.SourceElement
public trait JavaSourceElementFactory { public interface JavaSourceElementFactory {
public fun source(javaElement: JavaElement): JavaSourceElement public fun source(javaElement: JavaElement): JavaSourceElement
} }
public trait JavaSourceElement: SourceElement { public interface JavaSourceElement: SourceElement {
public val javaElement: JavaElement public val javaElement: JavaElement
} }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.java.structure
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
public trait JavaPackage : JavaElement { public interface JavaPackage : JavaElement {
public fun getClasses(nameFilter: (Name) -> Boolean): Collection<JavaClass> public fun getClasses(nameFilter: (Name) -> Boolean): Collection<JavaClass>
public fun getSubPackages(): Collection<JavaPackage> public fun getSubPackages(): Collection<JavaPackage>
@@ -18,26 +18,26 @@ package org.jetbrains.kotlin.load.java.structure
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
public trait JavaAnnotationArgument { public interface JavaAnnotationArgument {
public val name: Name? public val name: Name?
} }
public trait JavaLiteralAnnotationArgument : JavaAnnotationArgument { public interface JavaLiteralAnnotationArgument : JavaAnnotationArgument {
public val value: Any? public val value: Any?
} }
public trait JavaArrayAnnotationArgument : JavaAnnotationArgument { public interface JavaArrayAnnotationArgument : JavaAnnotationArgument {
public fun getElements(): List<JavaAnnotationArgument> public fun getElements(): List<JavaAnnotationArgument>
} }
public trait JavaEnumValueAnnotationArgument : JavaAnnotationArgument { public interface JavaEnumValueAnnotationArgument : JavaAnnotationArgument {
public fun resolve(): JavaField? public fun resolve(): JavaField?
} }
public trait JavaClassObjectAnnotationArgument : JavaAnnotationArgument { public interface JavaClassObjectAnnotationArgument : JavaAnnotationArgument {
public fun getReferencedType(): JavaType public fun getReferencedType(): JavaType
} }
public trait JavaAnnotationAsAnnotationArgument : JavaAnnotationArgument { public interface JavaAnnotationAsAnnotationArgument : JavaAnnotationArgument {
public fun getAnnotation(): JavaAnnotation public fun getAnnotation(): JavaAnnotation
} }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.java.structure.JavaClass
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
public trait KotlinClassFinder { public interface KotlinClassFinder {
public fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass? public fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass?
public fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass? public fun findKotlinClass(javaClass: JavaClass): KotlinJvmBinaryClass?
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import java.lang.reflect.AnnotatedElement import java.lang.reflect.AnnotatedElement
public trait ReflectJavaAnnotationOwner : JavaAnnotationOwner { public interface ReflectJavaAnnotationOwner : JavaAnnotationOwner {
val element: AnnotatedElement val element: AnnotatedElement
override fun getAnnotations() = getAnnotations(element.getDeclaredAnnotations()) override fun getAnnotations() = getAnnotations(element.getDeclaredAnnotations())
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.load.java.JavaVisibilities
import org.jetbrains.kotlin.load.java.structure.JavaModifierListOwner import org.jetbrains.kotlin.load.java.structure.JavaModifierListOwner
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
public trait ReflectJavaModifierListOwner : JavaModifierListOwner { public interface ReflectJavaModifierListOwner : JavaModifierListOwner {
/* protected // KT-3029 */ val modifiers: Int /* protected // KT-3029 */ val modifiers: Int
override fun isAbstract() = Modifier.isAbstract(modifiers) override fun isAbstract() = Modifier.isAbstract(modifiers)
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap
import org.jetbrains.kotlin.resolve.ImportPath import org.jetbrains.kotlin.resolve.ImportPath
import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.TypeSubstitutor
public trait ModuleDescriptor : DeclarationDescriptor, ModuleParameters { public interface ModuleDescriptor : DeclarationDescriptor, ModuleParameters {
override fun getContainingDeclaration(): DeclarationDescriptor? = null override fun getContainingDeclaration(): DeclarationDescriptor? = null
public val builtIns: KotlinBuiltIns public val builtIns: KotlinBuiltIns
@@ -43,7 +43,7 @@ public trait ModuleDescriptor : DeclarationDescriptor, ModuleParameters {
public fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection<FqName> public fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection<FqName>
} }
trait ModuleParameters { interface ModuleParameters {
public val defaultImports: List<ImportPath> public val defaultImports: List<ImportPath>
public val platformToKotlinClassMap: PlatformToKotlinClassMap public val platformToKotlinClassMap: PlatformToKotlinClassMap
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScope
public trait PackageFragmentDescriptor : ClassOrPackageFragmentDescriptor { public interface PackageFragmentDescriptor : ClassOrPackageFragmentDescriptor {
override fun getContainingDeclaration(): ModuleDescriptor override fun getContainingDeclaration(): ModuleDescriptor
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
public trait PackageFragmentProvider { public interface PackageFragmentProvider {
public fun getPackageFragments(fqName: FqName): List<PackageFragmentDescriptor> public fun getPackageFragments(fqName: FqName): List<PackageFragmentDescriptor>
public fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection<FqName> public fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection<FqName>
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors.annotations
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.DescriptorUtils
public trait Annotations : Iterable<AnnotationDescriptor> { public interface Annotations : Iterable<AnnotationDescriptor> {
public fun isEmpty(): Boolean public fun isEmpty(): Boolean
@@ -54,7 +54,7 @@ class FilteredAnnotations(
if (fqNameFilter(fqName)) delegate.findExternalAnnotation(fqName) if (fqNameFilter(fqName)) delegate.findExternalAnnotation(fqName)
else null else null
override fun iterator() = delegate.sequence() override fun iterator() = delegate.asSequence()
.filter { annotation -> .filter { annotation ->
val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor() val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor()
descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName -> descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName ->
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.utils.sure import org.jetbrains.kotlin.utils.sure
import java.util.LinkedHashSet import java.util.LinkedHashSet
import kotlin.properties.Delegates
public class ModuleDescriptorImpl( public class ModuleDescriptorImpl(
moduleName: Name, moduleName: Name,
@@ -56,7 +55,7 @@ public class ModuleDescriptorImpl(
return packageFragmentProvider.getSubPackagesOf(fqName, nameFilter) return packageFragmentProvider.getSubPackagesOf(fqName, nameFilter)
} }
private val packageFragmentProviderForWholeModuleWithDependencies by Delegates.lazy { private val packageFragmentProviderForWholeModuleWithDependencies by lazy {
val moduleDependencies = dependencies.sure { "Dependencies of module $id were not set before querying module content" } val moduleDependencies = dependencies.sure { "Dependencies of module $id were not set before querying module content" }
val dependenciesDescriptors = moduleDependencies.descriptors val dependenciesDescriptors = moduleDependencies.descriptors
assert(this in dependenciesDescriptors) { "Module ${id} is not contained in his own dependencies, this is probably a misconfiguration" } assert(this in dependenciesDescriptors) { "Module ${id} is not contained in his own dependencies, this is probably a misconfiguration" }
@@ -29,7 +29,7 @@ public abstract class PackageFragmentDescriptorImpl(
override fun substitute(substitutor: TypeSubstitutor): DeclarationDescriptor? = this override fun substitute(substitutor: TypeSubstitutor): DeclarationDescriptor? = this
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R = override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
visitor.visitPackageFragmentDescriptor(this, data) as R visitor.visitPackageFragmentDescriptor(this, data)
override fun getContainingDeclaration(): ModuleDescriptor { override fun getContainingDeclaration(): ModuleDescriptor {
return super<DeclarationDescriptorNonRootImpl>.getContainingDeclaration() as ModuleDescriptor return super<DeclarationDescriptorNonRootImpl>.getContainingDeclaration() as ModuleDescriptor
@@ -82,7 +82,7 @@ public val DeclarationDescriptorWithVisibility.isEffectivelyPublicApi: Boolean
var parent: DeclarationDescriptorWithVisibility? = this var parent: DeclarationDescriptorWithVisibility? = this
while (parent != null) { while (parent != null) {
if (!parent!!.getVisibility().isPublicAPI()) return false if (!parent.getVisibility().isPublicAPI()) return false
parent = DescriptorUtils.getParentOfType(parent, javaClass<DeclarationDescriptorWithVisibility>()) parent = DescriptorUtils.getParentOfType(parent, javaClass<DeclarationDescriptorWithVisibility>())
} }
@@ -39,7 +39,7 @@ public enum class ConstraintPositionKind {
} }
} }
public trait ConstraintPosition { public interface ConstraintPosition {
val kind: ConstraintPositionKind val kind: ConstraintPositionKind
fun isStrong(): Boolean = kind != TYPE_BOUND_POSITION fun isStrong(): Boolean = kind != TYPE_BOUND_POSITION
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.Variance
public trait ConstraintSystem { public interface ConstraintSystem {
/** /**
* Registers variables in a constraint system. * Registers variables in a constraint system.
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.inference
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
public trait ConstraintSystemStatus { public interface ConstraintSystemStatus {
/** /**
* Returns <tt>true</tt> if constraint system has a solution (has no contradiction and has enough information to infer each registered type variable). * Returns <tt>true</tt> if constraint system has a solution (has no contradiction and has enough information to infer each registered type variable).
*/ */
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.Variance
public trait TypeBounds { public interface TypeBounds {
public val varianceOfPosition: Variance public val varianceOfPosition: Variance
public val typeVariable: TypeParameterDescriptor public val typeVariable: TypeParameterDescriptor
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.utils.toReadOnlyList import org.jetbrains.kotlin.utils.toReadOnlyList
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
public trait JetScope { public interface JetScope {
public fun getClassifier(name: Name): ClassifierDescriptor? public fun getClassifier(name: Name): ClassifierDescriptor?
@@ -201,7 +201,7 @@ public class DescriptorKindFilter(
} }
} }
public trait DescriptorKindExclude { public interface DescriptorKindExclude {
public fun excludes(descriptor: DeclarationDescriptor): Boolean public fun excludes(descriptor: DeclarationDescriptor): Boolean
public val fullyExcludedDescriptorKinds: Int public val fullyExcludedDescriptorKinds: Int
@@ -16,21 +16,21 @@
package org.jetbrains.kotlin.resolve.scopes package org.jetbrains.kotlin.resolve.scopes
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.Printer
import java.util.ArrayList import java.util.ArrayList
import kotlin.properties.Delegates
public class StaticScopeForKotlinClass( public class StaticScopeForKotlinClass(
private val containingClass: ClassDescriptor private val containingClass: ClassDescriptor
) : JetScopeImpl() { ) : JetScopeImpl() {
override fun getClassifier(name: Name) = null // TODO override fun getClassifier(name: Name) = null // TODO
private val functions: List<FunctionDescriptor> by Delegates.lazy { private val functions: List<FunctionDescriptor> by lazy {
if (containingClass.getKind() != ClassKind.ENUM_CLASS) { if (containingClass.getKind() != ClassKind.ENUM_CLASS) {
listOf<FunctionDescriptor>() listOf<FunctionDescriptor>()
} }
@@ -25,13 +25,12 @@ import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize
import java.util.HashMap import java.util.HashMap
import kotlin.properties.Delegates
public class SubstitutingScope(private val workerScope: JetScope, private val substitutor: TypeSubstitutor) : JetScope { public class SubstitutingScope(private val workerScope: JetScope, private val substitutor: TypeSubstitutor) : JetScope {
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null
private val _allDescriptors by Delegates.lazy { substitute(workerScope.getDescriptors()) } private val _allDescriptors by lazy { substitute(workerScope.getDescriptors()) }
private fun <D : DeclarationDescriptor> substitute(descriptor: D?): D? { private fun <D : DeclarationDescriptor> substitute(descriptor: D?): D? {
if (descriptor == null) return null if (descriptor == null) return null
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.types package org.jetbrains.kotlin.types
import kotlin.properties.* import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
class StarProjectionImpl( class StarProjectionImpl(
private val typeParameter: TypeParameterDescriptor private val typeParameter: TypeParameterDescriptor
@@ -27,7 +27,7 @@ class StarProjectionImpl(
override fun getProjectionKind() = Variance.OUT_VARIANCE override fun getProjectionKind() = Variance.OUT_VARIANCE
// No synchronization here: there's no problem in accidentally computing this twice // No synchronization here: there's no problem in accidentally computing this twice
private val _type: JetType by Delegates.lazy { private val _type: JetType by lazy {
typeParameter.starProjectionType() typeParameter.starProjectionType()
} }
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.types
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
public trait TypeCapability public interface TypeCapability
public trait Specificity : TypeCapability { public interface Specificity : TypeCapability {
public enum class Relation { public enum class Relation {
LESS_SPECIFIC, LESS_SPECIFIC,
@@ -40,7 +40,7 @@ fun oneMoreSpecificThanAnother(a: JetType, b: JetType) =
// To facilitate laziness, any JetType implementation may inherit from this trait, // To facilitate laziness, any JetType implementation may inherit from this trait,
// even if it turns out that the type an instance represents is not actually a type variable // even if it turns out that the type an instance represents is not actually a type variable
// (i.e. it is not derived from a type parameter), see isTypeVariable // (i.e. it is not derived from a type parameter), see isTypeVariable
public trait CustomTypeVariable : TypeCapability { public interface CustomTypeVariable : TypeCapability {
public val isTypeVariable: Boolean public val isTypeVariable: Boolean
// If typeParameterDescriptor != null <=> isTypeVariable == true, this is not a type variable // If typeParameterDescriptor != null <=> isTypeVariable == true, this is not a type variable
@@ -56,7 +56,7 @@ public fun JetType.getCustomTypeVariable(): CustomTypeVariable? =
if (it.isTypeVariable) it else null if (it.isTypeVariable) it else null
} }
public trait SubtypingRepresentatives : TypeCapability { public interface SubtypingRepresentatives : TypeCapability {
public val subTypeRepresentative: JetType public val subTypeRepresentative: JetType
public val superTypeRepresentative: JetType public val superTypeRepresentative: JetType
@@ -19,6 +19,6 @@ package org.jetbrains.kotlin.types.error
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
// marker for DescriptorRenderer to treat specially in decompiler mode // marker for DescriptorRenderer to treat specially in decompiler mode
public trait MissingDependencyErrorClass { public interface MissingDependencyErrorClass {
public val fullFqName: FqName public val fullFqName: FqName
} }
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.checker.JetTypeChecker
import kotlin.platform.platformStatic import kotlin.platform.platformStatic
public trait FlexibleTypeCapabilities { public interface FlexibleTypeCapabilities {
fun <T: TypeCapability> getCapability(capabilityClass: Class<T>, jetType: JetType, flexibility: Flexibility): T? fun <T: TypeCapability> getCapability(capabilityClass: Class<T>, jetType: JetType, flexibility: Flexibility): T?
val id: String val id: String
@@ -31,7 +31,7 @@ public trait FlexibleTypeCapabilities {
} }
} }
public trait Flexibility : TypeCapability, SubtypingRepresentatives { public interface Flexibility : TypeCapability, SubtypingRepresentatives {
companion object { companion object {
// This is a "magic" classifier: when type resolver sees it in the code, e.g. ft<Foo, Foo?>, instead of creating a normal type, // This is a "magic" classifier: when type resolver sees it in the code, e.g. ft<Foo, Foo?>, instead of creating a normal type,
// it creates a flexible type, e.g. (Foo..Foo?). // it creates a flexible type, e.g. (Foo..Foo?).
@@ -100,12 +100,12 @@ fun Collection<TypeProjection>.singleBestRepresentative(): TypeProjection? {
public fun JetType.lowerIfFlexible(): JetType = if (this.isFlexible()) this.flexibility().lowerBound else this public fun JetType.lowerIfFlexible(): JetType = if (this.isFlexible()) this.flexibility().lowerBound else this
public fun JetType.upperIfFlexible(): JetType = if (this.isFlexible()) this.flexibility().upperBound else this public fun JetType.upperIfFlexible(): JetType = if (this.isFlexible()) this.flexibility().upperBound else this
public trait NullAwareness : TypeCapability { public interface NullAwareness : TypeCapability {
public fun makeNullableAsSpecified(nullable: Boolean): JetType public fun makeNullableAsSpecified(nullable: Boolean): JetType
public fun computeIsNullable(): Boolean public fun computeIsNullable(): Boolean
} }
trait FlexibleTypeDelegation : TypeCapability { interface FlexibleTypeDelegation : TypeCapability {
public val delegateType: JetType public val delegateType: JetType
} }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.serialization.deserialization
import org.jetbrains.kotlin.types.DynamicTypeCapabilities import org.jetbrains.kotlin.types.DynamicTypeCapabilities
import org.jetbrains.kotlin.types.FlexibleTypeCapabilities import org.jetbrains.kotlin.types.FlexibleTypeCapabilities
trait FlexibleTypeCapabilitiesDeserializer { interface FlexibleTypeCapabilitiesDeserializer {
object ThrowException : FlexibleTypeCapabilitiesDeserializer { object ThrowException : FlexibleTypeCapabilitiesDeserializer {
override fun capabilitiesById(id: String): FlexibleTypeCapabilities? { override fun capabilitiesById(id: String): FlexibleTypeCapabilities? {
throw IllegalArgumentException("Capabilities not found by ThrowException manager: $id") throw IllegalArgumentException("Capabilities not found by ThrowException manager: $id")
@@ -19,6 +19,6 @@ package org.jetbrains.kotlin.serialization.deserialization
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
public trait LocalClassResolver { public interface LocalClassResolver {
public fun resolveLocalClass(classId: ClassId): ClassDescriptor? public fun resolveLocalClass(classId: ClassId): ClassDescriptor?
} }
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.NameResolver
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
public trait DeserializedCallableMemberDescriptor: CallableMemberDescriptor { public interface DeserializedCallableMemberDescriptor: CallableMemberDescriptor {
public val proto: ProtoBuf.Callable public val proto: ProtoBuf.Callable
public val nameResolver: NameResolver public val nameResolver: NameResolver
} }
@@ -69,7 +69,7 @@ public abstract class DeserializedMemberScope protected constructor(
protos = ArrayList(1) protos = ArrayList(1)
map.put(key, protos) map.put(key, protos)
} }
protos!!.add(memberProto) protos.add(memberProto)
} }
return map return map
} }
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? { public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? {
val packageViewDescriptor = getPackage(classId.getPackageFqName()) ?: return null val packageViewDescriptor = getPackage(classId.getPackageFqName())
val segments = classId.getRelativeClassName().pathSegments() val segments = classId.getRelativeClassName().pathSegments()
val topLevelClass = packageViewDescriptor.memberScope.getClassifier(segments.first()) as? ClassDescriptor ?: return null val topLevelClass = packageViewDescriptor.memberScope.getClassifier(segments.first()) as? ClassDescriptor ?: return null
var result = topLevelClass var result = topLevelClass
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.storage
import java.util.concurrent.ConcurrentMap import java.util.concurrent.ConcurrentMap
public trait StorageManager { public interface StorageManager {
/** /**
* Given a function compute: K -> V create a memoized version of it that computes a value only once for each key * Given a function compute: K -> V create a memoized version of it that computes a value only once for each key
* @param compute the function to be memoized * @param compute the function to be memoized
@@ -16,19 +16,19 @@
package org.jetbrains.kotlin.storage package org.jetbrains.kotlin.storage
public trait MemoizedFunctionToNotNull<P, R : Any> : Function1<P, R> { public interface MemoizedFunctionToNotNull<P, R : Any> : Function1<P, R> {
public fun isComputed(key: P): Boolean public fun isComputed(key: P): Boolean
} }
public trait MemoizedFunctionToNullable<P, R : Any> : Function1<P, R?> { public interface MemoizedFunctionToNullable<P, R : Any> : Function1<P, R?> {
public fun isComputed(key: P): Boolean public fun isComputed(key: P): Boolean
} }
public trait NotNullLazyValue<T : Any> : Function0<T> { public interface NotNullLazyValue<T : Any> : Function0<T> {
public fun isComputed(): Boolean public fun isComputed(): Boolean
} }
public trait NullableLazyValue<T : Any> : Function0<T?> { public interface NullableLazyValue<T : Any> : Function0<T?> {
public fun isComputed(): Boolean public fun isComputed(): Boolean
} }