GenerationState in TypeMapper replaced with boolean flag
This commit is contained in:
@@ -62,6 +62,10 @@ public class JvmCodegenUtil {
|
||||
}
|
||||
|
||||
public static boolean isAnnotationOrJvm6Interface(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
|
||||
return isAnnotationOrJvm6Interface(descriptor, state.isJvm8Target());
|
||||
}
|
||||
|
||||
public static boolean isAnnotationOrJvm6Interface(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target) {
|
||||
if (!isJvmInterface(descriptor)) {
|
||||
return false;
|
||||
}
|
||||
@@ -76,11 +80,15 @@ public class JvmCodegenUtil {
|
||||
return ((FileBasedKotlinClass) binaryClass).getClassVersion() == Opcodes.V1_6;
|
||||
}
|
||||
}
|
||||
return !state.isJvm8Target();
|
||||
return !isJvm8Target;
|
||||
}
|
||||
|
||||
public static boolean isJvm8Interface(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
|
||||
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvm6Interface(descriptor, state);
|
||||
return isJvm8Interface(descriptor, state.isJvm8Target());
|
||||
}
|
||||
|
||||
public static boolean isJvm8Interface(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target) {
|
||||
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvm6Interface(descriptor, isJvm8Target);
|
||||
}
|
||||
|
||||
public static boolean isJvm8InterfaceMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
|
||||
class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
|
||||
// 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,
|
||||
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
|
||||
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
|
||||
|
||||
override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapAsmMethod(function)
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
|
||||
// Avoid errors when some classes are not loaded for some reason
|
||||
private val typeMapper = KotlinTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES, fileClassesProvider, incrementalCache,
|
||||
IncompatibleClassTracker.DoNothing, moduleName, null)
|
||||
IncompatibleClassTracker.DoNothing, moduleName, false)
|
||||
private val reportDiagnosticsTasks = ArrayList<() -> Unit>()
|
||||
|
||||
fun reportDiagnostics() {
|
||||
|
||||
@@ -124,13 +124,16 @@ class GenerationState @JvmOverloads constructor(
|
||||
extraJvmDiagnosticsTrace.bindingContext.diagnostics
|
||||
}
|
||||
|
||||
val isJvm8Target: Boolean = configuration.get(JVMConfigurationKeys.JVM_TARGET) == JvmTarget.JVM_1_8
|
||||
val generateDefaultImplsForJvm8: Boolean = configuration.getBoolean(JVMConfigurationKeys.INTERFACE_COMPATIBILITY)
|
||||
|
||||
val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module)
|
||||
val classBuilderMode: ClassBuilderMode = builderFactory.classBuilderMode
|
||||
val bindingTrace: BindingTrace = DelegatingBindingTrace(bindingContext, "trace in GenerationState")
|
||||
val bindingContext: BindingContext = bindingTrace.bindingContext
|
||||
val typeMapper: KotlinTypeMapper = KotlinTypeMapper(
|
||||
this.bindingContext, classBuilderMode, fileClassesProvider, incrementalCacheForThisTarget,
|
||||
IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace), this.moduleName, this
|
||||
IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace), this.moduleName, isJvm8Target
|
||||
)
|
||||
val intrinsics: IntrinsicMethods = IntrinsicMethods()
|
||||
val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
|
||||
@@ -156,8 +159,6 @@ class GenerationState @JvmOverloads constructor(
|
||||
val isInlineDisabled: Boolean = configuration.getBoolean(CommonConfigurationKeys.DISABLE_INLINE)
|
||||
val useTypeTableInSerializer: Boolean = configuration.getBoolean(JVMConfigurationKeys.USE_TYPE_TABLE)
|
||||
val inheritMultifileParts: Boolean = configuration.getBoolean(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS)
|
||||
val isJvm8Target: Boolean = configuration.get(JVMConfigurationKeys.JVM_TARGET) == JvmTarget.JVM_1_8
|
||||
val generateDefaultImplsForJvm8: Boolean = configuration.getBoolean(JVMConfigurationKeys.INTERFACE_COMPATIBILITY)
|
||||
|
||||
val rootContext: CodegenContext<*> = RootContext(this)
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class KotlinTypeMapper {
|
||||
private final IncrementalCache incrementalCache;
|
||||
private final IncompatibleClassTracker incompatibleClassTracker;
|
||||
private final String moduleName;
|
||||
@Nullable private GenerationState state;
|
||||
private boolean isJvm8Target;
|
||||
private final TypeMappingConfiguration<Type> typeMappingConfiguration = new TypeMappingConfiguration<Type>() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -128,7 +128,7 @@ public class KotlinTypeMapper {
|
||||
@Nullable IncrementalCache incrementalCache,
|
||||
@NotNull IncompatibleClassTracker incompatibleClassTracker,
|
||||
@NotNull String moduleName,
|
||||
@Nullable GenerationState state
|
||||
boolean isJvm8Target
|
||||
) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.classBuilderMode = classBuilderMode;
|
||||
@@ -136,7 +136,7 @@ public class KotlinTypeMapper {
|
||||
this.incrementalCache = incrementalCache;
|
||||
this.incompatibleClassTracker = incompatibleClassTracker;
|
||||
this.moduleName = moduleName;
|
||||
this.state = state;
|
||||
this.isJvm8Target = isJvm8Target;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -744,7 +744,7 @@ public class KotlinTypeMapper {
|
||||
}
|
||||
|
||||
private boolean isJvm8Interface(@NotNull ClassDescriptor ownerForDefault) {
|
||||
return isJvmInterface(ownerForDefault) && (state != null && JvmCodegenUtil.isJvm8Interface(ownerForDefault, state));
|
||||
return isJvmInterface(ownerForDefault) && JvmCodegenUtil.isJvm8Interface(ownerForDefault, isJvm8Target);
|
||||
}
|
||||
|
||||
public static boolean isAccessor(@NotNull CallableMemberDescriptor descriptor) {
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ abstract class AbstractAnnotationProcessingExtension(
|
||||
|
||||
private fun KotlinProcessingEnvironment.createTypeMapper(): KotlinTypeMapper {
|
||||
return KotlinTypeMapper(bindingContext, ClassBuilderMode.full(false), NoResolveFileClassesProvider,
|
||||
null, IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
|
||||
null, IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
|
||||
}
|
||||
|
||||
private fun KotlinProcessingEnvironment.doAnnotationProcessing(files: Collection<KtFile>): ProcessingResult {
|
||||
|
||||
@@ -76,7 +76,7 @@ class KotlinUClass(
|
||||
override val internalName by lz {
|
||||
val descriptor = resolveToDescriptor() ?: return@lz null
|
||||
val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null,
|
||||
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
|
||||
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
|
||||
typeMapper.mapClass(descriptor).internalName
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ abstract class KotlinAbstractUFunction : KotlinAbstractUElement(), UFunction, Ps
|
||||
}
|
||||
|
||||
val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider, null,
|
||||
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, null)
|
||||
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
|
||||
typeMapper.mapAsmMethod(descriptor).descriptor
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user