Refactoring. Remove FlexibleTypeFactoryDeserializer.
This commit is contained in:
-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 {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId)
|
||||
val capabilities = c.components.flexibleTypeFactoryDeserializer.capabilitiesById(id) ?:
|
||||
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
||||
val flexibleTypeFactory = c.components.flexibleTypeFactory
|
||||
if (flexibleTypeFactory.id != id) {
|
||||
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: " +
|
||||
"Unexpected flexible type factory. Expected: ${flexibleTypeFactory.id} Actual: $id")
|
||||
}
|
||||
|
||||
return capabilities
|
||||
.create(DeserializedType(c, proto),
|
||||
DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!))
|
||||
return flexibleTypeFactory.create(DeserializedType(c, proto), DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!))
|
||||
}
|
||||
|
||||
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.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||
|
||||
class DeserializationComponents(
|
||||
val storageManager: StorageManager,
|
||||
@@ -34,7 +35,7 @@ class DeserializationComponents(
|
||||
val localClassResolver: LocalClassResolver,
|
||||
val errorReporter: ErrorReporter,
|
||||
val lookupTracker: LookupTracker,
|
||||
val flexibleTypeFactoryDeserializer: FlexibleTypeFactoryDeserializer,
|
||||
val flexibleTypeFactory: FlexibleTypeFactory,
|
||||
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
||||
val notFoundClasses: NotFoundClasses,
|
||||
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
||||
|
||||
Reference in New Issue
Block a user