Refactoring. Rename FlexibleTypeCapabilities -> FlexibleTypeFactory. Also use factory.create instead of DelegatingFlexibleType.create.
This commit is contained in:
+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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,22 +16,22 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.types.DynamicTypeCapabilities
|
||||
import org.jetbrains.kotlin.types.FlexibleTypeCapabilities
|
||||
import org.jetbrains.kotlin.types.DynamicTypeFactory
|
||||
import org.jetbrains.kotlin.types.FlexibleTypeFactory
|
||||
|
||||
interface FlexibleTypeCapabilitiesDeserializer {
|
||||
object ThrowException : FlexibleTypeCapabilitiesDeserializer {
|
||||
override fun capabilitiesById(id: String): FlexibleTypeCapabilities? {
|
||||
interface FlexibleTypeFactoryDeserializer {
|
||||
object ThrowException : FlexibleTypeFactoryDeserializer {
|
||||
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
||||
throw IllegalArgumentException("Capabilities not found by ThrowException manager: $id")
|
||||
}
|
||||
}
|
||||
|
||||
object Dynamic : FlexibleTypeCapabilitiesDeserializer {
|
||||
override fun capabilitiesById(id: String): FlexibleTypeCapabilities? {
|
||||
return if (id == DynamicTypeCapabilities.id) DynamicTypeCapabilities else null
|
||||
object Dynamic : FlexibleTypeFactoryDeserializer {
|
||||
override fun capabilitiesById(id: String): FlexibleTypeFactory? {
|
||||
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");
|
||||
* 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 {
|
||||
if (proto.hasFlexibleTypeCapabilitiesId()) {
|
||||
val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId)
|
||||
val capabilities = c.components.flexibleTypeCapabilitiesDeserializer.capabilitiesById(id) ?:
|
||||
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
||||
val capabilities = c.components.flexibleTypeFactoryDeserializer.capabilitiesById(id) ?:
|
||||
return ErrorUtils.createErrorType("${DeserializedType(c, proto)}: Capabilities not found for id $id")
|
||||
|
||||
return DelegatingFlexibleType.create(
|
||||
DeserializedType(c, proto),
|
||||
DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!),
|
||||
capabilities
|
||||
)
|
||||
return capabilities
|
||||
.create(DeserializedType(c, proto),
|
||||
DeserializedType(c, proto.flexibleUpperBound(c.typeTable)!!))
|
||||
}
|
||||
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ class DeserializationComponents(
|
||||
val localClassResolver: LocalClassResolver,
|
||||
val errorReporter: ErrorReporter,
|
||||
val lookupTracker: LookupTracker,
|
||||
val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
|
||||
val flexibleTypeFactoryDeserializer: FlexibleTypeFactoryDeserializer,
|
||||
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
||||
val notFoundClasses: NotFoundClasses,
|
||||
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
||||
|
||||
Reference in New Issue
Block a user