Saving and loading projection kind of array element type in bytecode.
This commit is contained in:
@@ -166,7 +166,7 @@ public class BothSignatureWriter {
|
||||
writeClassEnd();
|
||||
return;
|
||||
case Type.ARRAY:
|
||||
writeArrayType(nullable);
|
||||
writeArrayType(nullable, Variance.INVARIANT);
|
||||
writeAsmType(asmType.getElementType(), false, kotlinTypeName);
|
||||
writeArrayEnd();
|
||||
return;
|
||||
@@ -235,9 +235,9 @@ public class BothSignatureWriter {
|
||||
jetSignatureWriter.visitEnd();
|
||||
}
|
||||
|
||||
public void writeArrayType(boolean nullable) {
|
||||
public void writeArrayType(boolean nullable, Variance projectionKind) {
|
||||
push(signatureVisitor().visitArrayType());
|
||||
jetSignatureWriter.visitArrayType(nullable);
|
||||
jetSignatureWriter.visitArrayType(nullable, toJetSignatureVariance(projectionKind));
|
||||
if (jvmCurrentType == null) {
|
||||
++jvmCurrentTypeArrayLevel;
|
||||
}
|
||||
|
||||
@@ -266,10 +266,11 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (jetType.getArguments().size() != 1) {
|
||||
throw new UnsupportedOperationException("arrays must have one type argument");
|
||||
}
|
||||
JetType memberType = jetType.getArguments().get(0).getType();
|
||||
TypeProjection memberProjection = jetType.getArguments().get(0);
|
||||
JetType memberType = memberProjection.getType();
|
||||
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeArrayType(jetType.isNullable());
|
||||
signatureVisitor.writeArrayType(jetType.isNullable(), memberProjection.getProjectionKind());
|
||||
mapType(memberType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureVisitor.writeArrayEnd();
|
||||
}
|
||||
|
||||
+3
-2
@@ -161,7 +161,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitArrayType(final boolean nullable) {
|
||||
public JetSignatureVisitor visitArrayType(final boolean nullable, final JetSignatureVariance wildcard) {
|
||||
return new JetTypeJetSignatureReader(javaSemanticServices, kotlinBuiltIns, typeVariableResolver) {
|
||||
@Override
|
||||
public void visitBaseType(char descriptor, boolean nullable) {
|
||||
@@ -178,7 +178,8 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
JetType arrayType = TypeUtils.makeNullableAsSpecified(KotlinBuiltIns.getInstance().getArrayType(jetType), nullable);
|
||||
JetType arrayType = TypeUtils.makeNullableAsSpecified(KotlinBuiltIns.getInstance().getArrayType(
|
||||
parseVariance(wildcard), jetType), nullable);
|
||||
JetTypeJetSignatureReader.this.done(arrayType);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
fun nothing(): Array<in Number> = throw Exception()
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
internal final fun nothing(): jet.Array<in jet.Number>
|
||||
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
fun nothing(): Array<out Number> = throw Exception()
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
internal final fun nothing(): jet.Array<out jet.Number>
|
||||
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
fun <T> nothing(): Array<out T> = throw Exception()
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
internal final fun </*0*/ T : jet.Any?>nothing(): jet.Array<out T>
|
||||
@@ -724,6 +724,11 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
|
||||
doTest("compiler/testData/loadKotlin/type/AnyQ.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfInNumber.kt")
|
||||
public void testArrayOfInNumber() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/type/ArrayOfInNumber.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfInt.kt")
|
||||
public void testArrayOfInt() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/type/ArrayOfInt.kt");
|
||||
@@ -734,6 +739,16 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
|
||||
doTest("compiler/testData/loadKotlin/type/ArrayOfInteger.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfOutNumber.kt")
|
||||
public void testArrayOfOutNumber() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/type/ArrayOfOutNumber.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfOutT.kt")
|
||||
public void testArrayOfOutT() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/type/ArrayOfOutT.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfString.kt")
|
||||
public void testArrayOfString() throws Exception {
|
||||
doTest("compiler/testData/loadKotlin/type/ArrayOfString.kt");
|
||||
|
||||
+15
@@ -726,6 +726,11 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/AnyQ.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfInNumber.kt")
|
||||
public void testArrayOfInNumber() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/ArrayOfInNumber.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfInt.kt")
|
||||
public void testArrayOfInt() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/ArrayOfInt.kt");
|
||||
@@ -736,6 +741,16 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/ArrayOfInteger.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfOutNumber.kt")
|
||||
public void testArrayOfOutNumber() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/ArrayOfOutNumber.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfOutT.kt")
|
||||
public void testArrayOfOutT() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/ArrayOfOutT.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ArrayOfString.kt")
|
||||
public void testArrayOfString() throws Exception {
|
||||
doTestSinglePackage("compiler/testData/loadKotlin/type/ArrayOfString.kt");
|
||||
|
||||
@@ -75,7 +75,7 @@ public class JetSignatureAdapter implements JetSignatureVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitArrayType(boolean nullable) {
|
||||
public JetSignatureVisitor visitArrayType(boolean nullable, JetSignatureVariance wildcard) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class JetSignatureExceptionsAdapter implements JetSignatureVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitArrayType(boolean nullable) {
|
||||
public JetSignatureVisitor visitArrayType(boolean nullable, JetSignatureVariance wildcard) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,13 @@ public class JetSignatureReader {
|
||||
return pos;
|
||||
|
||||
case '[':
|
||||
return parseType(signature, pos, v.visitArrayType(nullable));
|
||||
switch (c = signature.charAt(pos)) {
|
||||
case '+':
|
||||
case '-':
|
||||
return parseType(signature, pos + 1, v.visitArrayType(nullable, JetSignatureVariance.parseVariance(c)));
|
||||
default:
|
||||
return parseType(signature, pos, v.visitArrayType(nullable, JetSignatureVariance.INVARIANT));
|
||||
}
|
||||
|
||||
case 'T':
|
||||
end = signature.indexOf(';', pos);
|
||||
|
||||
@@ -123,7 +123,7 @@ public interface JetSignatureVisitor {
|
||||
* @return a non null visitor to visit the signature of the array element
|
||||
* type.
|
||||
*/
|
||||
JetSignatureVisitor visitArrayType(boolean nullable);
|
||||
JetSignatureVisitor visitArrayType(boolean nullable, JetSignatureVariance wildcard);
|
||||
|
||||
/**
|
||||
* Starts the visit of a signature corresponding to a class or interface
|
||||
|
||||
@@ -157,9 +157,12 @@ public class JetSignatureWriter implements JetSignatureVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetSignatureWriter visitArrayType(boolean nullable) {
|
||||
public JetSignatureWriter visitArrayType(boolean nullable, JetSignatureVariance wildcard) {
|
||||
visitNullabe(nullable);
|
||||
buf.append('[');
|
||||
if (wildcard != JetSignatureVariance.INVARIANT) {
|
||||
buf.append(wildcard.getC());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -195,7 +198,7 @@ public class JetSignatureWriter implements JetSignatureVisitor {
|
||||
++argumentStack;
|
||||
buf.append('<');
|
||||
}
|
||||
if (variance.getC() != '=') {
|
||||
if (variance != JetSignatureVariance.INVARIANT) {
|
||||
buf.append(variance.getC());
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user