Added GenerationState to KotlinTypeMapper

This commit is contained in:
Michael Bogdanov
2016-09-12 14:13:45 +03:00
parent dd4d5e3aa1
commit 0390cd6ee1
7 changed files with 10 additions and 7 deletions
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper { class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
// We use empty BindingContext, because it is only used by KotlinTypeMapper for purposes irrelevant to the needs of this class // We use empty BindingContext, because it is only used by KotlinTypeMapper for purposes irrelevant to the needs of this class
private val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null, private val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME) IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapAsmMethod(function) override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapAsmMethod(function)
} }
@@ -63,7 +63,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
// Avoid errors when some classes are not loaded for some reason // Avoid errors when some classes are not loaded for some reason
private val typeMapper = KotlinTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES, fileClassesProvider, incrementalCache, private val typeMapper = KotlinTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES, fileClassesProvider, incrementalCache,
IncompatibleClassTracker.DoNothing, moduleName) IncompatibleClassTracker.DoNothing, moduleName, null)
private val reportDiagnosticsTasks = ArrayList<() -> Unit>() private val reportDiagnosticsTasks = ArrayList<() -> Unit>()
fun reportDiagnostics() { fun reportDiagnostics() {
@@ -130,7 +130,7 @@ class GenerationState @JvmOverloads constructor(
val bindingContext: BindingContext = bindingTrace.bindingContext val bindingContext: BindingContext = bindingTrace.bindingContext
val typeMapper: KotlinTypeMapper = KotlinTypeMapper( val typeMapper: KotlinTypeMapper = KotlinTypeMapper(
this.bindingContext, classBuilderMode, fileClassesProvider, incrementalCacheForThisTarget, this.bindingContext, classBuilderMode, fileClassesProvider, incrementalCacheForThisTarget,
IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace), this.moduleName IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace), this.moduleName, this
) )
val intrinsics: IntrinsicMethods = IntrinsicMethods() val intrinsics: IntrinsicMethods = IntrinsicMethods()
val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this) val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
@@ -99,6 +99,7 @@ public class KotlinTypeMapper {
private final IncrementalCache incrementalCache; private final IncrementalCache incrementalCache;
private final IncompatibleClassTracker incompatibleClassTracker; private final IncompatibleClassTracker incompatibleClassTracker;
private final String moduleName; private final String moduleName;
@Nullable private GenerationState state;
private final TypeMappingConfiguration<Type> typeMappingConfiguration = new TypeMappingConfiguration<Type>() { private final TypeMappingConfiguration<Type> typeMappingConfiguration = new TypeMappingConfiguration<Type>() {
@NotNull @NotNull
@Override @Override
@@ -126,7 +127,8 @@ public class KotlinTypeMapper {
@NotNull JvmFileClassesProvider fileClassesProvider, @NotNull JvmFileClassesProvider fileClassesProvider,
@Nullable IncrementalCache incrementalCache, @Nullable IncrementalCache incrementalCache,
@NotNull IncompatibleClassTracker incompatibleClassTracker, @NotNull IncompatibleClassTracker incompatibleClassTracker,
@NotNull String moduleName @NotNull String moduleName,
@Nullable GenerationState state
) { ) {
this.bindingContext = bindingContext; this.bindingContext = bindingContext;
this.classBuilderMode = classBuilderMode; this.classBuilderMode = classBuilderMode;
@@ -134,6 +136,7 @@ public class KotlinTypeMapper {
this.incrementalCache = incrementalCache; this.incrementalCache = incrementalCache;
this.incompatibleClassTracker = incompatibleClassTracker; this.incompatibleClassTracker = incompatibleClassTracker;
this.moduleName = moduleName; this.moduleName = moduleName;
this.state = state;
} }
@NotNull @NotNull
@@ -161,7 +161,7 @@ abstract class AbstractAnnotationProcessingExtension(
private fun KotlinProcessingEnvironment.createTypeMapper(): KotlinTypeMapper { private fun KotlinProcessingEnvironment.createTypeMapper(): KotlinTypeMapper {
return KotlinTypeMapper(bindingContext, ClassBuilderMode.full(false), NoResolveFileClassesProvider, return KotlinTypeMapper(bindingContext, ClassBuilderMode.full(false), NoResolveFileClassesProvider,
null, IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME) null, IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
} }
private fun KotlinProcessingEnvironment.doAnnotationProcessing(files: Collection<KtFile>): ProcessingResult { private fun KotlinProcessingEnvironment.doAnnotationProcessing(files: Collection<KtFile>): ProcessingResult {
@@ -76,7 +76,7 @@ class KotlinUClass(
override val internalName by lz { override val internalName by lz {
val descriptor = resolveToDescriptor() ?: return@lz null val descriptor = resolveToDescriptor() ?: return@lz null
val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null, val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME) IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
typeMapper.mapClass(descriptor).internalName typeMapper.mapClass(descriptor).internalName
} }
@@ -67,7 +67,7 @@ abstract class KotlinAbstractUFunction : KotlinAbstractUElement(), UFunction, Ps
} }
val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null, val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME) IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
typeMapper.mapAsmMethod(descriptor).descriptor typeMapper.mapAsmMethod(descriptor).descriptor
} }