Add "java.io.Serializable" as supertype to java builtIns mapped to classes that are serializable on jvm

Implementation is hacky, relies on adding fictional supertype to corresponding classes
This commit is contained in:
Pavel V. Talanov
2015-09-24 18:43:18 +03:00
parent 427c853e27
commit d5624708fb
9 changed files with 152 additions and 16 deletions
@@ -0,0 +1,28 @@
/*
* Copyright 2010-2015 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.serialization.deserialization.descriptors.DeserializedClassDescriptor
import org.jetbrains.kotlin.types.JetType
interface AdditionalSupertypes {
fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<JetType>
object None : AdditionalSupertypes {
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<JetType> = emptyList()
}
}
@@ -25,16 +25,17 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.storage.StorageManager
public class DeserializationComponents(
public val storageManager: StorageManager,
public val moduleDescriptor: ModuleDescriptor,
public val classDataFinder: ClassDataFinder,
public val annotationAndConstantLoader: AnnotationAndConstantLoader<AnnotationDescriptor, ConstantValue<*>, AnnotationWithTarget>,
public val packageFragmentProvider: PackageFragmentProvider,
public val localClassResolver: LocalClassResolver,
public val errorReporter: ErrorReporter,
public val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
public val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
public val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE
val storageManager: StorageManager,
val moduleDescriptor: ModuleDescriptor,
val classDataFinder: ClassDataFinder,
val annotationAndConstantLoader: AnnotationAndConstantLoader<AnnotationDescriptor, ConstantValue<*>, AnnotationWithTarget>,
val packageFragmentProvider: PackageFragmentProvider,
val localClassResolver: LocalClassResolver,
val errorReporter: ErrorReporter,
val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer,
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
val additionalSupertypes: AdditionalSupertypes = AdditionalSupertypes.None
) {
public val classDeserializer: ClassDeserializer = ClassDeserializer(this)
@@ -149,6 +149,8 @@ public class DeserializedClassDescriptor(
}
}
result.addAll(c.components.additionalSupertypes.forClass(this))
if (unresolved.isNotEmpty()) {
c.components.errorReporter.reportIncompleteHierarchy(this, unresolved.map(DeserializedType::getPresentableText))
}