synchronizing my and Alex' signature writers and readers
This commit is contained in:
committed by
Nikolay Krasko
parent
9a8a1be1bb
commit
c46fe1381f
+1
-1
@@ -34,7 +34,7 @@ public abstract class JetTypeJetSignatureReader implements JetSignatureVisitor {
|
||||
|
||||
|
||||
@Override
|
||||
public void visitFormalTypeParameter(String name) {
|
||||
public void visitFormalTypeParameter(String name, Variance variance) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.signature;
|
||||
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class JetSignatureAdapter implements JetSignatureVisitor {
|
||||
@Override
|
||||
public void visitFormalTypeParameter(String name) {
|
||||
public void visitFormalTypeParameter(String name, Variance variance) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-1
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.signature;
|
||||
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.objectweb.asm.signature.SignatureReader;
|
||||
import org.objectweb.asm.signature.SignatureVisitor;
|
||||
|
||||
@@ -26,8 +27,19 @@ public class JetSignatureReader {
|
||||
if (signature.charAt(0) == '<') {
|
||||
pos = 2;
|
||||
do {
|
||||
Variance variance;
|
||||
if (signature.substring(pos).startsWith("in ")) {
|
||||
variance = Variance.IN_VARIANCE;
|
||||
pos += "in ".length();
|
||||
} else if (signature.substring(pos).startsWith("out ")) {
|
||||
variance = Variance.OUT_VARIANCE;
|
||||
pos += "out ".length();
|
||||
} else {
|
||||
variance = Variance.INVARIANT;
|
||||
pos += "".length();
|
||||
}
|
||||
int end = signature.indexOf(':', pos);
|
||||
v.visitFormalTypeParameter(signature.substring(pos - 1, end));
|
||||
v.visitFormalTypeParameter(signature.substring(pos - 1, end), variance);
|
||||
pos = end + 1;
|
||||
|
||||
c = signature.charAt(pos);
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.signature;
|
||||
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.objectweb.asm.signature.SignatureVisitor;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,7 @@ public interface JetSignatureVisitor {
|
||||
*
|
||||
* @param name the name of the formal parameter.
|
||||
*/
|
||||
void visitFormalTypeParameter(String name);
|
||||
void visitFormalTypeParameter(String name, Variance variance);
|
||||
|
||||
/**
|
||||
* Visits the class bound of the last visited formal type parameter.
|
||||
|
||||
+14
-1
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.signature;
|
||||
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.objectweb.asm.signature.SignatureWriter;
|
||||
|
||||
/**
|
||||
@@ -43,11 +44,23 @@ public class JetSignatureWriter implements JetSignatureVisitor {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void visitFormalTypeParameter(final String name) {
|
||||
public void visitFormalTypeParameter(final String name, Variance variance) {
|
||||
if (!hasFormals) {
|
||||
hasFormals = true;
|
||||
buf.append('<');
|
||||
}
|
||||
switch (variance) {
|
||||
case OUT_VARIANCE:
|
||||
buf.append("out ");
|
||||
break;
|
||||
case IN_VARIANCE:
|
||||
buf.append("in ");
|
||||
break;
|
||||
case INVARIANT:
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
buf.append(name);
|
||||
buf.append(':');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user