Introduce TypeMappingMode.toGenericArgumentMode

This commit is contained in:
Denis Zharkov
2015-11-19 18:10:01 +03:00
parent ef2bc28463
commit faf1e17888
2 changed files with 13 additions and 8 deletions
@@ -440,10 +440,7 @@ public class JetTypeMapper {
arrayElementType = boxType(mapType(memberType, mode)); arrayElementType = boxType(mapType(memberType, mode));
if (signatureVisitor != null) { if (signatureVisitor != null) {
signatureVisitor.writeArrayType(); signatureVisitor.writeArrayType();
TypeMappingMode newMode = mode.isForAnnotationParameter() ? mapType(memberType, signatureVisitor, mode.toGenericArgumentMode());
TypeMappingMode.GENERIC_TYPE_PARAMETER_FOR_ANNOTATION_PARAMETER :
TypeMappingMode.GENERIC_TYPE;
mapType(memberType, signatureVisitor, newMode, memberProjection.getProjectionKind());
signatureVisitor.writeArrayEnd(); signatureVisitor.writeArrayEnd();
} }
} }
@@ -649,7 +646,7 @@ public class JetTypeMapper {
getEffectiveVariance(parameter.getVariance(), argument.getProjectionKind(), howThisTypeIsUsed, mode); getEffectiveVariance(parameter.getVariance(), argument.getProjectionKind(), howThisTypeIsUsed, mode);
signatureVisitor.writeTypeArgument(projectionKind); signatureVisitor.writeTypeArgument(projectionKind);
mapType(argument.getType(), signatureVisitor, TypeMappingMode.GENERIC_TYPE); mapType(argument.getType(), signatureVisitor, mode.toGenericArgumentMode());
signatureVisitor.writeTypeArgumentEnd(); signatureVisitor.writeTypeArgumentEnd();
} }
} }
@@ -24,7 +24,9 @@ internal enum class TypeMappingMode(
/** /**
* kotlin.Int is mapped to I * kotlin.Int is mapped to I
*/ */
DEFAULT(), DEFAULT() {
override fun toGenericArgumentMode(): TypeMappingMode = GENERIC_TYPE
},
/** /**
* kotlin.Int is mapped to Ljava/lang/Integer; * kotlin.Int is mapped to Ljava/lang/Integer;
*/ */
@@ -33,15 +35,21 @@ internal enum class TypeMappingMode(
* kotlin.Int is mapped to Ljava/lang/Integer; * kotlin.Int is mapped to Ljava/lang/Integer;
* No projections allowed in immediate arguments * No projections allowed in immediate arguments
*/ */
SUPER_TYPE(needPrimitiveBoxing = true, writeDeclarationSiteProjections = false), SUPER_TYPE(needPrimitiveBoxing = true, writeDeclarationSiteProjections = false) {
override fun toGenericArgumentMode(): TypeMappingMode = GENERIC_TYPE
},
/** /**
* kotlin.reflect.KClass mapped to java.lang.Class * kotlin.reflect.KClass mapped to java.lang.Class
* Other types mapped as DEFAULT * Other types mapped as DEFAULT
*/ */
VALUE_FOR_ANNOTATION(isForAnnotationParameter = true), VALUE_FOR_ANNOTATION(isForAnnotationParameter = true) {
override fun toGenericArgumentMode(): TypeMappingMode = GENERIC_TYPE_PARAMETER_FOR_ANNOTATION_PARAMETER
},
/** /**
* kotlin.reflect.KClass mapped to java.lang.Class * kotlin.reflect.KClass mapped to java.lang.Class
* Other types mapped as GENERIC_TYPE * Other types mapped as GENERIC_TYPE
*/ */
GENERIC_TYPE_PARAMETER_FOR_ANNOTATION_PARAMETER(isForAnnotationParameter = true, needPrimitiveBoxing = true); GENERIC_TYPE_PARAMETER_FOR_ANNOTATION_PARAMETER(isForAnnotationParameter = true, needPrimitiveBoxing = true);
open fun toGenericArgumentMode(): TypeMappingMode = this
} }