Refactoring. Remove type capability Flexibility.
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.
|
||||
@@ -180,9 +180,9 @@ public abstract class AnnotationCodegen {
|
||||
|
||||
if (FlexibleTypesKt.isFlexible(type)) {
|
||||
// A flexible type whose lower bound in not-null and upper bound is nullable, should not be annotated
|
||||
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
||||
FlexibleType flexibleType = FlexibleTypesKt.asFlexibleType(type);
|
||||
|
||||
if (!TypeUtils.isNullableType(flexibility.getLowerBound()) && TypeUtils.isNullableType(flexibility.getUpperBound())) {
|
||||
if (!TypeUtils.isNullableType(flexibleType.getLowerBound()) && TypeUtils.isNullableType(flexibleType.getUpperBound())) {
|
||||
AnnotationDescriptor notNull = type.getAnnotations().findAnnotation(JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION);
|
||||
if (notNull != null) {
|
||||
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, NotNull.class);
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.jvm
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.asFlexibleType
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
object JvmTypeSpecificityComparator : TypeSpecificityComparator {
|
||||
@@ -28,7 +28,7 @@ object JvmTypeSpecificityComparator : TypeSpecificityComparator {
|
||||
if (!specific.isFlexible() || general.isFlexible()) return false
|
||||
|
||||
// general is inflexible
|
||||
val flexibility = specific.flexibility()
|
||||
val flexibility = specific.asFlexibleType()
|
||||
|
||||
// For primitive types we have to take care of the case when there are two overloaded methods like
|
||||
// foo(int) and foo(Integer)
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.asFlexibleType
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
class WhenByPlatformEnumChecker : AdditionalTypeChecker {
|
||||
@@ -34,7 +34,7 @@ class WhenByPlatformEnumChecker : AdditionalTypeChecker {
|
||||
if (expression is KtWhenExpression && expression.elseExpression == null) {
|
||||
// Check for conditionally-exhaustive when on platform enums, see KT-6399
|
||||
val type = expression.subjectExpression?.let { c.trace.getType(it) } ?: return
|
||||
if (type.isFlexible() && TypeUtils.isNullableType(type.flexibility().upperBound) && !type.annotations.isMarkedNotNull()) {
|
||||
if (type.isFlexible() && TypeUtils.isNullableType(type.asFlexibleType().upperBound) && !type.annotations.isMarkedNotNull()) {
|
||||
val enumClassDescriptor = WhenChecker.getClassDescriptorOfTypeIfEnum(type) ?: return
|
||||
val context = c.trace.bindingContext
|
||||
if (WhenChecker.getEnumMissingCases(expression, context, enumClassDescriptor).isEmpty()
|
||||
|
||||
+2
-2
@@ -45,8 +45,8 @@ object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
// optimization: if no arguments or flexibility, everything is OK
|
||||
if (expectedType.arguments.isEmpty() || !expectedType.isFlexible()) return
|
||||
|
||||
val lowerBound = expectedType.flexibility().lowerBound
|
||||
val upperBound = expectedType.flexibility().upperBound
|
||||
val lowerBound = expectedType.asFlexibleType().lowerBound
|
||||
val upperBound = expectedType.asFlexibleType().upperBound
|
||||
|
||||
// Use site variance projection is always the same for flexible types
|
||||
if (lowerBound.constructor == upperBound.constructor) return
|
||||
|
||||
@@ -1151,9 +1151,9 @@ public class DescriptorResolver {
|
||||
: "Flexible type cannot be denoted in Kotlin otherwise than as ft<T1, T2>, but was: "
|
||||
+ PsiUtilsKt.getElementTextWithContext(typeReference);
|
||||
// it's really ft<Foo, Bar>
|
||||
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
||||
checkBounds(jetTypeArguments.get(0), flexibility.getLowerBound(), trace);
|
||||
checkBounds(jetTypeArguments.get(1), flexibility.getUpperBound(), trace);
|
||||
FlexibleType flexibleType = FlexibleTypesKt.asFlexibleType(type);
|
||||
checkBounds(jetTypeArguments.get(0), flexibleType.getLowerBound(), trace);
|
||||
checkBounds(jetTypeArguments.get(1), flexibleType.getUpperBound(), trace);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,8 +156,8 @@ class TypeResolver(
|
||||
private fun forceResolveTypeContents(type: KotlinType) {
|
||||
type.annotations // force read type annotations
|
||||
if (type.isFlexible()) {
|
||||
forceResolveTypeContents(type.flexibility().lowerBound)
|
||||
forceResolveTypeContents(type.flexibility().upperBound)
|
||||
forceResolveTypeContents(type.asFlexibleType().lowerBound)
|
||||
forceResolveTypeContents(type.asFlexibleType().upperBound)
|
||||
}
|
||||
else {
|
||||
type.constructor // force read type constructor
|
||||
|
||||
@@ -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.
|
||||
@@ -98,8 +98,8 @@ public class ForceResolveUtil {
|
||||
|
||||
forceResolveAllContents(type.getAnnotations());
|
||||
if (FlexibleTypesKt.isFlexible(type)) {
|
||||
forceResolveAllContents(FlexibleTypesKt.flexibility(type).getLowerBound());
|
||||
forceResolveAllContents(FlexibleTypesKt.flexibility(type).getUpperBound());
|
||||
forceResolveAllContents(FlexibleTypesKt.asFlexibleType(type).getLowerBound());
|
||||
forceResolveAllContents(FlexibleTypesKt.asFlexibleType(type).getUpperBound());
|
||||
}
|
||||
else {
|
||||
forceResolveAllContents(type.getConstructor());
|
||||
|
||||
@@ -91,9 +91,9 @@ public class CommonSupertypes {
|
||||
return type;
|
||||
}
|
||||
hasFlexible = true;
|
||||
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
||||
upper.add(flexibility.getUpperBound());
|
||||
lower.add(flexibility.getLowerBound());
|
||||
FlexibleType flexibleType = FlexibleTypesKt.asFlexibleType(type);
|
||||
upper.add(flexibleType.getUpperBound());
|
||||
lower.add(flexibleType.getLowerBound());
|
||||
}
|
||||
else {
|
||||
upper.add(KotlinTypeKt.asSimpleType(type));
|
||||
|
||||
+1
-1
@@ -506,7 +506,7 @@ public class DescriptorSerializer {
|
||||
}
|
||||
|
||||
if (FlexibleTypesKt.isFlexible(type)) {
|
||||
DelegatingFlexibleType flexibleType = (DelegatingFlexibleType) FlexibleTypesKt.flexibility(type);
|
||||
DelegatingFlexibleType flexibleType = (DelegatingFlexibleType) FlexibleTypesKt.asFlexibleType(type);
|
||||
|
||||
ProtoBuf.Type.Builder lowerBound = type(flexibleType.getLowerBound());
|
||||
ProtoBuf.Type.Builder upperBound = type(flexibleType.getUpperBound());
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.serialization;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.types.DelegatingFlexibleType;
|
||||
import org.jetbrains.kotlin.types.Flexibility;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public abstract class SerializerExtension {
|
||||
|
||||
Reference in New Issue
Block a user