Refactoring. Remove FlexibleTypeFactoryDeserializer.
This commit is contained in:
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.kotlin
|
|||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaPackageFragmentProvider
|
import org.jetbrains.kotlin.load.java.lazy.LazyJavaPackageFragmentProvider
|
||||||
|
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
|
||||||
@@ -40,7 +41,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, JavaFlexibleTypeFactoryDeserializer, ClassDescriptorFactory.EMPTY,
|
errorReporter, lookupTracker, FlexibleJavaClassifierTypeFactory, ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses, JavaTypeCapabilitiesLoader,
|
notFoundClasses, JavaTypeCapabilitiesLoader,
|
||||||
additionalSupertypes = BuiltInClassesAreSerializableOnJvm(moduleDescriptor)
|
additionalSupertypes = BuiltInClassesAreSerializableOnJvm(moduleDescriptor)
|
||||||
)
|
)
|
||||||
|
|||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.load.kotlin
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
|
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.FlexibleTypeFactoryDeserializer
|
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
|
||||||
|
|
||||||
object JavaFlexibleTypeFactoryDeserializer : FlexibleTypeFactoryDeserializer {
|
|
||||||
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
|
||||||
return if (id == LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.id)
|
|
||||||
LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory
|
|
||||||
else null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
fun createBuiltInPackageFragmentProvider(
|
fun createBuiltInPackageFragmentProvider(
|
||||||
@@ -50,7 +51,7 @@ fun createBuiltInPackageFragmentProvider(
|
|||||||
localClassResolver,
|
localClassResolver,
|
||||||
ErrorReporter.DO_NOTHING,
|
ErrorReporter.DO_NOTHING,
|
||||||
LookupTracker.DO_NOTHING,
|
LookupTracker.DO_NOTHING,
|
||||||
FlexibleTypeFactoryDeserializer.ThrowException,
|
FlexibleTypeFactory.ThrowException,
|
||||||
classDescriptorFactory,
|
classDescriptorFactory,
|
||||||
notFoundClasses,
|
notFoundClasses,
|
||||||
additionalSupertypes = additionalSupertypes
|
additionalSupertypes = additionalSupertypes
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ interface FlexibleTypeFactory {
|
|||||||
val id: String
|
val id: String
|
||||||
|
|
||||||
fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType
|
fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType
|
||||||
|
|
||||||
|
object ThrowException : FlexibleTypeFactory {
|
||||||
|
private fun error(): Nothing = throw IllegalArgumentException("This factory should not be used.")
|
||||||
|
override val id: String
|
||||||
|
get() = error()
|
||||||
|
|
||||||
|
override fun create(lowerBound: KotlinType, upperBound: KotlinType): KotlinType = error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Flexibility : TypeCapability, SubtypingRepresentatives {
|
interface Flexibility : TypeCapability, SubtypingRepresentatives {
|
||||||
|
|||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.serialization.deserialization
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.types.DynamicTypeFactory
|
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
|
||||||
|
|
||||||
interface FlexibleTypeFactoryDeserializer {
|
|
||||||
object ThrowException : FlexibleTypeFactoryDeserializer {
|
|
||||||
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
|
||||||
throw IllegalArgumentException("Capabilities not found by ThrowException manager: $id")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object Dynamic : FlexibleTypeFactoryDeserializer {
|
|
||||||
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
|
||||||
return if (id == DynamicTypeFactory.id) DynamicTypeFactory else null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun capabilitiesById(id: String): FlexibleTypeFactory?
|
|
||||||
}
|
|
||||||
+6
-5
@@ -56,12 +56,13 @@ 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.flexibleTypeFactoryDeserializer.capabilitiesById(id) ?:
|
val flexibleTypeFactory = c.components.flexibleTypeFactory
|
||||||
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
if (flexibleTypeFactory.id != id) {
|
||||||
|
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: " +
|
||||||
|
"Unexpected flexible type factory. Expected: ${flexibleTypeFactory.id} Actual: $id")
|
||||||
|
}
|
||||||
|
|
||||||
return capabilities
|
return flexibleTypeFactory.create(DeserializedType(c, proto), DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!))
|
||||||
.create(DeserializedType(c, proto),
|
|
||||||
DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeserializedType(c, proto, additionalAnnotations)
|
return DeserializedType(c, proto, additionalAnnotations)
|
||||||
|
|||||||
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
|
|
||||||
class DeserializationComponents(
|
class DeserializationComponents(
|
||||||
val storageManager: StorageManager,
|
val storageManager: StorageManager,
|
||||||
@@ -34,7 +35,7 @@ class DeserializationComponents(
|
|||||||
val localClassResolver: LocalClassResolver,
|
val localClassResolver: LocalClassResolver,
|
||||||
val errorReporter: ErrorReporter,
|
val errorReporter: ErrorReporter,
|
||||||
val lookupTracker: LookupTracker,
|
val lookupTracker: LookupTracker,
|
||||||
val flexibleTypeFactoryDeserializer: FlexibleTypeFactoryDeserializer,
|
val flexibleTypeFactory: FlexibleTypeFactory,
|
||||||
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
||||||
val notFoundClasses: NotFoundClasses,
|
val notFoundClasses: NotFoundClasses,
|
||||||
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
|||||||
import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf
|
import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||||
|
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||||
|
|
||||||
class KotlinBuiltInDeserializerForDecompiler(
|
class KotlinBuiltInDeserializerForDecompiler(
|
||||||
packageDirectory: VirtualFile,
|
packageDirectory: VirtualFile,
|
||||||
@@ -48,7 +49,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, FlexibleTypeFactoryDeserializer.ThrowException, ClassDescriptorFactory.EMPTY,
|
LookupTracker.DO_NOTHING, FlexibleTypeFactory.ThrowException, ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses
|
notFoundClasses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.decompiler.textBuilder.DeserializerForDecompile
|
|||||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.LoggingErrorReporter
|
import org.jetbrains.kotlin.idea.decompiler.textBuilder.LoggingErrorReporter
|
||||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.ResolveEverythingToKotlinAnyLocalClassResolver
|
import org.jetbrains.kotlin.idea.decompiler.textBuilder.ResolveEverythingToKotlinAnyLocalClassResolver
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
|
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||||
import org.jetbrains.kotlin.load.kotlin.*
|
import org.jetbrains.kotlin.load.kotlin.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
@@ -64,7 +65,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, JavaFlexibleTypeFactoryDeserializer, ClassDescriptorFactory.EMPTY, notFoundClasses
|
LookupTracker.DO_NOTHING, FlexibleJavaClassifierTypeFactory, ClassDescriptorFactory.EMPTY, notFoundClasses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
|||||||
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
|
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
|
||||||
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptClassDataFinder
|
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptClassDataFinder
|
||||||
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializedResourcePaths
|
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializedResourcePaths
|
||||||
|
import org.jetbrains.kotlin.types.DynamicTypeFactory
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
|
|
||||||
class KotlinJavaScriptDeserializerForDecompiler(
|
class KotlinJavaScriptDeserializerForDecompiler(
|
||||||
@@ -61,7 +62,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, FlexibleTypeFactoryDeserializer.Dynamic, ClassDescriptorFactory.EMPTY,
|
LookupTracker.DO_NOTHING, DynamicTypeFactory, ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses
|
notFoundClasses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
import org.jetbrains.kotlin.types.DynamicTypeFactory
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
fun createKotlinJavascriptPackageFragmentProvider(
|
fun createKotlinJavascriptPackageFragmentProvider(
|
||||||
@@ -48,7 +49,7 @@ fun createKotlinJavascriptPackageFragmentProvider(
|
|||||||
localClassResolver,
|
localClassResolver,
|
||||||
ErrorReporter.DO_NOTHING,
|
ErrorReporter.DO_NOTHING,
|
||||||
LookupTracker.DO_NOTHING,
|
LookupTracker.DO_NOTHING,
|
||||||
FlexibleTypeFactoryDeserializer.Dynamic,
|
DynamicTypeFactory,
|
||||||
ClassDescriptorFactory.EMPTY,
|
ClassDescriptorFactory.EMPTY,
|
||||||
notFoundClasses
|
notFoundClasses
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user