Refactoring. Rename FlexibleTypeCapabilities -> FlexibleTypeFactory. Also use factory.create instead of DelegatingFlexibleType.create.
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.
|
||||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
|||||||
import org.jetbrains.kotlin.frontend.di.configureModule
|
import org.jetbrains.kotlin.frontend.di.configureModule
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl
|
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl
|
||||||
import org.jetbrains.kotlin.load.java.JavaFlexibleTypeCapabilitiesProvider
|
import org.jetbrains.kotlin.load.java.JavaFlexibleTypeFactoryProvider
|
||||||
import org.jetbrains.kotlin.load.java.components.*
|
import org.jetbrains.kotlin.load.java.components.*
|
||||||
import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolver
|
import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolver
|
||||||
import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver
|
import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver
|
||||||
@@ -62,7 +62,7 @@ fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentScope: G
|
|||||||
useInstance(SamConversionResolverImpl)
|
useInstance(SamConversionResolverImpl)
|
||||||
useImpl<JavaSourceElementFactoryImpl>()
|
useImpl<JavaSourceElementFactoryImpl>()
|
||||||
useImpl<JavaLazyAnalyzerPostConstruct>()
|
useImpl<JavaLazyAnalyzerPostConstruct>()
|
||||||
useImpl<JavaFlexibleTypeCapabilitiesProvider>()
|
useInstance(JavaFlexibleTypeFactoryProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createContainerForLazyResolveWithJava(
|
fun createContainerForLazyResolveWithJava(
|
||||||
|
|||||||
+5
-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.
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.load.java
|
package org.jetbrains.kotlin.load.java
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.TypeResolver.FlexibleTypeCapabilitiesProvider
|
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeCapabilities
|
|
||||||
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
|
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
|
||||||
|
import org.jetbrains.kotlin.resolve.TypeResolver.FlexibleTypeFactoryProvider
|
||||||
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
|
|
||||||
class JavaFlexibleTypeCapabilitiesProvider : FlexibleTypeCapabilitiesProvider() {
|
object JavaFlexibleTypeFactoryProvider : FlexibleTypeFactoryProvider() {
|
||||||
override fun getCapabilities(): FlexibleTypeCapabilities = LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities
|
override val factory: FlexibleTypeFactory get() = LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory
|
||||||
}
|
}
|
||||||
+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.
|
||||||
@@ -72,7 +72,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
"' should not end with conflict";
|
"' should not end with conflict";
|
||||||
|
|
||||||
if (FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
if (FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
||||||
return LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(type, TypeUtils.makeNullable(type));
|
return LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.INSTANCE.create(type, TypeUtils.makeNullable(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypeUtils.makeNullableAsSpecified(type, samType.isMarkedNullable());
|
return TypeUtils.makeNullableAsSpecified(type, samType.isMarkedNullable());
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class TypeResolver(
|
|||||||
private val annotationResolver: AnnotationResolver,
|
private val annotationResolver: AnnotationResolver,
|
||||||
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
|
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
|
||||||
private val moduleDescriptor: ModuleDescriptor,
|
private val moduleDescriptor: ModuleDescriptor,
|
||||||
private val flexibleTypeCapabilitiesProvider: FlexibleTypeCapabilitiesProvider,
|
private val flexibleTypeFactoryProvider: FlexibleTypeFactoryProvider,
|
||||||
private val storageManager: StorageManager,
|
private val storageManager: StorageManager,
|
||||||
private val lazinessToken: TypeLazinessToken,
|
private val lazinessToken: TypeLazinessToken,
|
||||||
private val dynamicTypesSettings: DynamicTypesSettings,
|
private val dynamicTypesSettings: DynamicTypesSettings,
|
||||||
@@ -58,10 +58,8 @@ class TypeResolver(
|
|||||||
private val identifierChecker: IdentifierChecker
|
private val identifierChecker: IdentifierChecker
|
||||||
) {
|
) {
|
||||||
|
|
||||||
open class FlexibleTypeCapabilitiesProvider {
|
open class FlexibleTypeFactoryProvider {
|
||||||
open fun getCapabilities(): FlexibleTypeCapabilities {
|
open val factory: FlexibleTypeFactory get() = FlexibleTypeFactory.DEFAULT
|
||||||
return FlexibleTypeCapabilities.NONE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KotlinType {
|
fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KotlinType {
|
||||||
@@ -373,10 +371,8 @@ class TypeResolver(
|
|||||||
&& parameters.size == 2) {
|
&& parameters.size == 2) {
|
||||||
// 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
|
||||||
return type(DelegatingFlexibleType.create(
|
return type(flexibleTypeFactoryProvider.factory.create(arguments[0].type,
|
||||||
arguments[0].type,
|
arguments[1].type)
|
||||||
arguments[1].type,
|
|
||||||
flexibleTypeCapabilitiesProvider.getCapabilities())
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||||
@@ -86,14 +85,14 @@ public class CommonSupertypes {
|
|||||||
boolean hasFlexible = false;
|
boolean hasFlexible = false;
|
||||||
List<KotlinType> upper = new ArrayList<KotlinType>(types.size());
|
List<KotlinType> upper = new ArrayList<KotlinType>(types.size());
|
||||||
List<KotlinType> lower = new ArrayList<KotlinType>(types.size());
|
List<KotlinType> lower = new ArrayList<KotlinType>(types.size());
|
||||||
Set<FlexibleTypeCapabilities> capabilities = new LinkedHashSet<FlexibleTypeCapabilities>();
|
Set<FlexibleTypeFactory> factories = new LinkedHashSet<FlexibleTypeFactory>();
|
||||||
for (KotlinType type : types) {
|
for (KotlinType type : types) {
|
||||||
if (FlexibleTypesKt.isFlexible(type)) {
|
if (FlexibleTypesKt.isFlexible(type)) {
|
||||||
hasFlexible = true;
|
hasFlexible = true;
|
||||||
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
||||||
upper.add(flexibility.getUpperBound());
|
upper.add(flexibility.getUpperBound());
|
||||||
lower.add(flexibility.getLowerBound());
|
lower.add(flexibility.getLowerBound());
|
||||||
capabilities.add(flexibility.getExtraCapabilities());
|
factories.add(flexibility.getFactory());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
upper.add(type);
|
upper.add(type);
|
||||||
@@ -102,10 +101,9 @@ public class CommonSupertypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasFlexible) return commonSuperTypeForInflexible(types, recursionDepth, maxDepth);
|
if (!hasFlexible) return commonSuperTypeForInflexible(types, recursionDepth, maxDepth);
|
||||||
return DelegatingFlexibleType.create(
|
return CollectionsKt.single(factories).create( // mixing different factories is not supported
|
||||||
commonSuperTypeForInflexible(lower, recursionDepth, maxDepth),
|
commonSuperTypeForInflexible(lower, recursionDepth, maxDepth),
|
||||||
commonSuperTypeForInflexible(upper, recursionDepth, maxDepth),
|
commonSuperTypeForInflexible(upper, recursionDepth, maxDepth)
|
||||||
CollectionsKt.single(capabilities) // mixing different capabilities is not supported
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+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.
|
||||||
@@ -465,7 +465,7 @@ public class DescriptorSerializer {
|
|||||||
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
||||||
|
|
||||||
ProtoBuf.Type.Builder lowerBound = type(flexibility.getLowerBound());
|
ProtoBuf.Type.Builder lowerBound = type(flexibility.getLowerBound());
|
||||||
lowerBound.setFlexibleTypeCapabilitiesId(getStringTable().getStringIndex(flexibility.getExtraCapabilities().getId()));
|
lowerBound.setFlexibleTypeCapabilitiesId(getStringTable().getStringIndex(flexibility.getFactory().getId()));
|
||||||
if (useTypeTable()) {
|
if (useTypeTable()) {
|
||||||
lowerBound.setFlexibleUpperBoundId(typeId(flexibility.getUpperBound()));
|
lowerBound.setFlexibleUpperBoundId(typeId(flexibility.getUpperBound()));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ class FlexibleTypeAssertionsEnabledTest : KotlinTestWithEnvironmentManagement()
|
|||||||
val builtIns = JvmPlatform.builtIns
|
val builtIns = JvmPlatform.builtIns
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(
|
LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.create(
|
||||||
builtIns.intType, builtIns.stringType).arguments
|
builtIns.intType, builtIns.stringType).arguments
|
||||||
} catch (e: AssertionError) {
|
} catch (e: AssertionError) {
|
||||||
assertEquals("Lower bound Int of a flexible type must be a subtype of the upper bound String", e.message)
|
assertEquals("Lower bound Int of a flexible type must be a subtype of the upper bound String", e.message)
|
||||||
|
|||||||
+2
-4
@@ -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.
|
||||||
@@ -18,8 +18,6 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaAnnotations
|
import org.jetbrains.kotlin.load.java.lazy.LazyJavaAnnotations
|
||||||
@@ -51,7 +49,7 @@ class LazyJavaTypeParameterDescriptor(
|
|||||||
override fun resolveUpperBounds(): List<KotlinType> {
|
override fun resolveUpperBounds(): List<KotlinType> {
|
||||||
val bounds = javaTypeParameter.upperBounds
|
val bounds = javaTypeParameter.upperBounds
|
||||||
if (bounds.isEmpty()) {
|
if (bounds.isEmpty()) {
|
||||||
return listOf(LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(
|
return listOf(LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.create(
|
||||||
c.module.builtIns.anyType,
|
c.module.builtIns.anyType,
|
||||||
c.module.builtIns.nullableAnyType
|
c.module.builtIns.nullableAnyType
|
||||||
))
|
))
|
||||||
|
|||||||
+6
-9
@@ -57,7 +57,7 @@ class LazyJavaTypeResolver(
|
|||||||
}
|
}
|
||||||
is JavaClassifierType ->
|
is JavaClassifierType ->
|
||||||
if (attr.allowFlexible && attr.howThisTypeIsUsed != SUPERTYPE)
|
if (attr.allowFlexible && attr.howThisTypeIsUsed != SUPERTYPE)
|
||||||
FlexibleJavaClassifierTypeCapabilities.create(
|
FlexibleJavaClassifierTypeFactory.create(
|
||||||
LazyJavaClassifierType(javaType, attr.toFlexible(FLEXIBLE_LOWER_BOUND)),
|
LazyJavaClassifierType(javaType, attr.toFlexible(FLEXIBLE_LOWER_BOUND)),
|
||||||
LazyJavaClassifierType(javaType, attr.toFlexible(FLEXIBLE_UPPER_BOUND))
|
LazyJavaClassifierType(javaType, attr.toFlexible(FLEXIBLE_UPPER_BOUND))
|
||||||
)
|
)
|
||||||
@@ -76,7 +76,7 @@ class LazyJavaTypeResolver(
|
|||||||
if (primitiveType != null) {
|
if (primitiveType != null) {
|
||||||
val jetType = c.module.builtIns.getPrimitiveArrayKotlinType(primitiveType)
|
val jetType = c.module.builtIns.getPrimitiveArrayKotlinType(primitiveType)
|
||||||
return@run if (attr.allowFlexible)
|
return@run if (attr.allowFlexible)
|
||||||
FlexibleJavaClassifierTypeCapabilities.create(jetType, TypeUtils.makeNullable(jetType))
|
FlexibleJavaClassifierTypeFactory.create(jetType, TypeUtils.makeNullable(jetType))
|
||||||
else TypeUtils.makeNullableAsSpecified(jetType, !attr.isMarkedNotNull)
|
else TypeUtils.makeNullableAsSpecified(jetType, !attr.isMarkedNotNull)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ class LazyJavaTypeResolver(
|
|||||||
TYPE_ARGUMENT.toAttributes(attr.allowFlexible, attr.isForAnnotationParameter))
|
TYPE_ARGUMENT.toAttributes(attr.allowFlexible, attr.isForAnnotationParameter))
|
||||||
|
|
||||||
if (attr.allowFlexible) {
|
if (attr.allowFlexible) {
|
||||||
return@run FlexibleJavaClassifierTypeCapabilities.create(
|
return@run FlexibleJavaClassifierTypeFactory.create(
|
||||||
c.module.builtIns.getArrayType(INVARIANT, componentType),
|
c.module.builtIns.getArrayType(INVARIANT, componentType),
|
||||||
TypeUtils.makeNullable(c.module.builtIns.getArrayType(OUT_VARIANCE, componentType)))
|
TypeUtils.makeNullable(c.module.builtIns.getArrayType(OUT_VARIANCE, componentType)))
|
||||||
}
|
}
|
||||||
@@ -284,20 +284,17 @@ class LazyJavaTypeResolver(
|
|||||||
override fun getAnnotations() = annotations
|
override fun getAnnotations() = annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities {
|
object FlexibleJavaClassifierTypeFactory : FlexibleTypeFactory {
|
||||||
@JvmStatic
|
|
||||||
fun create(lowerBound: KotlinType, upperBound: KotlinType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
|
||||||
|
|
||||||
override val id: String get() = "kotlin.jvm.PlatformType"
|
override val id: String get() = "kotlin.jvm.PlatformType"
|
||||||
|
|
||||||
override fun createFlexibleType(lowerBound: KotlinType, upperBound: KotlinType): KotlinType {
|
override fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType {
|
||||||
if (lowerBound == upperBound) return lowerBound
|
if (lowerBound == upperBound) return lowerBound
|
||||||
|
|
||||||
return Impl(lowerBound, upperBound)
|
return Impl(lowerBound, upperBound)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Impl(lowerBound: KotlinType, upperBound: KotlinType) :
|
private class Impl(lowerBound: KotlinType, upperBound: KotlinType) :
|
||||||
DelegatingFlexibleType(lowerBound, upperBound, FlexibleJavaClassifierTypeCapabilities), CustomTypeVariable, Specificity {
|
DelegatingFlexibleType(lowerBound, upperBound, FlexibleJavaClassifierTypeFactory), CustomTypeVariable, Specificity {
|
||||||
|
|
||||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>): T? {
|
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>): T? {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
|||||||
+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.
|
||||||
@@ -97,7 +97,7 @@ internal object RawSubstitution : TypeSubstitution() {
|
|||||||
is ClassDescriptor -> {
|
is ClassDescriptor -> {
|
||||||
val lower = type.lowerIfFlexible()
|
val lower = type.lowerIfFlexible()
|
||||||
val upper = type.upperIfFlexible()
|
val upper = type.upperIfFlexible()
|
||||||
LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(
|
LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.create(
|
||||||
eraseInflexibleBasedOnClassDescriptor(lower, declaration, lowerTypeAttr),
|
eraseInflexibleBasedOnClassDescriptor(lower, declaration, lowerTypeAttr),
|
||||||
eraseInflexibleBasedOnClassDescriptor(upper, declaration, upperTypeAttr)
|
eraseInflexibleBasedOnClassDescriptor(upper, declaration, upperTypeAttr)
|
||||||
)
|
)
|
||||||
|
|||||||
+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");
|
* 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.
|
||||||
@@ -70,7 +70,7 @@ private fun KotlinType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQual
|
|||||||
val wereChanges = lowerResult.wereChanges || upperResult.wereChanges
|
val wereChanges = lowerResult.wereChanges || upperResult.wereChanges
|
||||||
Result(
|
Result(
|
||||||
if (wereChanges)
|
if (wereChanges)
|
||||||
DelegatingFlexibleType.create(lowerResult.type, upperResult.type, extraCapabilities)
|
factory.create(lowerResult.type, upperResult.type)
|
||||||
else
|
else
|
||||||
this@enhancePossiblyFlexible,
|
this@enhancePossiblyFlexible,
|
||||||
lowerResult.subtreeSize,
|
lowerResult.subtreeSize,
|
||||||
@@ -229,7 +229,7 @@ internal object NotNullTypeParameterTypeCapability : CustomTypeVariable {
|
|||||||
|
|
||||||
if (replacement.isFlexible()) {
|
if (replacement.isFlexible()) {
|
||||||
with(replacement.flexibility()) {
|
with(replacement.flexibility()) {
|
||||||
return DelegatingFlexibleType.create(lowerBound.prepareReplacement(), upperBound.prepareReplacement(), extraCapabilities)
|
return factory.create(lowerBound.prepareReplacement(), upperBound.prepareReplacement())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+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.
|
||||||
@@ -40,7 +40,7 @@ class DeserializationComponentsForJava(
|
|||||||
val localClassResolver = LocalClassResolverImpl()
|
val localClassResolver = LocalClassResolverImpl()
|
||||||
components = DeserializationComponents(
|
components = DeserializationComponents(
|
||||||
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider, localClassResolver,
|
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider, localClassResolver,
|
||||||
errorReporter, lookupTracker, JavaFlexibleTypeCapabilitiesDeserializer, ClassDescriptorFactory.EMPTY,
|
errorReporter, lookupTracker, JavaFlexibleTypeFactoryDeserializer, ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses, JavaTypeCapabilitiesLoader,
|
notFoundClasses, JavaTypeCapabilitiesLoader,
|
||||||
additionalSupertypes = BuiltInClassesAreSerializableOnJvm(moduleDescriptor)
|
additionalSupertypes = BuiltInClassesAreSerializableOnJvm(moduleDescriptor)
|
||||||
)
|
)
|
||||||
|
|||||||
+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.
|
||||||
@@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.load.kotlin
|
package org.jetbrains.kotlin.load.kotlin
|
||||||
|
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeCapabilitiesDeserializer
|
|
||||||
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
|
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeCapabilities
|
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeFactoryDeserializer
|
||||||
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
|
|
||||||
object JavaFlexibleTypeCapabilitiesDeserializer : FlexibleTypeCapabilitiesDeserializer {
|
object JavaFlexibleTypeFactoryDeserializer : FlexibleTypeFactoryDeserializer {
|
||||||
override fun capabilitiesById(id: String): FlexibleTypeCapabilities? {
|
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
||||||
return if (id == LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.id)
|
return if (id == LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.id)
|
||||||
LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities
|
LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory
|
||||||
else null
|
else 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");
|
* 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.
|
||||||
@@ -50,7 +50,7 @@ fun createBuiltInPackageFragmentProvider(
|
|||||||
localClassResolver,
|
localClassResolver,
|
||||||
ErrorReporter.DO_NOTHING,
|
ErrorReporter.DO_NOTHING,
|
||||||
LookupTracker.DO_NOTHING,
|
LookupTracker.DO_NOTHING,
|
||||||
FlexibleTypeCapabilitiesDeserializer.ThrowException,
|
FlexibleTypeFactoryDeserializer.ThrowException,
|
||||||
classDescriptorFactory,
|
classDescriptorFactory,
|
||||||
notFoundClasses,
|
notFoundClasses,
|
||||||
additionalSupertypes = additionalSupertypes
|
additionalSupertypes = additionalSupertypes
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -23,8 +23,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
import org.jetbrains.kotlin.types.typeUtil.*
|
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
data class ApproximationBounds<T>(
|
data class ApproximationBounds<T>(
|
||||||
@@ -98,12 +97,10 @@ fun approximateCapturedTypes(type: KotlinType): ApproximationBounds<KotlinType>
|
|||||||
val boundsForFlexibleLower = approximateCapturedTypes(type.lowerIfFlexible())
|
val boundsForFlexibleLower = approximateCapturedTypes(type.lowerIfFlexible())
|
||||||
val boundsForFlexibleUpper = approximateCapturedTypes(type.upperIfFlexible())
|
val boundsForFlexibleUpper = approximateCapturedTypes(type.upperIfFlexible())
|
||||||
|
|
||||||
val extraCapabilities = type.flexibility().extraCapabilities
|
val factory = type.flexibility().factory
|
||||||
return ApproximationBounds(
|
return ApproximationBounds(
|
||||||
DelegatingFlexibleType.create(
|
factory.create(boundsForFlexibleLower.lower.lowerIfFlexible(), boundsForFlexibleUpper.lower.upperIfFlexible()),
|
||||||
boundsForFlexibleLower.lower.lowerIfFlexible(), boundsForFlexibleUpper.lower.upperIfFlexible(), extraCapabilities),
|
factory.create(boundsForFlexibleLower.upper.lowerIfFlexible(), boundsForFlexibleUpper.upper.upperIfFlexible()))
|
||||||
DelegatingFlexibleType.create(
|
|
||||||
boundsForFlexibleLower.upper.lowerIfFlexible(), boundsForFlexibleUpper.upper.upperIfFlexible(), extraCapabilities))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val typeConstructor = type.constructor
|
val typeConstructor = 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");
|
* 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.
|
||||||
@@ -146,8 +146,8 @@ public class TypeSubstitutor {
|
|||||||
originalProjectionKind == Variance.INVARIANT || originalProjectionKind == substitutedProjectionKind :
|
originalProjectionKind == Variance.INVARIANT || originalProjectionKind == substitutedProjectionKind :
|
||||||
"Unexpected substituted projection kind: " + substitutedProjectionKind + "; original: " + originalProjectionKind;
|
"Unexpected substituted projection kind: " + substitutedProjectionKind + "; original: " + originalProjectionKind;
|
||||||
|
|
||||||
KotlinType substitutedFlexibleType = DelegatingFlexibleType.create(
|
KotlinType substitutedFlexibleType = flexibility.getFactory().create(
|
||||||
substitutedLower.getType(), substitutedUpper.getType(), flexibility.getExtraCapabilities());
|
substitutedLower.getType(), substitutedUpper.getType());
|
||||||
return new TypeProjectionImpl(substitutedProjectionKind, substitutedFlexibleType);
|
return new TypeProjectionImpl(substitutedProjectionKind, substitutedFlexibleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,17 +33,17 @@ interface Dynamicity : TypeCapability
|
|||||||
|
|
||||||
fun KotlinType.isDynamic(): Boolean = this.getCapability(Dynamicity::class.java) != null
|
fun KotlinType.isDynamic(): Boolean = this.getCapability(Dynamicity::class.java) != null
|
||||||
|
|
||||||
fun createDynamicType(builtIns: KotlinBuiltIns) = DynamicTypeCapabilities.createFlexibleType(builtIns.nothingType, builtIns.nullableAnyType)
|
fun createDynamicType(builtIns: KotlinBuiltIns) = DynamicTypeFactory.create(builtIns.nothingType, builtIns.nullableAnyType)
|
||||||
|
|
||||||
object DynamicTypeCapabilities : FlexibleTypeCapabilities {
|
object DynamicTypeFactory : FlexibleTypeFactory {
|
||||||
override val id: String get() = "kotlin.DynamicType"
|
override val id: String get() = "kotlin.DynamicType"
|
||||||
|
|
||||||
override fun createFlexibleType(lowerBound: KotlinType, upperBound: KotlinType): KotlinType {
|
override fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType {
|
||||||
if (lowerBound == upperBound) return lowerBound
|
if (lowerBound == upperBound) return lowerBound
|
||||||
return Impl(lowerBound, upperBound)
|
return Impl(lowerBound, upperBound)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Impl(lowerBound: KotlinType, upperBound: KotlinType) : DelegatingFlexibleType(lowerBound, upperBound, DynamicTypeCapabilities), Dynamicity, Specificity, NullAwareness, FlexibleTypeDelegation {
|
private class Impl(lowerBound: KotlinType, upperBound: KotlinType) : DelegatingFlexibleType(lowerBound, upperBound, DynamicTypeFactory), Dynamicity, Specificity, NullAwareness, FlexibleTypeDelegation {
|
||||||
companion object {
|
companion object {
|
||||||
internal val capabilityClasses = hashSetOf(
|
internal val capabilityClasses = hashSetOf(
|
||||||
Dynamicity::class.java,
|
Dynamicity::class.java,
|
||||||
|
|||||||
@@ -20,17 +20,18 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
|
|
||||||
interface FlexibleTypeCapabilities {
|
interface FlexibleTypeFactory {
|
||||||
fun createFlexibleType(lowerBound: KotlinType, upperBound: KotlinType): KotlinType
|
|
||||||
val id: String
|
val id: String
|
||||||
|
|
||||||
object NONE : FlexibleTypeCapabilities {
|
fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType
|
||||||
override fun createFlexibleType(lowerBound: KotlinType, upperBound: KotlinType): KotlinType {
|
|
||||||
if (lowerBound == upperBound) return lowerBound
|
|
||||||
return object : DelegatingFlexibleType(lowerBound, upperBound, this@NONE) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
object DEFAULT : FlexibleTypeFactory {
|
||||||
override val id: String get() = "NONE"
|
override val id: String get() = "NONE"
|
||||||
|
|
||||||
|
override fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType {
|
||||||
|
if (lowerBound == upperBound) return lowerBound
|
||||||
|
return object : DelegatingFlexibleType(lowerBound, upperBound, this@DEFAULT) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ interface Flexibility : TypeCapability, SubtypingRepresentatives {
|
|||||||
val lowerBound: KotlinType
|
val lowerBound: KotlinType
|
||||||
val upperBound: KotlinType
|
val upperBound: KotlinType
|
||||||
|
|
||||||
val extraCapabilities: FlexibleTypeCapabilities
|
val factory: FlexibleTypeFactory
|
||||||
|
|
||||||
override val subTypeRepresentative: KotlinType
|
override val subTypeRepresentative: KotlinType
|
||||||
get() = lowerBound
|
get() = lowerBound
|
||||||
@@ -115,7 +116,7 @@ interface FlexibleTypeDelegation : TypeCapability {
|
|||||||
open class DelegatingFlexibleType protected constructor(
|
open class DelegatingFlexibleType protected constructor(
|
||||||
override val lowerBound: KotlinType,
|
override val lowerBound: KotlinType,
|
||||||
override val upperBound: KotlinType,
|
override val upperBound: KotlinType,
|
||||||
override val extraCapabilities: FlexibleTypeCapabilities
|
override val factory: FlexibleTypeFactory
|
||||||
) : DelegatingType(), NullAwareness, Flexibility, FlexibleTypeDelegation {
|
) : DelegatingType(), NullAwareness, Flexibility, FlexibleTypeDelegation {
|
||||||
companion object {
|
companion object {
|
||||||
internal val capabilityClasses = hashSetOf(
|
internal val capabilityClasses = hashSetOf(
|
||||||
@@ -125,11 +126,6 @@ open class DelegatingFlexibleType protected constructor(
|
|||||||
FlexibleTypeDelegation::class.java
|
FlexibleTypeDelegation::class.java
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun create(lowerBound: KotlinType, upperBound: KotlinType, extraCapabilities: FlexibleTypeCapabilities): KotlinType {
|
|
||||||
return extraCapabilities.createFlexibleType(lowerBound, upperBound)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
var RUN_SLOW_ASSERTIONS = false
|
var RUN_SLOW_ASSERTIONS = false
|
||||||
}
|
}
|
||||||
@@ -162,10 +158,8 @@ open class DelegatingFlexibleType protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeNullableAsSpecified(nullable: Boolean): KotlinType {
|
override fun makeNullableAsSpecified(nullable: Boolean): KotlinType {
|
||||||
return create(
|
return factory.create(TypeUtils.makeNullableAsSpecified(lowerBound, nullable),
|
||||||
TypeUtils.makeNullableAsSpecified(lowerBound, nullable),
|
TypeUtils.makeNullableAsSpecified(upperBound, nullable))
|
||||||
TypeUtils.makeNullableAsSpecified(upperBound, nullable),
|
|
||||||
extraCapabilities)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun computeIsNullable() = delegateType.isMarkedNullable
|
override fun computeIsNullable() = delegateType.isMarkedNullable
|
||||||
|
|||||||
+10
-10
@@ -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.
|
||||||
@@ -16,22 +16,22 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.serialization.deserialization
|
package org.jetbrains.kotlin.serialization.deserialization
|
||||||
|
|
||||||
import org.jetbrains.kotlin.types.DynamicTypeCapabilities
|
import org.jetbrains.kotlin.types.DynamicTypeFactory
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeCapabilities
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
|
|
||||||
interface FlexibleTypeCapabilitiesDeserializer {
|
interface FlexibleTypeFactoryDeserializer {
|
||||||
object ThrowException : FlexibleTypeCapabilitiesDeserializer {
|
object ThrowException : FlexibleTypeFactoryDeserializer {
|
||||||
override fun capabilitiesById(id: String): FlexibleTypeCapabilities? {
|
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
||||||
throw IllegalArgumentException("Capabilities not found by ThrowException manager: $id")
|
throw IllegalArgumentException("Capabilities not found by ThrowException manager: $id")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object Dynamic : FlexibleTypeCapabilitiesDeserializer {
|
object Dynamic : FlexibleTypeFactoryDeserializer {
|
||||||
override fun capabilitiesById(id: String): FlexibleTypeCapabilities? {
|
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
||||||
return if (id == DynamicTypeCapabilities.id) DynamicTypeCapabilities else null
|
return if (id == DynamicTypeFactory.id) DynamicTypeFactory else null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun capabilitiesById(id: String): FlexibleTypeCapabilities?
|
fun capabilitiesById(id: String): FlexibleTypeFactory?
|
||||||
}
|
}
|
||||||
+6
-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");
|
* 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.
|
||||||
@@ -56,14 +56,12 @@ class TypeDeserializer(
|
|||||||
fun type(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY): KotlinType {
|
fun type(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY): KotlinType {
|
||||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||||
val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId)
|
val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId)
|
||||||
val capabilities = c.components.flexibleTypeCapabilitiesDeserializer.capabilitiesById(id) ?:
|
val capabilities = c.components.flexibleTypeFactoryDeserializer.capabilitiesById(id) ?:
|
||||||
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
||||||
|
|
||||||
return DelegatingFlexibleType.create(
|
return capabilities
|
||||||
DeserializedType(c, proto),
|
.create(DeserializedType(c, proto),
|
||||||
DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!),
|
DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!))
|
||||||
capabilities
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeserializedType(c, proto, additionalAnnotations)
|
return DeserializedType(c, proto, additionalAnnotations)
|
||||||
|
|||||||
+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.
|
||||||
@@ -34,7 +34,7 @@ class DeserializationComponents(
|
|||||||
val localClassResolver: LocalClassResolver,
|
val localClassResolver: LocalClassResolver,
|
||||||
val errorReporter: ErrorReporter,
|
val errorReporter: ErrorReporter,
|
||||||
val lookupTracker: LookupTracker,
|
val lookupTracker: LookupTracker,
|
||||||
val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
|
val flexibleTypeFactoryDeserializer: FlexibleTypeFactoryDeserializer,
|
||||||
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
||||||
val notFoundClasses: NotFoundClasses,
|
val notFoundClasses: NotFoundClasses,
|
||||||
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
||||||
|
|||||||
+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.
|
||||||
@@ -48,7 +48,7 @@ class KotlinBuiltInDeserializerForDecompiler(
|
|||||||
storageManager, moduleDescriptor, BuiltInsClassDataFinder(proto, nameResolver),
|
storageManager, moduleDescriptor, BuiltInsClassDataFinder(proto, nameResolver),
|
||||||
AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, BuiltInSerializerProtocol), packageFragmentProvider,
|
AnnotationAndConstantLoaderImpl(moduleDescriptor, notFoundClasses, BuiltInSerializerProtocol), packageFragmentProvider,
|
||||||
ResolveEverythingToKotlinAnyLocalClassResolver(targetPlatform.builtIns), LoggingErrorReporter(LOG),
|
ResolveEverythingToKotlinAnyLocalClassResolver(targetPlatform.builtIns), LoggingErrorReporter(LOG),
|
||||||
LookupTracker.DO_NOTHING, FlexibleTypeCapabilitiesDeserializer.ThrowException, ClassDescriptorFactory.EMPTY,
|
LookupTracker.DO_NOTHING, FlexibleTypeFactoryDeserializer.ThrowException, ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses
|
notFoundClasses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+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.
|
||||||
@@ -64,7 +64,7 @@ class DeserializerForClassfileDecompiler(
|
|||||||
deserializationComponents = DeserializationComponents(
|
deserializationComponents = DeserializationComponents(
|
||||||
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider,
|
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider,
|
||||||
ResolveEverythingToKotlinAnyLocalClassResolver(targetPlatform.builtIns), LoggingErrorReporter(LOG),
|
ResolveEverythingToKotlinAnyLocalClassResolver(targetPlatform.builtIns), LoggingErrorReporter(LOG),
|
||||||
LookupTracker.DO_NOTHING, JavaFlexibleTypeCapabilitiesDeserializer, ClassDescriptorFactory.EMPTY, notFoundClasses
|
LookupTracker.DO_NOTHING, JavaFlexibleTypeFactoryDeserializer, ClassDescriptorFactory.EMPTY, notFoundClasses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+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.
|
||||||
@@ -61,7 +61,7 @@ class KotlinJavaScriptDeserializerForDecompiler(
|
|||||||
deserializationComponents = DeserializationComponents(
|
deserializationComponents = DeserializationComponents(
|
||||||
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider,
|
storageManager, moduleDescriptor, classDataFinder, annotationAndConstantLoader, packageFragmentProvider,
|
||||||
ResolveEverythingToKotlinAnyLocalClassResolver(targetPlatform.builtIns), LoggingErrorReporter(LOG),
|
ResolveEverythingToKotlinAnyLocalClassResolver(targetPlatform.builtIns), LoggingErrorReporter(LOG),
|
||||||
LookupTracker.DO_NOTHING, FlexibleTypeCapabilitiesDeserializer.Dynamic, ClassDescriptorFactory.EMPTY,
|
LookupTracker.DO_NOTHING, FlexibleTypeFactoryDeserializer.Dynamic, ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses
|
notFoundClasses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+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");
|
* 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.
|
||||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf.Type
|
|||||||
import org.jetbrains.kotlin.serialization.ProtoBuf.Type.Argument.Projection
|
import org.jetbrains.kotlin.serialization.ProtoBuf.Type.Argument.Projection
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf.TypeParameter.Variance
|
import org.jetbrains.kotlin.serialization.ProtoBuf.TypeParameter.Variance
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.types.DynamicTypeCapabilities
|
import org.jetbrains.kotlin.types.DynamicTypeFactory
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
|||||||
if (type.hasFlexibleTypeCapabilitiesId()) {
|
if (type.hasFlexibleTypeCapabilitiesId()) {
|
||||||
val id = c.nameResolver.getString(type.flexibleTypeCapabilitiesId)
|
val id = c.nameResolver.getString(type.flexibleTypeCapabilitiesId)
|
||||||
|
|
||||||
if (id == DynamicTypeCapabilities.id) {
|
if (id == DynamicTypeFactory.id) {
|
||||||
KotlinPlaceHolderStubImpl<KtDynamicType>(parent, KtStubElementTypes.DYNAMIC_TYPE)
|
KotlinPlaceHolderStubImpl<KtDynamicType>(parent, KtStubElementTypes.DYNAMIC_TYPE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+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.
|
||||||
@@ -48,7 +48,7 @@ fun createKotlinJavascriptPackageFragmentProvider(
|
|||||||
localClassResolver,
|
localClassResolver,
|
||||||
ErrorReporter.DO_NOTHING,
|
ErrorReporter.DO_NOTHING,
|
||||||
LookupTracker.DO_NOTHING,
|
LookupTracker.DO_NOTHING,
|
||||||
FlexibleTypeCapabilitiesDeserializer.Dynamic,
|
FlexibleTypeFactoryDeserializer.Dynamic,
|
||||||
ClassDescriptorFactory.EMPTY,
|
ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses
|
notFoundClasses
|
||||||
)
|
)
|
||||||
|
|||||||
+6
-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");
|
* 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.
|
||||||
@@ -29,7 +29,10 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
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.*
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
||||||
|
import org.jetbrains.kotlin.types.StarProjectionImpl
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||||
|
|
||||||
private class XmlSourceElement(override val psi: PsiElement) : PsiSourceElement
|
private class XmlSourceElement(override val psi: PsiElement) : PsiSourceElement
|
||||||
@@ -106,7 +109,7 @@ private fun genProperty(
|
|||||||
override val resourceId = id
|
override val resourceId = id
|
||||||
}
|
}
|
||||||
|
|
||||||
val flexibleType = DelegatingFlexibleType.create(type, type.makeNullable(), FlexibleTypeCapabilities.NONE)
|
val flexibleType = FlexibleTypeFactory.DEFAULT.create(type, type.makeNullable())
|
||||||
property.setType(
|
property.setType(
|
||||||
flexibleType,
|
flexibleType,
|
||||||
emptyList<TypeParameterDescriptor>(),
|
emptyList<TypeParameterDescriptor>(),
|
||||||
|
|||||||
Reference in New Issue
Block a user