Introduce KotlinTypeFactory
This commit is contained in:
@@ -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.
|
||||
@@ -58,12 +58,11 @@ fun KotlinType.approximateFlexibleTypes(preferNotNull: Boolean = false): KotlinT
|
||||
|
||||
return approximation
|
||||
}
|
||||
return KotlinTypeImpl.create(
|
||||
annotations,
|
||||
constructor,
|
||||
isMarkedNullable,
|
||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
||||
return KotlinTypeFactory.simpleType(annotations,
|
||||
constructor,
|
||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||
isMarkedNullable,
|
||||
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.idea.util.CallTypeAndReceiver
|
||||
import org.jetbrains.kotlin.idea.util.toFuzzyType
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||
@@ -100,7 +100,7 @@ object KeywordValues {
|
||||
|
||||
if (qualifierType != null) {
|
||||
val kClassDescriptor = resolutionFacade.getFrontendService(ReflectionTypes::class.java).kClass
|
||||
val classLiteralType = KotlinTypeImpl.create(Annotations.EMPTY, kClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType)))
|
||||
val classLiteralType = KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kClassDescriptor, listOf(TypeProjectionImpl(qualifierType)))
|
||||
val kClassTypes = listOf(classLiteralType.toFuzzyType(emptyList()))
|
||||
val kClassMatcher = { info: ExpectedInfo -> kClassTypes.matchExpectedInfo(info) }
|
||||
consumer.consume("class", kClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
|
||||
@@ -112,7 +112,7 @@ object KeywordValues {
|
||||
.singleOrNull() as? ClassDescriptor
|
||||
|
||||
if (javaLangClassDescriptor != null) {
|
||||
val javaLangClassType = KotlinTypeImpl.create(Annotations.EMPTY, javaLangClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType)))
|
||||
val javaLangClassType = KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, javaLangClassDescriptor, listOf(TypeProjectionImpl(qualifierType)))
|
||||
val javaClassTypes = listOf(javaLangClassType.toFuzzyType(emptyList()))
|
||||
val javaClassMatcher = { info: ExpectedInfo -> javaClassTypes.matchExpectedInfo(info) }
|
||||
consumer.consume("class", javaClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
|
||||
|
||||
+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.
|
||||
@@ -312,7 +312,7 @@ class TypeInstantiationItems(
|
||||
private val tail: Tail?) : InheritanceItemsSearcher {
|
||||
|
||||
private val baseHasTypeArgs = classDescriptor.declaredTypeParameters.isNotEmpty()
|
||||
private val expectedType = KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs)
|
||||
private val expectedType = KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor, typeArgs)
|
||||
private val expectedFuzzyType = expectedType.toFuzzyType(freeParameters)
|
||||
|
||||
override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) {
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ internal fun KotlinType.substitute(substitution: KotlinTypeSubstitution, varianc
|
||||
val (projection, typeParameter) = pair
|
||||
TypeProjectionImpl(Variance.INVARIANT, projection.type.substitute(substitution, typeParameter.variance))
|
||||
}
|
||||
return KotlinTypeImpl.create(annotations, constructor, isMarkedNullable, newArguments, memberScope)
|
||||
return KotlinTypeFactory.simpleType(annotations, constructor, newArguments, isMarkedNullable, memberScope)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-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.
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessT
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtForExpression
|
||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
@@ -51,11 +51,11 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor
|
||||
|
||||
val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0])
|
||||
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
|
||||
val newReturnJetType = KotlinTypeImpl.create(returnJetType.annotations,
|
||||
returnJetType.constructor,
|
||||
returnJetType.isMarkedNullable,
|
||||
returnJetTypeArguments,
|
||||
returnJetType.memberScope)
|
||||
val newReturnJetType = KotlinTypeFactory.simpleType(returnJetType.annotations,
|
||||
returnJetType.constructor,
|
||||
returnJetTypeArguments,
|
||||
returnJetType.isMarkedNullable,
|
||||
returnJetType.memberScope)
|
||||
val returnType = TypeInfo(newReturnJetType, Variance.OUT_VARIANCE)
|
||||
return FunctionInfo(OperatorNameConventions.ITERATOR.asString(), iterableType, returnType, isOperator = true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user