Minor.Reformat

This commit is contained in:
Mikhael Bogdanov
2018-03-07 14:52:23 +01:00
parent c1c8660e55
commit 95a7e6c2d5
@@ -168,8 +168,7 @@ private fun getInlineName(
val implementationOwnerInternalName: String? = val implementationOwnerInternalName: String? =
if (file == null) { if (file == null) {
CodegenContextUtil.getImplementationOwnerClassType(codegenContext)?.internalName CodegenContextUtil.getImplementationOwnerClassType(codegenContext)?.internalName
} } else JvmFileClassUtil.getFileClassInternalName(file)
else JvmFileClassUtil.getFileClassInternalName(file)
if (implementationOwnerInternalName == null) { if (implementationOwnerInternalName == null) {
val contextDescriptor = codegenContext.contextDescriptor val contextDescriptor = codegenContext.contextDescriptor
@@ -338,8 +337,7 @@ internal fun buildClassReaderByInternalName(state: GenerationState, internalName
return ClassReader(outputFile.asByteArray()) return ClassReader(outputFile.asByteArray())
} }
val file = findVirtualFileImprecise(state, internalName) ?: val file = findVirtualFileImprecise(state, internalName) ?: throw RuntimeException("Couldn't find virtual file for " + internalName)
throw RuntimeException("Couldn't find virtual file for " + internalName)
return ClassReader(file.contentsToByteArray()) return ClassReader(file.contentsToByteArray())
} }
@@ -538,15 +536,20 @@ internal fun createSpecialEnumMethodBody(
val invokeType = typeMapper.mapType(type) val invokeType = typeMapper.mapType(type)
val desc = getSpecialEnumFunDescriptor(invokeType, isValueOf) val desc = getSpecialEnumFunDescriptor(invokeType, isValueOf)
val node = MethodNode(API, Opcodes.ACC_STATIC, "fake", desc, null, null) val node = MethodNode(API, Opcodes.ACC_STATIC, "fake", desc, null, null)
ExpressionCodegen.putReifiedOperationMarkerIfTypeIsReifiedParameterWithoutPropagation(type, ReifiedTypeInliner.OperationKind.ENUM_REIFIED, InstructionAdapter(node)) ExpressionCodegen.putReifiedOperationMarkerIfTypeIsReifiedParameterWithoutPropagation(
type,
ReifiedTypeInliner.OperationKind.ENUM_REIFIED,
InstructionAdapter(node)
)
if (isValueOf) { if (isValueOf) {
node.visitInsn(Opcodes.ACONST_NULL) node.visitInsn(Opcodes.ACONST_NULL)
node.visitVarInsn(Opcodes.ALOAD, 0) node.visitVarInsn(Opcodes.ALOAD, 0)
node.visitMethodInsn(Opcodes.INVOKESTATIC, ENUM_TYPE.internalName, "valueOf", node.visitMethodInsn(
Type.getMethodDescriptor(ENUM_TYPE, JAVA_CLASS_TYPE, AsmTypes.JAVA_STRING_TYPE), false) Opcodes.INVOKESTATIC, ENUM_TYPE.internalName, "valueOf",
} Type.getMethodDescriptor(ENUM_TYPE, JAVA_CLASS_TYPE, AsmTypes.JAVA_STRING_TYPE), false
else { )
} else {
node.visitInsn(Opcodes.ICONST_0) node.visitInsn(Opcodes.ICONST_0)
node.visitTypeInsn(Opcodes.ANEWARRAY, ENUM_TYPE.internalName) node.visitTypeInsn(Opcodes.ANEWARRAY, ENUM_TYPE.internalName)
} }
@@ -556,7 +559,10 @@ internal fun createSpecialEnumMethodBody(
} }
internal fun getSpecialEnumFunDescriptor(type: Type, isValueOf: Boolean): String { internal fun getSpecialEnumFunDescriptor(type: Type, isValueOf: Boolean): String {
return if (isValueOf) Type.getMethodDescriptor(type, AsmTypes.JAVA_STRING_TYPE) else Type.getMethodDescriptor(AsmUtil.getArrayType(type)) return if (isValueOf) Type.getMethodDescriptor(
type,
AsmTypes.JAVA_STRING_TYPE
) else Type.getMethodDescriptor(AsmUtil.getArrayType(type))
} }
@@ -573,10 +579,10 @@ fun FunctionDescriptor.getClassFilePath(typeMapper: KotlinTypeMapper, cache: Inc
return when (source) { return when (source) {
is KotlinJvmBinaryPackageSourceElement -> { is KotlinJvmBinaryPackageSourceElement -> {
val directMember = JvmCodegenUtil.getDirectMember(this) as? DeserializedCallableMemberDescriptor ?: val directMember = JvmCodegenUtil.getDirectMember(this) as? DeserializedCallableMemberDescriptor
throw AssertionError("Expected DeserializedCallableMemberDescriptor, got: $this") ?: throw AssertionError("Expected DeserializedCallableMemberDescriptor, got: $this")
val kotlinClass = source.getContainingBinaryClass(directMember) ?: val kotlinClass =
throw AssertionError("Descriptor $this is not found, in: $source") source.getContainingBinaryClass(directMember) ?: throw AssertionError("Descriptor $this is not found, in: $source")
if (kotlinClass !is VirtualFileKotlinClass) { if (kotlinClass !is VirtualFileKotlinClass) {
throw AssertionError("Expected VirtualFileKotlinClass, got $kotlinClass") throw AssertionError("Expected VirtualFileKotlinClass, got $kotlinClass")
} }