Refactoring. Convert KotlinType to kotlin.
This commit is contained in:
@@ -89,8 +89,8 @@ class TypeResolver(
|
||||
override fun getDelegate() = _delegate()
|
||||
|
||||
override fun forceResolveAllContents() {
|
||||
ForceResolveUtil.forceResolveAllContents(getConstructor())
|
||||
getArguments().forEach { ForceResolveUtil.forceResolveAllContents(it.getType()) }
|
||||
ForceResolveUtil.forceResolveAllContents(constructor)
|
||||
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");
|
||||
* 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<*>? {
|
||||
return when (argument) {
|
||||
@@ -103,7 +103,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
+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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -678,7 +678,7 @@ class LazyJavaClassMemberScope(
|
||||
|
||||
return memberIndex().getAllFieldNames() +
|
||||
ownerDescriptor.getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet<Name>()) { supertype ->
|
||||
supertype.getMemberScope().getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
||||
supertype.memberScope.getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
||||
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
|
||||
// their Kotlin analogs, so we treat them as raw to avoid exceptions
|
||||
// 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> {
|
||||
val typeConstructor = getConstructor()
|
||||
val typeParameters = typeConstructor.parameters
|
||||
val typeParameters = constructor.parameters
|
||||
if (isRaw()) {
|
||||
return typeParameters.map {
|
||||
parameter ->
|
||||
@@ -259,7 +258,7 @@ class LazyJavaTypeResolver(
|
||||
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@ {
|
||||
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
|
||||
}
|
||||
|
||||
+4
-4
@@ -95,7 +95,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
|
||||
|
||||
var globalArgIndex = index + 1
|
||||
var wereChanges = enhancedMutabilityAnnotations != null
|
||||
val enhancedArguments = getArguments().mapIndexed {
|
||||
val enhancedArguments = arguments.mapIndexed {
|
||||
localArgIndex, arg ->
|
||||
if (arg.isStarProjection) {
|
||||
globalArgIndex++
|
||||
@@ -138,7 +138,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
|
||||
enhancedArguments,
|
||||
if (enhancedClassifier is ClassDescriptor)
|
||||
enhancedClassifier.getMemberScope(newSubstitution)
|
||||
else enhancedClassifier.getDefaultType().getMemberScope(),
|
||||
else enhancedClassifier.getDefaultType().memberScope,
|
||||
newCapabilities
|
||||
)
|
||||
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> {
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable().noChange()
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable.noChange()
|
||||
|
||||
return when (qualifiers.nullability) {
|
||||
NULLABLE -> true.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");
|
||||
* 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) {
|
||||
list.add(type)
|
||||
for (arg in type.getArguments()) {
|
||||
for (arg in type.arguments) {
|
||||
if (arg.isStarProjection) {
|
||||
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");
|
||||
* 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 getCapabilities(): TypeCapabilities = object : TypeCapabilities {
|
||||
override val capabilities: TypeCapabilities get() = object : TypeCapabilities {
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>) =
|
||||
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.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
|
||||
abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType {
|
||||
|
||||
private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() }
|
||||
override fun getConstructor(): TypeConstructor = typeConstructor()
|
||||
override val constructor by typeConstructor
|
||||
|
||||
protected abstract fun computeTypeConstructor(): TypeConstructor
|
||||
|
||||
private val arguments = storageManager.createLazyValue { computeArguments() }
|
||||
override fun getArguments(): List<TypeProjection> = arguments()
|
||||
private val _arguments = storageManager.createLazyValue { computeArguments() }
|
||||
override val arguments by _arguments
|
||||
|
||||
protected abstract fun computeArguments(): List<TypeProjection>
|
||||
|
||||
private val memberScope = storageManager.createLazyValue { computeMemberScope() }
|
||||
override fun getMemberScope() = memberScope()
|
||||
override val memberScope by storageManager.createLazyValue { computeMemberScope() }
|
||||
|
||||
protected open fun computeMemberScope(): MemberScope {
|
||||
val descriptor = constructor.declarationDescriptor
|
||||
@@ -43,22 +43,22 @@ abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlin
|
||||
is TypeParameterDescriptor -> descriptor.getDefaultType().memberScope
|
||||
is ClassDescriptor -> {
|
||||
val substitution = getCapability<RawTypeCapability>()?.substitution
|
||||
?: TypeConstructorSubstitution.create(constructor, getArguments())
|
||||
?: TypeConstructorSubstitution.create(constructor, arguments)
|
||||
descriptor.getMemberScope(substitution)
|
||||
}
|
||||
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 toString() = when {
|
||||
!typeConstructor.isComputed() -> "[Not-computed]"
|
||||
!arguments.isComputed() ->
|
||||
!_arguments.isComputed() ->
|
||||
if (constructor.parameters.isEmpty()) constructor.toString()
|
||||
else "$constructor<not-computed>"
|
||||
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
|
||||
private constructor(
|
||||
private val annotations: Annotations,
|
||||
private val constructor: TypeConstructor,
|
||||
private val nullable: Boolean,
|
||||
private val arguments: List<TypeProjection>,
|
||||
private val memberScope: MemberScope
|
||||
override val constructor: TypeConstructor,
|
||||
override val isMarkedNullable: Boolean,
|
||||
override val arguments: List<TypeProjection>,
|
||||
override val memberScope: MemberScope
|
||||
) : AbstractKotlinType() {
|
||||
|
||||
companion object {
|
||||
@@ -67,10 +67,8 @@ private constructor(
|
||||
nullable: Boolean,
|
||||
arguments: List<TypeProjection>,
|
||||
memberScope: MemberScope,
|
||||
private val typeCapabilities: TypeCapabilities
|
||||
) : KotlinTypeImpl(annotations, constructor, nullable, arguments, memberScope) {
|
||||
override fun getCapabilities(): TypeCapabilities = typeCapabilities
|
||||
}
|
||||
override val capabilities: TypeCapabilities
|
||||
) : KotlinTypeImpl(annotations, constructor, nullable, arguments, memberScope)
|
||||
|
||||
init {
|
||||
if (memberScope is ErrorUtils.ErrorScope) {
|
||||
@@ -80,13 +78,5 @@ private constructor(
|
||||
|
||||
override fun getAnnotations() = annotations
|
||||
|
||||
override fun getConstructor() = constructor
|
||||
|
||||
override fun getArguments() = arguments
|
||||
|
||||
override fun isMarkedNullable() = nullable
|
||||
|
||||
override fun getMemberScope() = memberScope
|
||||
|
||||
override fun isError() = false
|
||||
override val isError: Boolean get() = false
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ object DynamicTypeFactory : FlexibleTypeFactory {
|
||||
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");
|
||||
* 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.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.LazyType
|
||||
import org.jetbrains.kotlin.types.TypeCapabilities
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
|
||||
class DeserializedType(
|
||||
@@ -47,16 +48,17 @@ class DeserializedType(
|
||||
.map { AnnotationWithTarget(it, null) } + additionalAnnotations.getAllAnnotations()
|
||||
}
|
||||
|
||||
override fun isMarkedNullable(): Boolean = typeProto.nullable
|
||||
override val isMarkedNullable: Boolean get() = typeProto.nullable
|
||||
|
||||
override fun isError(): Boolean {
|
||||
val descriptor = constructor.declarationDescriptor
|
||||
return descriptor != null && ErrorUtils.isError(descriptor)
|
||||
}
|
||||
override val isError: Boolean
|
||||
get() {
|
||||
val descriptor = constructor.declarationDescriptor
|
||||
return descriptor != null && ErrorUtils.isError(descriptor)
|
||||
}
|
||||
|
||||
override fun getAnnotations(): Annotations = annotations
|
||||
|
||||
override fun getCapabilities() = typeCapabilities()
|
||||
override val capabilities: TypeCapabilities get() = typeCapabilities()
|
||||
|
||||
private val typeCapabilities = c.storageManager.createLazyValue {
|
||||
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");
|
||||
* 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.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.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.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.GT -> "$0.compareTo($1) > 0"
|
||||
KtTokens.LT -> "$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");
|
||||
* 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.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 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.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import java.util.*
|
||||
|
||||
class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeElement>() {
|
||||
override fun provideNodes(node: TreeElement): Collection<TreeElement> {
|
||||
@@ -44,7 +44,7 @@ class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeEleme
|
||||
val children = ArrayList<TreeElement>()
|
||||
|
||||
val defaultType = descriptor.getDefaultType()
|
||||
for (memberDescriptor in defaultType.getMemberScope().getContributedDescriptors()) {
|
||||
for (memberDescriptor in defaultType.memberScope.getContributedDescriptors()) {
|
||||
if (memberDescriptor !is CallableMemberDescriptor) continue
|
||||
|
||||
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");
|
||||
* 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.getResolutionFacade
|
||||
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.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.psiUtil.getElementTextWithContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -103,7 +106,7 @@ class SpecifyTypeExplicitlyIntention : SelfTargetingIntention<KtCallableDeclarat
|
||||
|
||||
object: DelegatingType() {
|
||||
override fun getDelegate() = it
|
||||
override fun getArguments() = newArguments
|
||||
override val arguments = newArguments
|
||||
}
|
||||
}
|
||||
.ifEmpty { return null }
|
||||
|
||||
@@ -21,10 +21,10 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
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.quickfix.createFromUsage.callableBuilder.containsStarProjections
|
||||
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.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -61,7 +61,7 @@ class LetImplementInterfaceFix(
|
||||
validExpectedType = with (expectedType) {
|
||||
isInterface() &&
|
||||
!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");
|
||||
* 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
|
||||
}
|
||||
|
||||
val wrappingType = object : KotlinType by typeParameter.defaultType {
|
||||
override fun getConstructor() = wrappingTypeConstructor
|
||||
val wrappingType = object : DelegatingType() {
|
||||
override fun getDelegate(): KotlinType? = typeParameter.defaultType
|
||||
override val constructor = wrappingTypeConstructor
|
||||
}
|
||||
|
||||
TypeProjectionImpl(wrappingType)
|
||||
|
||||
Reference in New Issue
Block a user