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");
|
* 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.
|
||||||
@@ -245,7 +245,7 @@ class CollectionStubMethodGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KotlinType {
|
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KotlinType {
|
||||||
return KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
|
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor, typeArguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FunctionDescriptor.signature(): JvmMethodGenericSignature = typeMapper.mapSignatureWithGeneric(this, OwnerKind.IMPLEMENTATION)
|
private fun FunctionDescriptor.signature(): JvmMethodGenericSignature = typeMapper.mapSignatureWithGeneric(this, OwnerKind.IMPLEMENTATION)
|
||||||
|
|||||||
+6
-6
@@ -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.
|
||||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
|||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||||
|
|
||||||
class JavaClassOnCompanionChecker : CallChecker {
|
class JavaClassOnCompanionChecker : CallChecker {
|
||||||
@@ -41,10 +41,10 @@ class JavaClassOnCompanionChecker : CallChecker {
|
|||||||
if (companionObject.isCompanionObject) {
|
if (companionObject.isCompanionObject) {
|
||||||
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
||||||
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||||
val expectedType = KotlinTypeImpl.create(
|
|
||||||
Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable,
|
val arguments = listOf(TypeProjectionImpl(containingClass.defaultType))
|
||||||
listOf(TypeProjectionImpl(containingClass.defaultType))
|
val expectedType = KotlinTypeFactory.simpleType(Annotations.EMPTY, javaLangClass.typeConstructor, arguments,
|
||||||
)
|
actualType.isMarkedNullable, javaLangClass.getMemberScope(arguments))
|
||||||
context.trace.report(ErrorsJvm.JAVA_CLASS_ON_COMPANION.on(resolvedCall.call.callElement, actualType, expectedType))
|
context.trace.report(ErrorsJvm.JAVA_CLASS_ON_COMPANION.on(resolvedCall.call.callElement, actualType, expectedType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ class TypeAliasExpander(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return if (withAbbreviatedType) {
|
return if (withAbbreviatedType) {
|
||||||
val abbreviatedType = KotlinTypeImpl.create(annotations,
|
val abbreviatedType = KotlinTypeFactory.simpleType(annotations,
|
||||||
typeAliasExpansion.descriptor.typeConstructor,
|
typeAliasExpansion.descriptor.typeConstructor,
|
||||||
originalProjection.type.isMarkedNullable,
|
typeAliasExpansion.arguments,
|
||||||
typeAliasExpansion.arguments,
|
originalProjection.type.isMarkedNullable,
|
||||||
MemberScope.Empty)
|
MemberScope.Empty)
|
||||||
|
|
||||||
expandedType.withAbbreviatedType(abbreviatedType)
|
expandedType.withAbbreviatedType(abbreviatedType)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,12 +317,11 @@ class TypeResolver(
|
|||||||
return if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
return if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
||||||
ErrorUtils.createErrorType("?")
|
ErrorUtils.createErrorType("?")
|
||||||
else
|
else
|
||||||
KotlinTypeImpl.create(
|
KotlinTypeFactory.simpleType(annotations,
|
||||||
annotations,
|
typeParameter.typeConstructor,
|
||||||
typeParameter.typeConstructor,
|
listOf(),
|
||||||
false,
|
false,
|
||||||
listOf(),
|
scopeForTypeParameter)
|
||||||
scopeForTypeParameter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getScopeForTypeParameter(c: TypeResolutionContext, typeParameterDescriptor: TypeParameterDescriptor): MemberScope {
|
private fun getScopeForTypeParameter(c: TypeResolutionContext, typeParameterDescriptor: TypeParameterDescriptor): MemberScope {
|
||||||
@@ -394,7 +393,7 @@ class TypeResolver(
|
|||||||
" but ${collectedArgumentAsTypeProjections.size} instead of ${parameters.size} found in ${element.text}"
|
" but ${collectedArgumentAsTypeProjections.size} instead of ${parameters.size} found in ${element.text}"
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultingType = KotlinTypeImpl.create(annotations, classDescriptor, false, arguments)
|
val resultingType = KotlinTypeFactory.simpleNotNullType(annotations, classDescriptor, arguments)
|
||||||
|
|
||||||
// We create flexible types by convention here
|
// We create flexible types by convention here
|
||||||
// This is not intended to be used in normal users' environments, only for tests and debugger etc
|
// This is not intended to be used in normal users' environments, only for tests and debugger etc
|
||||||
@@ -466,7 +465,7 @@ class TypeResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return if (c.abbreviated) {
|
return if (c.abbreviated) {
|
||||||
val abbreviatedType = KotlinTypeImpl.create(annotations, descriptor.typeConstructor, false, arguments, MemberScope.Empty)
|
val abbreviatedType = KotlinTypeFactory.simpleType(annotations, descriptor.typeConstructor, arguments, false, MemberScope.Empty)
|
||||||
type(abbreviatedType)
|
type(abbreviatedType)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ fun replaceReturnTypeForCallable(type: KotlinType, given: KotlinType): KotlinTyp
|
|||||||
fun replaceReturnTypeByUnknown(type: KotlinType) = replaceReturnTypeForCallable(type, DONT_CARE)
|
fun replaceReturnTypeByUnknown(type: KotlinType) = replaceReturnTypeForCallable(type, DONT_CARE)
|
||||||
|
|
||||||
private fun replaceTypeArguments(type: KotlinType, newArguments: List<TypeProjection>) =
|
private fun replaceTypeArguments(type: KotlinType, newArguments: List<TypeProjection>) =
|
||||||
KotlinTypeImpl.create(type.annotations, type.constructor, type.isMarkedNullable, newArguments, type.memberScope)
|
KotlinTypeFactory.simpleType(type.annotations, type.constructor, newArguments, type.isMarkedNullable, type.memberScope)
|
||||||
|
|
||||||
private fun getParameterArgumentsOfCallableType(type: KotlinType) =
|
private fun getParameterArgumentsOfCallableType(type: KotlinType) =
|
||||||
type.arguments.dropLast(1)
|
type.arguments.dropLast(1)
|
||||||
@@ -111,8 +111,8 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
|
|||||||
for (typeProjection in receiverType.arguments) {
|
for (typeProjection in receiverType.arguments) {
|
||||||
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.projectionKind, DONT_CARE))
|
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.projectionKind, DONT_CARE))
|
||||||
}
|
}
|
||||||
return KotlinTypeImpl.create(receiverType.annotations, receiverType.constructor, receiverType.isMarkedNullable, fakeTypeArguments,
|
return KotlinTypeFactory.simpleType(receiverType.annotations, receiverType.constructor, fakeTypeArguments,
|
||||||
ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
|
receiverType.isMarkedNullable, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boolean {
|
fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boolean {
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -17,13 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.resolve.calls.inference
|
package org.jetbrains.kotlin.resolve.calls.inference
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.Call
|
import org.jetbrains.kotlin.psi.Call
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasOnlyInputTypesAnnotation
|
import org.jetbrains.kotlin.resolve.descriptorUtil.hasOnlyInputTypesAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
|
||||||
|
|
||||||
class TypeVariable(
|
class TypeVariable(
|
||||||
val call: CallHandle,
|
val call: CallHandle,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||||
import org.jetbrains.kotlin.types.SimpleType
|
import org.jetbrains.kotlin.types.SimpleType
|
||||||
import org.jetbrains.kotlin.types.TypeProjection
|
import org.jetbrains.kotlin.types.TypeProjection
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ fun createFunctionType(
|
|||||||
AnnotationsImpl(annotations + extensionFunctionAnnotation)
|
AnnotationsImpl(annotations + extensionFunctionAnnotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
return KotlinTypeImpl.create(typeAnnotations, classDescriptor, false, arguments)
|
return KotlinTypeFactory.simpleNotNullType(typeAnnotations, classDescriptor, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getValueParametersCountFromFunctionType(type: KotlinType): Int {
|
fun getValueParametersCountFromFunctionType(type: KotlinType): Int {
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ public class CommonSupertypes {
|
|||||||
else {
|
else {
|
||||||
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
||||||
}
|
}
|
||||||
return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), constructor, nullable, newProjections, newScope);
|
return KotlinTypeFactory.simpleType(Annotations.Companion.getEMPTY(), constructor, newProjections, nullable, newScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -129,11 +129,11 @@ public class TypeIntersector {
|
|||||||
|
|
||||||
TypeConstructor constructor = new IntersectionTypeConstructor(Annotations.Companion.getEMPTY(), resultingTypes);
|
TypeConstructor constructor = new IntersectionTypeConstructor(Annotations.Companion.getEMPTY(), resultingTypes);
|
||||||
|
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleType(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
constructor,
|
constructor,
|
||||||
allNullable,
|
|
||||||
Collections.<TypeProjection>emptyList(),
|
Collections.<TypeProjection>emptyList(),
|
||||||
|
allNullable,
|
||||||
TypeIntersectionScope.create("member scope for intersection type " + constructor, resultingTypes)
|
TypeIntersectionScope.create("member scope for intersection type " + constructor, resultingTypes)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
|||||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||||
@@ -217,9 +217,10 @@ class DoubleColonExpressionResolver(
|
|||||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(expression, descriptor.typeConstructor.parameters.size, descriptor))
|
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(expression, descriptor.typeConstructor.parameters.size, descriptor))
|
||||||
}
|
}
|
||||||
|
|
||||||
KotlinTypeImpl.create(
|
val arguments = descriptor.typeConstructor.parameters.map(TypeUtils::makeStarProjection)
|
||||||
Annotations.EMPTY, descriptor, possiblyBareType.isNullable || doubleColonExpression.hasQuestionMarks,
|
KotlinTypeFactory.simpleType(
|
||||||
descriptor.typeConstructor.parameters.map(TypeUtils::makeStarProjection)
|
Annotations.EMPTY, descriptor.typeConstructor, arguments,
|
||||||
|
possiblyBareType.isNullable || doubleColonExpression.hasQuestionMarks, descriptor.getMemberScope(arguments)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+4
-5
@@ -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.
|
||||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class ConstraintSystemTestData(
|
class ConstraintSystemTestData(
|
||||||
@@ -64,9 +64,8 @@ class ConstraintSystemTestData(
|
|||||||
val matcher = INTEGER_VALUE_TYPE_PATTERN.matcher(name)
|
val matcher = INTEGER_VALUE_TYPE_PATTERN.matcher(name)
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
val number = matcher.group(1)!!
|
val number = matcher.group(1)!!
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleType(Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns),
|
||||||
Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns), false, listOf(),
|
listOf(), false, MemberScope.Empty
|
||||||
MemberScope.Empty
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return typeResolver.resolveType(
|
return typeResolver.resolveType(
|
||||||
|
|||||||
+1
-4
@@ -195,10 +195,7 @@ class LazyJavaClassDescriptor(
|
|||||||
parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.defaultType)
|
parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.defaultType)
|
||||||
}
|
}
|
||||||
|
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor, parametersAsTypeProjections)
|
||||||
Annotations.EMPTY, classDescriptor,
|
|
||||||
/* nullable =*/ false, parametersAsTypeProjections
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPurelyImplementsFqNameFromAnnotation(): FqName? {
|
private fun getPurelyImplementsFqNameFromAnnotation(): FqName? {
|
||||||
|
|||||||
+2
-3
@@ -106,9 +106,8 @@ internal object RawSubstitution : TypeSubstitution() {
|
|||||||
val arguments = listOf(
|
val arguments = listOf(
|
||||||
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
|
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
|
||||||
)
|
)
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleType(type.annotations, type.constructor, arguments,
|
||||||
type.annotations, type.constructor, type.isMarkedNullable, arguments,
|
type.isMarkedNullable, (type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
|
||||||
(type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -730,24 +730,14 @@ public abstract class KotlinBuiltIns {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public SimpleType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument) {
|
public SimpleType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument) {
|
||||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleNotNullType(Annotations.Companion.getEMPTY(), getArray(), types);
|
||||||
Annotations.Companion.getEMPTY(),
|
|
||||||
getArray(),
|
|
||||||
false,
|
|
||||||
types
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public SimpleType getEnumType(@NotNull SimpleType argument) {
|
public SimpleType getEnumType(@NotNull SimpleType argument) {
|
||||||
Variance projectionType = Variance.INVARIANT;
|
Variance projectionType = Variance.INVARIANT;
|
||||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleNotNullType(Annotations.Companion.getEMPTY(), getEnum(), types);
|
||||||
Annotations.Companion.getEMPTY(),
|
|
||||||
getEnum(),
|
|
||||||
false,
|
|
||||||
types
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -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,7 +65,7 @@ class ReflectionTypes(module: ModuleDescriptor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type))
|
val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type))
|
||||||
return KotlinTypeImpl.create(annotations, descriptor, false, arguments)
|
return KotlinTypeFactory.simpleNotNullType(annotations, descriptor, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getKFunctionType(
|
fun getKFunctionType(
|
||||||
@@ -82,7 +82,7 @@ class ReflectionTypes(module: ModuleDescriptor) {
|
|||||||
return classDescriptor.defaultType
|
return classDescriptor.defaultType
|
||||||
}
|
}
|
||||||
|
|
||||||
return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments)
|
return KotlinTypeFactory.simpleNotNullType(annotations, classDescriptor, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getKPropertyType(annotations: Annotations, receiverType: KotlinType?, returnType: KotlinType, mutable: Boolean): KotlinType {
|
fun getKPropertyType(annotations: Annotations, receiverType: KotlinType?, returnType: KotlinType, mutable: Boolean): KotlinType {
|
||||||
@@ -107,7 +107,7 @@ class ReflectionTypes(module: ModuleDescriptor) {
|
|||||||
arguments.add(TypeProjectionImpl(receiverType))
|
arguments.add(TypeProjectionImpl(receiverType))
|
||||||
}
|
}
|
||||||
arguments.add(TypeProjectionImpl(returnType))
|
arguments.add(TypeProjectionImpl(returnType))
|
||||||
return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments)
|
return KotlinTypeFactory.simpleNotNullType(annotations, classDescriptor, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -130,10 +130,8 @@ class ReflectionTypes(module: ModuleDescriptor) {
|
|||||||
|
|
||||||
fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? {
|
fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? {
|
||||||
val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null
|
val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kPropertyClass,
|
||||||
Annotations.EMPTY, kPropertyClass, false,
|
listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single())))
|
||||||
listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single()))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ class FunctionClassDescriptor(
|
|||||||
TypeProjectionImpl(it.defaultType)
|
TypeProjectionImpl(it.defaultType)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(KotlinTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments))
|
result.add(KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, descriptor, arguments))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add unnumbered base class, e.g. Function for Function{n}, KFunction for KFunction{n}
|
// Add unnumbered base class, e.g. Function for Function{n}, KFunction for KFunction{n}
|
||||||
|
|||||||
+2
-2
@@ -68,9 +68,9 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
|||||||
this.defaultType = storageManager.createLazyValue(new Function0<SimpleType>() {
|
this.defaultType = storageManager.createLazyValue(new Function0<SimpleType>() {
|
||||||
@Override
|
@Override
|
||||||
public SimpleType invoke() {
|
public SimpleType invoke() {
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleType(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
getTypeConstructor(), false, Collections.<TypeProjection>emptyList(),
|
getTypeConstructor(), Collections.<TypeProjection>emptyList(), false,
|
||||||
new LazyScopeAdapter(storageManager.createLazyValue(
|
new LazyScopeAdapter(storageManager.createLazyValue(
|
||||||
new Function0<MemberScope>() {
|
new Function0<MemberScope>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-6
@@ -132,12 +132,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
@Override
|
@Override
|
||||||
public SimpleType getDefaultType() {
|
public SimpleType getDefaultType() {
|
||||||
List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters());
|
List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters());
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleNotNullType(getAnnotations(), this, typeProjections);
|
||||||
getAnnotations(),
|
|
||||||
this,
|
|
||||||
false,
|
|
||||||
typeProjections
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ class CapturedType(
|
|||||||
private val delegateType = run {
|
private val delegateType = run {
|
||||||
val scope = ErrorUtils.createErrorScope(
|
val scope = ErrorUtils.createErrorScope(
|
||||||
"No member resolution should be done on captured type, it used only during constraint system resolution", true)
|
"No member resolution should be done on captured type, it used only during constraint system resolution", true)
|
||||||
KotlinTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope)
|
KotlinTypeFactory.simpleType(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), listOf(), false, scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDelegate(): KotlinType = delegateType
|
override fun getDelegate(): KotlinType = delegateType
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -99,9 +99,8 @@ class IntegerValueTypeConstant(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val unknownIntegerType = KotlinTypeImpl.create(
|
val unknownIntegerType = KotlinTypeFactory.simpleType(Annotations.EMPTY, typeConstructor, emptyList<TypeProjection>(),
|
||||||
Annotations.EMPTY, typeConstructor, false, emptyList<TypeProjection>(),
|
false, ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
|
||||||
ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
|
object KotlinTypeFactory {
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun simpleType(
|
||||||
|
annotations: Annotations,
|
||||||
|
constructor: TypeConstructor,
|
||||||
|
arguments: List<TypeProjection>,
|
||||||
|
nullable: Boolean,
|
||||||
|
memberScope: MemberScope
|
||||||
|
): SimpleType = KotlinTypeImpl.create(annotations, constructor, nullable, arguments, memberScope)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun simpleNotNullType(
|
||||||
|
annotations: Annotations,
|
||||||
|
descriptor: ClassDescriptor,
|
||||||
|
arguments: List<TypeProjection>
|
||||||
|
): SimpleType = KotlinTypeImpl.create(annotations, descriptor.typeConstructor, false, arguments, descriptor.getMemberScope(arguments))
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun simpleType(
|
||||||
|
baseType: SimpleType,
|
||||||
|
annotations: Annotations = baseType.annotations,
|
||||||
|
constructor: TypeConstructor = baseType.constructor,
|
||||||
|
arguments: List<TypeProjection> = baseType.arguments,
|
||||||
|
nullable: Boolean = baseType.isMarkedNullable,
|
||||||
|
memberScope: MemberScope = baseType.memberScope
|
||||||
|
): SimpleType = simpleType(annotations, constructor, arguments, nullable, memberScope)
|
||||||
|
}
|
||||||
@@ -30,6 +30,8 @@ private constructor(
|
|||||||
) : AbstractKotlinType(), SimpleType {
|
) : AbstractKotlinType(), SimpleType {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
@Deprecated("", ReplaceWith("KotlinTypeFactory.simpleType(annotations, constructor, arguments, nullable, memberScope)", "org.jetbrains.kotlin.types.KotlinTypeFactory"))
|
||||||
@JvmStatic fun create(annotations: Annotations,
|
@JvmStatic fun create(annotations: Annotations,
|
||||||
constructor: TypeConstructor,
|
constructor: TypeConstructor,
|
||||||
nullable: Boolean,
|
nullable: Boolean,
|
||||||
@@ -51,6 +53,7 @@ private constructor(
|
|||||||
return KotlinTypeImpl(annotations, constructor, nullable, arguments, memberScope)
|
return KotlinTypeImpl(annotations, constructor, nullable, arguments, memberScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("", ReplaceWith("KotlinTypeFactory.simpleType(annotations, descriptor, arguments, nullable)", "org.jetbrains.kotlin.types.KotlinTypeFactory"))
|
||||||
@JvmStatic fun create(annotations: Annotations,
|
@JvmStatic fun create(annotations: Annotations,
|
||||||
descriptor: ClassDescriptor,
|
descriptor: ClassDescriptor,
|
||||||
nullable: Boolean,
|
nullable: Boolean,
|
||||||
|
|||||||
@@ -250,11 +250,11 @@ public class TypeUtils {
|
|||||||
}
|
}
|
||||||
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
|
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
|
||||||
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
|
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleType(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
typeConstructor,
|
typeConstructor,
|
||||||
false,
|
|
||||||
arguments,
|
arguments,
|
||||||
|
false,
|
||||||
unsubstitutedMemberScope
|
unsubstitutedMemberScope
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -58,12 +58,11 @@ fun KotlinType.approximateFlexibleTypes(preferNotNull: Boolean = false): KotlinT
|
|||||||
|
|
||||||
return approximation
|
return approximation
|
||||||
}
|
}
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeFactory.simpleType(annotations,
|
||||||
annotations,
|
constructor,
|
||||||
constructor,
|
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||||
isMarkedNullable,
|
isMarkedNullable,
|
||||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
||||||
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");
|
* 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.
|
||||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.idea.util.CallTypeAndReceiver
|
|||||||
import org.jetbrains.kotlin.idea.util.toFuzzyType
|
import org.jetbrains.kotlin.idea.util.toFuzzyType
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
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.TypeProjectionImpl
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||||
@@ -100,7 +100,7 @@ object KeywordValues {
|
|||||||
|
|
||||||
if (qualifierType != null) {
|
if (qualifierType != null) {
|
||||||
val kClassDescriptor = resolutionFacade.getFrontendService(ReflectionTypes::class.java).kClass
|
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 kClassTypes = listOf(classLiteralType.toFuzzyType(emptyList()))
|
||||||
val kClassMatcher = { info: ExpectedInfo -> kClassTypes.matchExpectedInfo(info) }
|
val kClassMatcher = { info: ExpectedInfo -> kClassTypes.matchExpectedInfo(info) }
|
||||||
consumer.consume("class", kClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
|
consumer.consume("class", kClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
|
||||||
@@ -112,7 +112,7 @@ object KeywordValues {
|
|||||||
.singleOrNull() as? ClassDescriptor
|
.singleOrNull() as? ClassDescriptor
|
||||||
|
|
||||||
if (javaLangClassDescriptor != null) {
|
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 javaClassTypes = listOf(javaLangClassType.toFuzzyType(emptyList()))
|
||||||
val javaClassMatcher = { info: ExpectedInfo -> javaClassTypes.matchExpectedInfo(info) }
|
val javaClassMatcher = { info: ExpectedInfo -> javaClassTypes.matchExpectedInfo(info) }
|
||||||
consumer.consume("class", javaClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) {
|
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");
|
* 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.
|
||||||
@@ -312,7 +312,7 @@ class TypeInstantiationItems(
|
|||||||
private val tail: Tail?) : InheritanceItemsSearcher {
|
private val tail: Tail?) : InheritanceItemsSearcher {
|
||||||
|
|
||||||
private val baseHasTypeArgs = classDescriptor.declaredTypeParameters.isNotEmpty()
|
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)
|
private val expectedFuzzyType = expectedType.toFuzzyType(freeParameters)
|
||||||
|
|
||||||
override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) {
|
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
|
val (projection, typeParameter) = pair
|
||||||
TypeProjectionImpl(Variance.INVARIANT, projection.type.substitute(substitution, typeParameter.variance))
|
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");
|
* 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,7 +26,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessT
|
|||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtForExpression
|
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.TypeProjectionImpl
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
@@ -51,11 +51,11 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor
|
|||||||
|
|
||||||
val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0])
|
val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0])
|
||||||
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
|
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
|
||||||
val newReturnJetType = KotlinTypeImpl.create(returnJetType.annotations,
|
val newReturnJetType = KotlinTypeFactory.simpleType(returnJetType.annotations,
|
||||||
returnJetType.constructor,
|
returnJetType.constructor,
|
||||||
returnJetType.isMarkedNullable,
|
returnJetTypeArguments,
|
||||||
returnJetTypeArguments,
|
returnJetType.isMarkedNullable,
|
||||||
returnJetType.memberScope)
|
returnJetType.memberScope)
|
||||||
val returnType = TypeInfo(newReturnJetType, Variance.OUT_VARIANCE)
|
val returnType = TypeInfo(newReturnJetType, Variance.OUT_VARIANCE)
|
||||||
return FunctionInfo(OperatorNameConventions.ITERATOR.asString(), iterableType, returnType, isOperator = true)
|
return FunctionInfo(OperatorNameConventions.ITERATOR.asString(), iterableType, returnType, isOperator = true)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||||
import org.jetbrains.kotlin.types.StarProjectionImpl
|
import org.jetbrains.kotlin.types.StarProjectionImpl
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||||
|
|
||||||
@@ -65,8 +65,8 @@ internal fun genPropertyForWidget(
|
|||||||
if (defaultType.constructor.parameters.isEmpty())
|
if (defaultType.constructor.parameters.isEmpty())
|
||||||
defaultType
|
defaultType
|
||||||
else
|
else
|
||||||
KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false,
|
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor,
|
||||||
defaultType.constructor.parameters.map { StarProjectionImpl(it) })
|
defaultType.constructor.parameters.map { StarProjectionImpl(it) })
|
||||||
} ?: context.viewType
|
} ?: context.viewType
|
||||||
|
|
||||||
return genProperty(resolvedWidget.widget.id, receiverType, type, packageFragmentDescriptor, sourceEl, resolvedWidget.errorType)
|
return genProperty(resolvedWidget.widget.id, receiverType, type, packageFragmentDescriptor, sourceEl, resolvedWidget.errorType)
|
||||||
|
|||||||
Reference in New Issue
Block a user