Make constructor of JetTypeImpl private, introduce factory methods

This commit is contained in:
Denis Zharkov
2015-08-03 17:55:00 +03:00
parent 101ab03721
commit 460c719753
29 changed files with 90 additions and 65 deletions
@@ -209,8 +209,7 @@ class CollectionStubMethodGenerator(
} }
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): JetType { private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): JetType {
return JetTypeImpl(Annotations.EMPTY, classDescriptor.getTypeConstructor(), false, typeArguments, return JetTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
classDescriptor.getMemberScope(typeArguments))
} }
private fun FunctionDescriptor.signature(): JvmMethodSignature = typeMapper.mapSignature(this) private fun FunctionDescriptor.signature(): JvmMethodSignature = typeMapper.mapSignature(this)
@@ -76,7 +76,7 @@ public class SingleAbstractMethodUtils {
} }
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor(); ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
assert classifier instanceof ClassDescriptor : "Not class: " + classifier; assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
return new JetTypeImpl( return JetTypeImpl.create(
functionType.getAnnotations(), functionType.getAnnotations(),
functionType.getConstructor(), functionType.getConstructor(),
functionType.isMarkedNullable(), functionType.isMarkedNullable(),
@@ -61,7 +61,7 @@ class PropagationHeuristics {
if (JetTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper) if (JetTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
&& !JetTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) { && !JetTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
JetTypeImpl betterTypeInSuper = new JetTypeImpl( JetTypeImpl betterTypeInSuper = JetTypeImpl.create(
arrayTypeFromSuper.getAnnotations(), arrayTypeFromSuper.getAnnotations(),
arrayTypeFromSuper.getConstructor(), arrayTypeFromSuper.getConstructor(),
arrayTypeFromSuper.isMarkedNullable(), arrayTypeFromSuper.isMarkedNullable(),
@@ -407,7 +407,7 @@ public class SignaturesPropagationData {
resultScope = autoType.getMemberScope(); resultScope = autoType.getMemberScope();
} }
JetTypeImpl type = new JetTypeImpl(autoType.getAnnotations(), JetType type = JetTypeImpl.create(autoType.getAnnotations(),
resultClassifier.getTypeConstructor(), resultClassifier.getTypeConstructor(),
resultNullable, resultNullable,
resultArguments, resultArguments,
@@ -157,8 +157,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
throw new AssertionError("Unexpected class of type constructor classifier " throw new AssertionError("Unexpected class of type constructor classifier "
+ (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName())); + (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName()));
} }
return new JetTypeImpl(originalType.getAnnotations(), typeConstructor, false, return JetTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
altArguments, memberScope);
} }
@NotNull @NotNull
@@ -137,7 +137,7 @@ public class TypeResolver(
result = if (scopeForTypeParameter is ErrorUtils.ErrorScope) result = if (scopeForTypeParameter is ErrorUtils.ErrorScope)
type(ErrorUtils.createErrorType("?")) type(ErrorUtils.createErrorType("?"))
else else
type(JetTypeImpl( type(JetTypeImpl.create(
annotations, annotations,
classifierDescriptor.getTypeConstructor(), classifierDescriptor.getTypeConstructor(),
TypeUtils.hasNullableLowerBound(classifierDescriptor), TypeUtils.hasNullableLowerBound(classifierDescriptor),
@@ -191,7 +191,7 @@ public class TypeResolver(
) )
return return
} }
val resultingType = JetTypeImpl(annotations, typeConstructor, false, arguments, classifierDescriptor.getMemberScope(arguments)) val resultingType = JetTypeImpl.create(annotations, classifierDescriptor, false, arguments)
result = type(resultingType) result = type(resultingType)
if (c.checkBounds) { if (c.checkBounds) {
val substitutor = TypeSubstitutor.create(resultingType) val substitutor = TypeSubstitutor.create(resultingType)
@@ -64,7 +64,7 @@ public fun replaceReturnTypeByUnknown(type: JetType): JetType {
} }
private fun replaceTypeArguments(type: JetType, newArguments: List<TypeProjection>) = private fun replaceTypeArguments(type: JetType, newArguments: List<TypeProjection>) =
JetTypeImpl(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()) JetTypeImpl.create(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope())
private fun getParameterArgumentsOfCallableType(type: JetType) = private fun getParameterArgumentsOfCallableType(type: JetType) =
type.getArguments().dropLast(1) type.getArguments().dropLast(1)
@@ -100,7 +100,7 @@ public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterD
for (typeProjection in receiverType.getArguments()) { for (typeProjection in receiverType.getArguments()) {
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE)) fakeTypeArguments.add(TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE))
} }
return JetTypeImpl(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments, return JetTypeImpl.create(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments,
ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)) ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
} }
@@ -578,7 +578,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
} }
}); });
return new JetTypeImpl(Annotations.EMPTY, typeConstructor, false, arguments, descriptor.getMemberScope(arguments)); return JetTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments);
} }
private static boolean isAllowedInClassLiteral(@NotNull JetType type) { private static boolean isAllowedInClassLiteral(@NotNull JetType type) {
@@ -60,7 +60,10 @@ public 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 JetTypeImpl(Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), KotlinBuiltIns.getInstance()), false, listOf(), JetScope.Empty) return JetTypeImpl.create(
Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), KotlinBuiltIns.getInstance()), false, listOf(),
JetScope.Empty
)
} }
return typeResolver.resolveType( return typeResolver.resolveType(
scopeToResolveTypeParameters, JetPsiFactory(project).createType(name), scopeToResolveTypeParameters, JetPsiFactory(project).createType(name),
@@ -168,10 +168,9 @@ class LazyJavaClassDescriptor(
parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType()) parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType())
} }
return JetTypeImpl( return JetTypeImpl.create(
Annotations.EMPTY, classDescriptor.getTypeConstructor(), Annotations.EMPTY, classDescriptor,
/* nullable =*/ false, parametersAsTypeProjections, /* nullable =*/ false, parametersAsTypeProjections
classDescriptor.getMemberScope(parametersAsTypeProjections)
) )
} }
@@ -289,14 +289,14 @@ class LazyJavaTypeResolver(
val arguments = listOf( val arguments = listOf(
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type)) TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
) )
return JetTypeImpl( return JetTypeImpl.create(
type.annotations, type.constructor, type.isMarkedNullable, arguments, type.annotations, type.constructor, type.isMarkedNullable, arguments,
(type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments) (type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
) )
} }
val constructor = type.constructor val constructor = type.constructor
return JetTypeImpl( return JetTypeImpl.create(
type.annotations, constructor, type.isMarkedNullable, type.annotations, constructor, type.isMarkedNullable,
type.constructor.parameters.map { type.constructor.parameters.map {
parameter -> computeProjection(parameter, attr) parameter -> computeProjection(parameter, attr)
@@ -102,7 +102,7 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i
typeConstructor.parameters, enhancedArguments typeConstructor.parameters, enhancedArguments
) )
val enhancedType = JetTypeImpl( val enhancedType = JetTypeImpl.create(
newAnnotations, newAnnotations,
typeConstructor, typeConstructor,
enhancedNullability, enhancedNullability,
@@ -664,12 +664,11 @@ public class KotlinBuiltIns {
@NotNull @NotNull
public JetType getArrayType(@NotNull Variance projectionType, @NotNull JetType argument) { public JetType getArrayType(@NotNull Variance projectionType, @NotNull JetType argument) {
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
return new JetTypeImpl( return JetTypeImpl.create(
Annotations.EMPTY, Annotations.EMPTY,
getArray().getTypeConstructor(), getArray(),
false, false,
types, types
getArray().getMemberScope(types)
); );
} }
@@ -677,12 +676,11 @@ public class KotlinBuiltIns {
public JetType getEnumType(@NotNull JetType argument) { public JetType getEnumType(@NotNull JetType 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 new JetTypeImpl( return JetTypeImpl.create(
Annotations.EMPTY, Annotations.EMPTY,
getEnum().getTypeConstructor(), getEnum(),
false, false,
types, types
getEnum().getMemberScope(types)
); );
} }
@@ -721,11 +719,10 @@ public class KotlinBuiltIns {
List<TypeProjection> arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType); List<TypeProjection> arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType);
int size = parameterTypes.size(); int size = parameterTypes.size();
ClassDescriptor classDescriptor = receiverType == null ? getFunction(size) : getExtensionFunction(size); ClassDescriptor classDescriptor = receiverType == null ? getFunction(size) : getExtensionFunction(size);
TypeConstructor constructor = classDescriptor.getTypeConstructor();
Annotations typeAnnotations = receiverType == null ? annotations : addExtensionAnnotation(annotations); Annotations typeAnnotations = receiverType == null ? annotations : addExtensionAnnotation(annotations);
return new JetTypeImpl(typeAnnotations, constructor, false, arguments, classDescriptor.getMemberScope(arguments)); return JetTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
} }
@NotNull @NotNull
@@ -63,7 +63,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
} }
val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type)) val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type))
return JetTypeImpl(annotations, descriptor.getTypeConstructor(), false, arguments, descriptor.getMemberScope(arguments)) return JetTypeImpl.create(annotations, descriptor, false, arguments)
} }
public fun getKFunctionType( public fun getKFunctionType(
@@ -80,7 +80,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
return classDescriptor.getDefaultType() return classDescriptor.getDefaultType()
} }
return JetTypeImpl(annotations, classDescriptor.getTypeConstructor(), false, arguments, classDescriptor.getMemberScope(arguments)) return JetTypeImpl.create(annotations, classDescriptor, false, arguments)
} }
public fun getKPropertyType(annotations: Annotations, receiverType: JetType?, returnType: JetType, mutable: Boolean): JetType { public fun getKPropertyType(annotations: Annotations, receiverType: JetType?, returnType: JetType, mutable: Boolean): JetType {
@@ -105,7 +105,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
arguments.add(TypeProjectionImpl(receiverType)) arguments.add(TypeProjectionImpl(receiverType))
} }
arguments.add(TypeProjectionImpl(returnType)) arguments.add(TypeProjectionImpl(returnType))
return JetTypeImpl(annotations, classDescriptor.getTypeConstructor(), false, arguments, classDescriptor.getMemberScope(arguments)) return JetTypeImpl.create(annotations, classDescriptor, false, arguments)
} }
companion object { companion object {
@@ -119,7 +119,7 @@ public class FunctionClassDescriptor(
TypeProjectionImpl(it.getDefaultType()) TypeProjectionImpl(it.getDefaultType())
} }
result.add(JetTypeImpl(Annotations.EMPTY, typeConstructor, false, arguments, descriptor.getMemberScope(arguments))) result.add(JetTypeImpl.create(Annotations.EMPTY, descriptor, false, 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}
@@ -71,7 +71,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
this.defaultType = storageManager.createLazyValue(new Function0<JetType>() { this.defaultType = storageManager.createLazyValue(new Function0<JetType>() {
@Override @Override
public JetType invoke() { public JetType invoke() {
return new JetTypeImpl(Annotations.EMPTY, getTypeConstructor(), false, Collections.<TypeProjection>emptyList(), return JetTypeImpl.create(Annotations.EMPTY, getTypeConstructor(), false, Collections.<TypeProjection>emptyList(),
new LazyScopeAdapter(storageManager.createLazyValue( new LazyScopeAdapter(storageManager.createLazyValue(
new Function0<JetScope>() { new Function0<JetScope>() {
@Override @Override
@@ -127,12 +127,12 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
@Override @Override
public JetType getDefaultType() { public JetType getDefaultType() {
List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters()); List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters());
return new JetTypeImpl( return JetTypeImpl.create(
getAnnotations(), getAnnotations(),
getTypeConstructor(), this,
false, false,
typeProjections, typeProjections
getMemberScope(typeProjections)); );
} }
@NotNull @NotNull
@@ -60,7 +60,7 @@ public 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)
JetTypeImpl(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope) JetTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope)
} }
override fun getDelegate(): JetType = delegateType override fun getDelegate(): JetType = delegateType
@@ -161,7 +161,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
val TypeParameterDescriptor.correspondingType: JetType val TypeParameterDescriptor.correspondingType: JetType
get() = cachedTypeForVariable.getOrPut(this) { get() = cachedTypeForVariable.getOrPut(this) {
JetTypeImpl(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), JetScope.Empty) JetTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), JetScope.Empty)
} }
fun JetType.isProper() = !TypeUtils.containsSpecialType(this) { fun JetType.isProper() = !TypeUtils.containsSpecialType(this) {
@@ -548,7 +548,7 @@ public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypePa
if (descriptor !is TypeParameterDescriptor) return null if (descriptor !is TypeParameterDescriptor) return null
val typeParameterDescriptor = conversion(descriptor) ?: return null val typeParameterDescriptor = conversion(descriptor) ?: return null
val type = JetTypeImpl(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty) val type = JetTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty)
return TypeProjectionImpl(type) return TypeProjectionImpl(type)
} }
}) })
@@ -81,7 +81,7 @@ public class IntegerValueTypeConstant(
} }
} }
val unknownIntegerType = JetTypeImpl( val unknownIntegerType = JetTypeImpl.create(
Annotations.EMPTY, typeConstructor, false, emptyList<TypeProjection>(), Annotations.EMPTY, typeConstructor, false, emptyList<TypeProjection>(),
ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
) )
@@ -120,7 +120,9 @@ public fun approximateCapturedTypes(type: JetType): ApproximationBounds<JetType>
private fun JetType.replaceTypeArguments(newTypeArguments: List<TypeArgument>): JetType { private fun JetType.replaceTypeArguments(newTypeArguments: List<TypeArgument>): JetType {
assert(getArguments().size() == newTypeArguments.size()) { "Incorrect type arguments $newTypeArguments" } assert(getArguments().size() == newTypeArguments.size()) { "Incorrect type arguments $newTypeArguments" }
return JetTypeImpl(getAnnotations(), getConstructor(), isMarkedNullable(), newTypeArguments.map { it.toTypeProjection() }, getMemberScope()) return JetTypeImpl.create(
getAnnotations(), getConstructor(), isMarkedNullable(), newTypeArguments.map { it.toTypeProjection() }, getMemberScope()
)
} }
private fun approximateProjection(typeArgument: TypeArgument): ApproximationBounds<TypeArgument> { private fun approximateProjection(typeArgument: TypeArgument): ApproximationBounds<TypeArgument> {
@@ -238,7 +238,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 new JetTypeImpl(Annotations.EMPTY, constructor, nullable, newProjections, newScope); return JetTypeImpl.create(Annotations.EMPTY, constructor, nullable, newProjections, newScope);
} }
@NotNull @NotNull
@@ -16,10 +16,13 @@
package org.jetbrains.kotlin.types package org.jetbrains.kotlin.types
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.JetScope
import kotlin.platform.platformStatic
public class JetTypeImpl( public class JetTypeImpl
private constructor(
private val annotations: Annotations, private val annotations: Annotations,
private val constructor: TypeConstructor, private val constructor: TypeConstructor,
private val nullable: Boolean, private val nullable: Boolean,
@@ -27,20 +30,44 @@ public class JetTypeImpl(
private val substitution: TypeSubstitution?, private val substitution: TypeSubstitution?,
private val memberScope: JetScope private val memberScope: JetScope
) : AbstractJetType() { ) : AbstractJetType() {
companion object {
@platformStatic
public fun create(annotations: Annotations,
constructor: TypeConstructor,
nullable: Boolean,
arguments: List<TypeProjection>,
memberScope: JetScope): JetTypeImpl
= JetTypeImpl(annotations, constructor, nullable, arguments, null, memberScope)
@platformStatic
public fun create(annotations: Annotations,
constructor: TypeConstructor,
nullable: Boolean,
arguments: List<TypeProjection>,
substitution: TypeSubstitution,
memberScope: JetScope): JetTypeImpl
= JetTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope)
@platformStatic
public fun create(annotations: Annotations,
descriptor: ClassDescriptor,
nullable: Boolean,
arguments: List<TypeProjection>): JetTypeImpl
= JetTypeImpl(
annotations, descriptor.typeConstructor, nullable, arguments, null, descriptor.getMemberScope(arguments)
)
}
init { init {
if (memberScope is ErrorUtils.ErrorScope) { if (memberScope is ErrorUtils.ErrorScope) {
throw IllegalStateException("JetTypeImpl should not be created for error type: $memberScope\n$constructor") throw IllegalStateException("JetTypeImpl should not be created for error type: $memberScope\n$constructor")
} }
} }
public constructor(
annotations: Annotations,
constructor: TypeConstructor,
nullable: Boolean,
arguments: List<TypeProjection>,
memberScope: JetScope
) : this(annotations, constructor, nullable, arguments, null, memberScope)
override fun getAnnotations() = annotations override fun getAnnotations() = annotations
override fun getSubstitution(): TypeSubstitution { override fun getSubstitution(): TypeSubstitution {
@@ -226,9 +226,9 @@ public class TypeSubstitutor {
return substitution.isEmpty(); return substitution.isEmpty();
} }
}; };
JetType substitutedType = new JetTypeImpl(type.getAnnotations(), // Old annotations. This is questionable JetType substitutedType = JetTypeImpl.create(type.getAnnotations(), // Old annotations. This is questionable
type.getConstructor(), // The same constructor type.getConstructor(), // The same constructor
type.isMarkedNullable(), // Same nullability type.isMarkedNullable(), // Same nullability
substitutedArguments, substitutedArguments,
new SubstitutingScope(type.getMemberScope(), create(substitutionFilteringTypeParameters))); new SubstitutingScope(type.getMemberScope(), create(substitutionFilteringTypeParameters)));
return new TypeProjectionImpl(projectionKind, substitutedType); return new TypeProjectionImpl(projectionKind, substitutedType);
@@ -259,7 +259,7 @@ public class TypeUtils {
i++; i++;
} }
return new JetTypeImpl( return JetTypeImpl.create(
Annotations.EMPTY, Annotations.EMPTY,
constructor, constructor,
allNullable, allNullable,
@@ -415,7 +415,7 @@ public class TypeUtils {
} }
TypeConstructor typeConstructor = classDescriptor.getTypeConstructor(); TypeConstructor typeConstructor = classDescriptor.getTypeConstructor();
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters()); List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
return new JetTypeImpl( return JetTypeImpl.create(
Annotations.EMPTY, Annotations.EMPTY,
typeConstructor, typeConstructor,
false, false,
@@ -57,7 +57,7 @@ public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true)
return approximation return approximation
} }
return JetTypeImpl( return JetTypeImpl.create(
jetType.getAnnotations(), jetType.getAnnotations(),
jetType.getConstructor(), jetType.getConstructor(),
jetType.isMarkedNullable(), jetType.isMarkedNullable(),
@@ -265,9 +265,8 @@ class TypeInstantiationItems(
val typeArgs: List<TypeProjection>, val typeArgs: List<TypeProjection>,
val tail: Tail?) : InheritanceItemsSearcher { val tail: Tail?) : InheritanceItemsSearcher {
private val typeConstructor = classDescriptor.getTypeConstructor() private val baseHasTypeArgs = classDescriptor.typeConstructor.parameters.isNotEmpty()
private val baseHasTypeArgs = typeConstructor.getParameters().isNotEmpty() private val expectedType = JetTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs)
private val expectedType = JetTypeImpl(Annotations.EMPTY, typeConstructor, false, typeArgs, classDescriptor.getMemberScope(typeArgs))
override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) { override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) {
val parameters = ClassInheritorsSearch.SearchParameters(psiClass, inheritorSearchScope, true, true, false, nameFilter) val parameters = ClassInheritorsSearch.SearchParameters(psiClass, inheritorSearchScope, true, true, false, nameFilter)
@@ -224,7 +224,7 @@ private fun JetType.substitute(substitution: JetTypeSubstitution, variance: Vari
val (projection, typeParameter) = pair val (projection, typeParameter) = pair
TypeProjectionImpl(Variance.INVARIANT, projection.getType().substitute(substitution, typeParameter.getVariance())) TypeProjectionImpl(Variance.INVARIANT, projection.getType().substitute(substitution, typeParameter.getVariance()))
} }
return JetTypeImpl(getAnnotations(), getConstructor(), isMarkedNullable(), newArguments, getMemberScope()) return JetTypeImpl.create(getAnnotations(), getConstructor(), isMarkedNullable(), newArguments, getMemberScope())
} }
} }
@@ -50,7 +50,7 @@ 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 = JetTypeImpl(returnJetType.annotations, val newReturnJetType = JetTypeImpl.create(returnJetType.annotations,
returnJetType.constructor, returnJetType.constructor,
returnJetType.isMarkedNullable, returnJetType.isMarkedNullable,
returnJetTypeArguments, returnJetTypeArguments,