Get reified signature from JetTypeMapper

#KT-6485 Fixed
This commit is contained in:
Denis Zharkov
2014-12-18 16:01:41 +03:00
parent 6df91fdda7
commit 04e560bc74
6 changed files with 42 additions and 9 deletions
@@ -37,6 +37,7 @@ import org.jetbrains.jet.codegen.context.*;
import org.jetbrains.jet.codegen.inline.*;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.codegen.when.SwitchCodegen;
@@ -2311,10 +2312,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(entry.getValue());
if (parameterDescriptor == null) {
// type is not generic
// boxType call needed because inlined method is compiled for T as java/lang/Object
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE);
Type type = typeMapper.mapTypeParameter(entry.getValue(), signatureWriter);
mappings.addParameterMappingToType(
key.getName().getIdentifier(),
boxType(asmType(entry.getValue()))
type,
signatureWriter.toString()
);
}
else {
@@ -105,8 +105,7 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame
}
// else TypeVariable is replaced by concrete type
visitClassType(mapping.asmType!!.getInternalName())
visitEnd()
SignatureReader(mapping.signature).accept(this)
}
override fun visitFormalTypeParameter(name: String?) {
@@ -197,12 +196,12 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame
public class ReifiedTypeParameterMappings() {
private val mappingsByName = hashMapOf<String, ReifiedTypeParameterMapping>()
public fun addParameterMappingToType(name: String, asmType: Type) {
mappingsByName[name] = ReifiedTypeParameterMapping(name, asmType, null)
public fun addParameterMappingToType(name: String, asmType: Type, signature: String) {
mappingsByName[name] = ReifiedTypeParameterMapping(name, asmType, newName = null, signature = signature)
}
public fun addParameterMappingToNewParameter(name: String, newName: String) {
mappingsByName[name] = ReifiedTypeParameterMapping(name, null, newName)
mappingsByName[name] = ReifiedTypeParameterMapping(name, asmType = null, newName = newName, signature = null)
}
fun get(name: String): ReifiedTypeParameterMapping? {
@@ -210,7 +209,7 @@ public class ReifiedTypeParameterMappings() {
}
}
public class ReifiedTypeParameterMapping(val name: String, val asmType: Type?, val newName: String?)
public class ReifiedTypeParameterMapping(val name: String, val asmType: Type?, val newName: String?, val signature: String?)
public class ReifiedTypeParametersUsages {
val usedTypeParameters: MutableSet<String> = hashSetOf()
@@ -184,6 +184,11 @@ public class JetTypeMapper {
return mapType(jetType, signatureVisitor, JetTypeMapperMode.SUPER_TYPE);
}
@NotNull
public Type mapTypeParameter(@NotNull JetType jetType, @Nullable BothSignatureWriter signatureVisitor) {
return mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
}
@NotNull
public Type mapClass(@NotNull ClassifierDescriptor classifier) {
return mapType(classifier.getDefaultType(), null, JetTypeMapperMode.IMPL);