Refactoring. Convert KotlinType to kotlin.
This commit is contained in:
@@ -89,8 +89,8 @@ class TypeResolver(
|
|||||||
override fun getDelegate() = _delegate()
|
override fun getDelegate() = _delegate()
|
||||||
|
|
||||||
override fun forceResolveAllContents() {
|
override fun forceResolveAllContents() {
|
||||||
ForceResolveUtil.forceResolveAllContents(getConstructor())
|
ForceResolveUtil.forceResolveAllContents(constructor)
|
||||||
getArguments().forEach { ForceResolveUtil.forceResolveAllContents(it.getType()) }
|
arguments.forEach { ForceResolveUtil.forceResolveAllContents(it.type) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -85,7 +85,7 @@ class LazyJavaAnnotationDescriptor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAnnotationClass() = getType().getConstructor().declarationDescriptor as ClassDescriptor
|
private fun getAnnotationClass() = getType().constructor.declarationDescriptor as ClassDescriptor
|
||||||
|
|
||||||
private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): ConstantValue<*>? {
|
private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): ConstantValue<*>? {
|
||||||
return when (argument) {
|
return when (argument) {
|
||||||
@@ -103,7 +103,7 @@ class LazyJavaAnnotationDescriptor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveFromArray(argumentName: Name, elements: List<JavaAnnotationArgument>): ConstantValue<*>? {
|
private fun resolveFromArray(argumentName: Name, elements: List<JavaAnnotationArgument>): ConstantValue<*>? {
|
||||||
if (getType().isError()) return null
|
if (getType().isError) return null
|
||||||
|
|
||||||
val valueParameter = DescriptorResolverUtils.getAnnotationParameterByName(argumentName, getAnnotationClass()) ?: return null
|
val valueParameter = DescriptorResolverUtils.getAnnotationParameterByName(argumentName, getAnnotationClass()) ?: return null
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -678,7 +678,7 @@ class LazyJavaClassMemberScope(
|
|||||||
|
|
||||||
return memberIndex().getAllFieldNames() +
|
return memberIndex().getAllFieldNames() +
|
||||||
ownerDescriptor.getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet<Name>()) { supertype ->
|
ownerDescriptor.getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet<Name>()) { supertype ->
|
||||||
supertype.getMemberScope().getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
supertype.memberScope.getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
||||||
variable.getName()
|
variable.getName()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -183,12 +183,11 @@ class LazyJavaTypeResolver(
|
|||||||
// such as collections with no generics, so the Java types are not raw, formally, but they don't match with
|
// such as collections with no generics, so the Java types are not raw, formally, but they don't match with
|
||||||
// their Kotlin analogs, so we treat them as raw to avoid exceptions
|
// their Kotlin analogs, so we treat them as raw to avoid exceptions
|
||||||
// No type arguments, but some are expected => raw
|
// No type arguments, but some are expected => raw
|
||||||
return javaType.typeArguments.isEmpty() && !getConstructor().parameters.isEmpty()
|
return javaType.typeArguments.isEmpty() && !constructor.parameters.isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun computeArguments(): List<TypeProjection> {
|
override fun computeArguments(): List<TypeProjection> {
|
||||||
val typeConstructor = getConstructor()
|
val typeParameters = constructor.parameters
|
||||||
val typeParameters = typeConstructor.parameters
|
|
||||||
if (isRaw()) {
|
if (isRaw()) {
|
||||||
return typeParameters.map {
|
return typeParameters.map {
|
||||||
parameter ->
|
parameter ->
|
||||||
@@ -259,7 +258,7 @@ class LazyJavaTypeResolver(
|
|||||||
return this != typeParameter.variance
|
return this != typeParameter.variance
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCapabilities(): TypeCapabilities = if (isRaw()) RawTypeCapabilities else TypeCapabilities.NONE
|
override val capabilities: TypeCapabilities get() = if (isRaw()) RawTypeCapabilities else TypeCapabilities.NONE
|
||||||
|
|
||||||
private val nullable = c.storageManager.createLazyValue l@ {
|
private val nullable = c.storageManager.createLazyValue l@ {
|
||||||
if (attr.flexibility == FLEXIBLE_LOWER_BOUND) return@l false
|
if (attr.flexibility == FLEXIBLE_LOWER_BOUND) return@l false
|
||||||
@@ -278,7 +277,7 @@ class LazyJavaTypeResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isMarkedNullable(): Boolean = nullable()
|
override val isMarkedNullable: Boolean get() = nullable()
|
||||||
|
|
||||||
override fun getAnnotations() = annotations
|
override fun getAnnotations() = annotations
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -95,7 +95,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
|
|||||||
|
|
||||||
var globalArgIndex = index + 1
|
var globalArgIndex = index + 1
|
||||||
var wereChanges = enhancedMutabilityAnnotations != null
|
var wereChanges = enhancedMutabilityAnnotations != null
|
||||||
val enhancedArguments = getArguments().mapIndexed {
|
val enhancedArguments = arguments.mapIndexed {
|
||||||
localArgIndex, arg ->
|
localArgIndex, arg ->
|
||||||
if (arg.isStarProjection) {
|
if (arg.isStarProjection) {
|
||||||
globalArgIndex++
|
globalArgIndex++
|
||||||
@@ -138,7 +138,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
|
|||||||
enhancedArguments,
|
enhancedArguments,
|
||||||
if (enhancedClassifier is ClassDescriptor)
|
if (enhancedClassifier is ClassDescriptor)
|
||||||
enhancedClassifier.getMemberScope(newSubstitution)
|
enhancedClassifier.getMemberScope(newSubstitution)
|
||||||
else enhancedClassifier.getDefaultType().getMemberScope(),
|
else enhancedClassifier.getDefaultType().memberScope,
|
||||||
newCapabilities
|
newCapabilities
|
||||||
)
|
)
|
||||||
return Result(enhancedType, subtreeSize, wereChanges = true)
|
return Result(enhancedType, subtreeSize, wereChanges = true)
|
||||||
@@ -180,12 +180,12 @@ private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
private fun KotlinType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||||
if (!position.shouldEnhance()) return this.isMarkedNullable().noChange()
|
if (!position.shouldEnhance()) return this.isMarkedNullable.noChange()
|
||||||
|
|
||||||
return when (qualifiers.nullability) {
|
return when (qualifiers.nullability) {
|
||||||
NULLABLE -> true.enhancedNullability()
|
NULLABLE -> true.enhancedNullability()
|
||||||
NOT_NULL -> false.enhancedNullability()
|
NOT_NULL -> false.enhancedNullability()
|
||||||
else -> this.isMarkedNullable().noChange()
|
else -> this.isMarkedNullable.noChange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -101,7 +101,7 @@ fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<Ko
|
|||||||
|
|
||||||
fun add(type: KotlinType) {
|
fun add(type: KotlinType) {
|
||||||
list.add(type)
|
list.add(type)
|
||||||
for (arg in type.getArguments()) {
|
for (arg in type.arguments) {
|
||||||
if (arg.isStarProjection) {
|
if (arg.isStarProjection) {
|
||||||
list.add(arg.type)
|
list.add(arg.type)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -68,7 +68,7 @@ class CapturedType(
|
|||||||
|
|
||||||
override fun getDelegate(): KotlinType = delegateType
|
override fun getDelegate(): KotlinType = delegateType
|
||||||
|
|
||||||
override fun getCapabilities(): TypeCapabilities = object : TypeCapabilities {
|
override val capabilities: TypeCapabilities get() = object : TypeCapabilities {
|
||||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>) =
|
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>) =
|
||||||
this@CapturedType.getCapability(capabilityClass)
|
this@CapturedType.getCapability(capabilityClass)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,21 +21,21 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
import org.jetbrains.kotlin.storage.getValue
|
||||||
|
|
||||||
abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType {
|
abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType {
|
||||||
|
|
||||||
private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() }
|
private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() }
|
||||||
override fun getConstructor(): TypeConstructor = typeConstructor()
|
override val constructor by typeConstructor
|
||||||
|
|
||||||
protected abstract fun computeTypeConstructor(): TypeConstructor
|
protected abstract fun computeTypeConstructor(): TypeConstructor
|
||||||
|
|
||||||
private val arguments = storageManager.createLazyValue { computeArguments() }
|
private val _arguments = storageManager.createLazyValue { computeArguments() }
|
||||||
override fun getArguments(): List<TypeProjection> = arguments()
|
override val arguments by _arguments
|
||||||
|
|
||||||
protected abstract fun computeArguments(): List<TypeProjection>
|
protected abstract fun computeArguments(): List<TypeProjection>
|
||||||
|
|
||||||
private val memberScope = storageManager.createLazyValue { computeMemberScope() }
|
override val memberScope by storageManager.createLazyValue { computeMemberScope() }
|
||||||
override fun getMemberScope() = memberScope()
|
|
||||||
|
|
||||||
protected open fun computeMemberScope(): MemberScope {
|
protected open fun computeMemberScope(): MemberScope {
|
||||||
val descriptor = constructor.declarationDescriptor
|
val descriptor = constructor.declarationDescriptor
|
||||||
@@ -43,22 +43,22 @@ abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlin
|
|||||||
is TypeParameterDescriptor -> descriptor.getDefaultType().memberScope
|
is TypeParameterDescriptor -> descriptor.getDefaultType().memberScope
|
||||||
is ClassDescriptor -> {
|
is ClassDescriptor -> {
|
||||||
val substitution = getCapability<RawTypeCapability>()?.substitution
|
val substitution = getCapability<RawTypeCapability>()?.substitution
|
||||||
?: TypeConstructorSubstitution.create(constructor, getArguments())
|
?: TypeConstructorSubstitution.create(constructor, arguments)
|
||||||
descriptor.getMemberScope(substitution)
|
descriptor.getMemberScope(substitution)
|
||||||
}
|
}
|
||||||
else -> throw IllegalStateException("Unsupported classifier: $descriptor")
|
else -> throw IllegalStateException("Unsupported classifier: $descriptor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isMarkedNullable() = false
|
override val isMarkedNullable: Boolean get() = false
|
||||||
|
|
||||||
override fun isError() = constructor.declarationDescriptor?.let { d -> ErrorUtils.isError(d) } ?: false
|
override val isError: Boolean get() = constructor.declarationDescriptor?.let { d -> ErrorUtils.isError(d) } ?: false
|
||||||
|
|
||||||
override fun getAnnotations() = Annotations.EMPTY
|
override fun getAnnotations() = Annotations.EMPTY
|
||||||
|
|
||||||
override fun toString() = when {
|
override fun toString() = when {
|
||||||
!typeConstructor.isComputed() -> "[Not-computed]"
|
!typeConstructor.isComputed() -> "[Not-computed]"
|
||||||
!arguments.isComputed() ->
|
!_arguments.isComputed() ->
|
||||||
if (constructor.parameters.isEmpty()) constructor.toString()
|
if (constructor.parameters.isEmpty()) constructor.toString()
|
||||||
else "$constructor<not-computed>"
|
else "$constructor<not-computed>"
|
||||||
else -> super.toString()
|
else -> super.toString()
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.types;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.annotations.ReadOnly;
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see KotlinTypeChecker#isSubtypeOf(KotlinType, KotlinType)
|
|
||||||
*/
|
|
||||||
public interface KotlinType extends Annotated {
|
|
||||||
@NotNull
|
|
||||||
TypeConstructor getConstructor();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@ReadOnly
|
|
||||||
List<TypeProjection> getArguments();
|
|
||||||
|
|
||||||
boolean isMarkedNullable();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
MemberScope getMemberScope();
|
|
||||||
|
|
||||||
boolean isError();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean equals(Object other);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
<T extends TypeCapability> T getCapability(@NotNull Class<T> capabilityClass);
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
TypeCapabilities getCapabilities();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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.types
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see KotlinTypeChecker.isSubtypeOf
|
||||||
|
*/
|
||||||
|
interface KotlinType : Annotated {
|
||||||
|
val constructor: TypeConstructor
|
||||||
|
|
||||||
|
val arguments: List<TypeProjection>
|
||||||
|
|
||||||
|
val isMarkedNullable: Boolean
|
||||||
|
|
||||||
|
val memberScope: MemberScope
|
||||||
|
|
||||||
|
val isError: Boolean
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean
|
||||||
|
|
||||||
|
fun <T : TypeCapability> getCapability(capabilityClass: Class<T>): T?
|
||||||
|
|
||||||
|
val capabilities: TypeCapabilities
|
||||||
|
}
|
||||||
@@ -23,10 +23,10 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
|||||||
open class KotlinTypeImpl
|
open class KotlinTypeImpl
|
||||||
private constructor(
|
private constructor(
|
||||||
private val annotations: Annotations,
|
private val annotations: Annotations,
|
||||||
private val constructor: TypeConstructor,
|
override val constructor: TypeConstructor,
|
||||||
private val nullable: Boolean,
|
override val isMarkedNullable: Boolean,
|
||||||
private val arguments: List<TypeProjection>,
|
override val arguments: List<TypeProjection>,
|
||||||
private val memberScope: MemberScope
|
override val memberScope: MemberScope
|
||||||
) : AbstractKotlinType() {
|
) : AbstractKotlinType() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -67,10 +67,8 @@ private constructor(
|
|||||||
nullable: Boolean,
|
nullable: Boolean,
|
||||||
arguments: List<TypeProjection>,
|
arguments: List<TypeProjection>,
|
||||||
memberScope: MemberScope,
|
memberScope: MemberScope,
|
||||||
private val typeCapabilities: TypeCapabilities
|
override val capabilities: TypeCapabilities
|
||||||
) : KotlinTypeImpl(annotations, constructor, nullable, arguments, memberScope) {
|
) : KotlinTypeImpl(annotations, constructor, nullable, arguments, memberScope)
|
||||||
override fun getCapabilities(): TypeCapabilities = typeCapabilities
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (memberScope is ErrorUtils.ErrorScope) {
|
if (memberScope is ErrorUtils.ErrorScope) {
|
||||||
@@ -80,13 +78,5 @@ private constructor(
|
|||||||
|
|
||||||
override fun getAnnotations() = annotations
|
override fun getAnnotations() = annotations
|
||||||
|
|
||||||
override fun getConstructor() = constructor
|
override val isError: Boolean get() = false
|
||||||
|
|
||||||
override fun getArguments() = arguments
|
|
||||||
|
|
||||||
override fun isMarkedNullable() = nullable
|
|
||||||
|
|
||||||
override fun getMemberScope() = memberScope
|
|
||||||
|
|
||||||
override fun isError() = false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,6 @@ object DynamicTypeFactory : FlexibleTypeFactory {
|
|||||||
return createDynamicType(delegateType.builtIns)
|
return createDynamicType(delegateType.builtIns)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isMarkedNullable() = false
|
override val isMarkedNullable: Boolean get() = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-7
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
|||||||
import org.jetbrains.kotlin.types.AbstractLazyType
|
import org.jetbrains.kotlin.types.AbstractLazyType
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
import org.jetbrains.kotlin.types.LazyType
|
import org.jetbrains.kotlin.types.LazyType
|
||||||
|
import org.jetbrains.kotlin.types.TypeCapabilities
|
||||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||||
|
|
||||||
class DeserializedType(
|
class DeserializedType(
|
||||||
@@ -47,16 +48,17 @@ class DeserializedType(
|
|||||||
.map { AnnotationWithTarget(it, null) } + additionalAnnotations.getAllAnnotations()
|
.map { AnnotationWithTarget(it, null) } + additionalAnnotations.getAllAnnotations()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isMarkedNullable(): Boolean = typeProto.nullable
|
override val isMarkedNullable: Boolean get() = typeProto.nullable
|
||||||
|
|
||||||
override fun isError(): Boolean {
|
override val isError: Boolean
|
||||||
val descriptor = constructor.declarationDescriptor
|
get() {
|
||||||
return descriptor != null && ErrorUtils.isError(descriptor)
|
val descriptor = constructor.declarationDescriptor
|
||||||
}
|
return descriptor != null && ErrorUtils.isError(descriptor)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getAnnotations(): Annotations = annotations
|
override fun getAnnotations(): Annotations = annotations
|
||||||
|
|
||||||
override fun getCapabilities() = typeCapabilities()
|
override val capabilities: TypeCapabilities get() = typeCapabilities()
|
||||||
|
|
||||||
private val typeCapabilities = c.storageManager.createLazyValue {
|
private val typeCapabilities = c.storageManager.createLazyValue {
|
||||||
c.components.typeCapabilitiesLoader.loadCapabilities(typeProto)
|
c.components.typeCapabilitiesLoader.loadCapabilities(typeProto)
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -147,8 +147,8 @@ class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(KtExpre
|
|||||||
KtTokens.MULTEQ -> if (functionName == "multAssign") "$0.multAssign($1)" else "$0 = $0.mult($1)"
|
KtTokens.MULTEQ -> if (functionName == "multAssign") "$0.multAssign($1)" else "$0 = $0.mult($1)"
|
||||||
KtTokens.DIVEQ -> if (functionName == "divAssign") "$0.divAssign($1)" else "$0 = $0.div($1)"
|
KtTokens.DIVEQ -> if (functionName == "divAssign") "$0.divAssign($1)" else "$0 = $0.div($1)"
|
||||||
KtTokens.PERCEQ -> if (functionName == "modAssign") "$0.modAssign($1)" else "$0 = $0.mod($1)"
|
KtTokens.PERCEQ -> if (functionName == "modAssign") "$0.modAssign($1)" else "$0 = $0.mod($1)"
|
||||||
KtTokens.EQEQ -> if (elemType?.isMarkedNullable() ?: true) "$0?.equals($1) ?: ($1 == null)" else "$0.equals($1)"
|
KtTokens.EQEQ -> if (elemType?.isMarkedNullable ?: true) "$0?.equals($1) ?: ($1 == null)" else "$0.equals($1)"
|
||||||
KtTokens.EXCLEQ -> if (elemType?.isMarkedNullable() ?: true) "!($0?.equals($1) ?: ($1 == null))" else "!$0.equals($1)"
|
KtTokens.EXCLEQ -> if (elemType?.isMarkedNullable ?: true) "!($0?.equals($1) ?: ($1 == null))" else "!$0.equals($1)"
|
||||||
KtTokens.GT -> "$0.compareTo($1) > 0"
|
KtTokens.GT -> "$0.compareTo($1) > 0"
|
||||||
KtTokens.LT -> "$0.compareTo($1) < 0"
|
KtTokens.LT -> "$0.compareTo($1) < 0"
|
||||||
KtTokens.GTEQ -> "$0.compareTo($1) >= 0"
|
KtTokens.GTEQ -> "$0.compareTo($1) >= 0"
|
||||||
|
|||||||
+8
-8
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,14 +18,14 @@ package org.jetbrains.kotlin.idea.structureView
|
|||||||
|
|
||||||
import com.intellij.ide.util.InheritedMembersNodeProvider
|
import com.intellij.ide.util.InheritedMembersNodeProvider
|
||||||
import com.intellij.ide.util.treeView.smartTree.TreeElement
|
import com.intellij.ide.util.treeView.smartTree.TreeElement
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
|
||||||
import java.util.ArrayList
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
|
||||||
import com.intellij.psi.NavigatablePsiElement
|
import com.intellij.psi.NavigatablePsiElement
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeElement>() {
|
class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeElement>() {
|
||||||
override fun provideNodes(node: TreeElement): Collection<TreeElement> {
|
override fun provideNodes(node: TreeElement): Collection<TreeElement> {
|
||||||
@@ -44,7 +44,7 @@ class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeEleme
|
|||||||
val children = ArrayList<TreeElement>()
|
val children = ArrayList<TreeElement>()
|
||||||
|
|
||||||
val defaultType = descriptor.getDefaultType()
|
val defaultType = descriptor.getDefaultType()
|
||||||
for (memberDescriptor in defaultType.getMemberScope().getContributedDescriptors()) {
|
for (memberDescriptor in defaultType.memberScope.getContributedDescriptors()) {
|
||||||
if (memberDescriptor !is CallableMemberDescriptor) continue
|
if (memberDescriptor !is CallableMemberDescriptor) continue
|
||||||
|
|
||||||
when (memberDescriptor.getKind()) {
|
when (memberDescriptor.getKind()) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,8 +26,11 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||||
import org.jetbrains.kotlin.idea.util.*
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
|
import org.jetbrains.kotlin.idea.util.approximateWithResolvableType
|
||||||
|
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||||
|
import org.jetbrains.kotlin.idea.util.isResolvableInScope
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
@@ -103,7 +106,7 @@ class SpecifyTypeExplicitlyIntention : SelfTargetingIntention<KtCallableDeclarat
|
|||||||
|
|
||||||
object: DelegatingType() {
|
object: DelegatingType() {
|
||||||
override fun getDelegate() = it
|
override fun getDelegate() = it
|
||||||
override fun getArguments() = newArguments
|
override val arguments = newArguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ifEmpty { return null }
|
.ifEmpty { return null }
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import com.intellij.openapi.editor.Editor
|
|||||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
|
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||||
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.containsStarProjections
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.containsStarProjections
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||||
@@ -61,7 +61,7 @@ class LetImplementInterfaceFix(
|
|||||||
validExpectedType = with (expectedType) {
|
validExpectedType = with (expectedType) {
|
||||||
isInterface() &&
|
isInterface() &&
|
||||||
!containsStarProjections() &&
|
!containsStarProjections() &&
|
||||||
constructor !in TypeUtils.getAllSupertypes(expressionType).map(KotlinType::getConstructor)
|
constructor !in TypeUtils.getAllSupertypes(expressionType).map(KotlinType::constructor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -65,8 +65,9 @@ private fun KotlinType.render(typeParameterNameMap: Map<TypeParameterDescriptor,
|
|||||||
override fun getTypeConstructor() = wrappingTypeConstructor
|
override fun getTypeConstructor() = wrappingTypeConstructor
|
||||||
}
|
}
|
||||||
|
|
||||||
val wrappingType = object : KotlinType by typeParameter.defaultType {
|
val wrappingType = object : DelegatingType() {
|
||||||
override fun getConstructor() = wrappingTypeConstructor
|
override fun getDelegate(): KotlinType? = typeParameter.defaultType
|
||||||
|
override val constructor = wrappingTypeConstructor
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeProjectionImpl(wrappingType)
|
TypeProjectionImpl(wrappingType)
|
||||||
|
|||||||
Reference in New Issue
Block a user