JS backend: use all generic parameters in mangling

This commit is contained in:
Zalim Bashorov
2014-09-30 22:14:22 +04:00
parent 10a9c0a434
commit 9b04e3e3fe
5 changed files with 42 additions and 19 deletions
@@ -241,7 +241,7 @@ public final class PatternBuilder {
if (actualReceiver != null) {
if (receiverFqName == null) return false;
String actualReceiverFqName = TranslationUtils.getJetTypeFqName(actualReceiver.getType());
String actualReceiverFqName = TranslationUtils.getJetTypeFqName(actualReceiver.getType(), false);
if (!actualReceiverFqName.equals(receiverFqName)) return false;
}
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import java.util.*;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.k2js.translate.utils.TranslationUtils.getJetTypeFqName;
public class ManglingUtils {
private ManglingUtils() {}
@@ -180,13 +181,13 @@ public class ManglingUtils {
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
if (receiverParameter != null) {
argTypes.append(TranslationUtils.getJetTypeFqName(receiverParameter.getType())).append(".");
argTypes.append(getJetTypeFqName(receiverParameter.getType(), true)).append(".");
}
argTypes.append(StringUtil.join(descriptor.getValueParameters(), new Function<ValueParameterDescriptor, String>() {
@Override
public String fun(ValueParameterDescriptor descriptor) {
return TranslationUtils.getJetTypeFqName(descriptor.getType());
return getJetTypeFqName(descriptor.getType(), true);
}
}, ","));
@@ -17,12 +17,15 @@
package org.jetbrains.k2js.translate.utils;
import com.google.dart.compiler.backend.js.ast.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeProjection;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.k2js.translate.context.TemporaryConstVariable;
import org.jetbrains.k2js.translate.context.TranslationContext;
@@ -134,15 +137,34 @@ public final class TranslationUtils {
}
@NotNull
public static String getJetTypeFqName(@NotNull JetType jetType) {
public static String getJetTypeFqName(@NotNull JetType jetType, boolean printTypeArguments) {
ClassifierDescriptor declaration = jetType.getConstructor().getDeclarationDescriptor();
assert declaration != null;
if (declaration instanceof TypeParameterDescriptor) {
return getJetTypeFqName(((TypeParameterDescriptor) declaration).getUpperBoundsAsType());
TypeParameterDescriptor typeParameter = (TypeParameterDescriptor) declaration;
return getJetTypeFqName(typeParameter.getUpperBoundsAsType(), printTypeArguments);
}
return getFqName(declaration).asString();
List<TypeProjection> typeArguments = jetType.getArguments();
String typeArgumentsAsString;
if (printTypeArguments && !typeArguments.isEmpty()) {
String joinedTypeArguments = StringUtil.join(typeArguments, new Function<TypeProjection, String>() {
@Override
public String fun(TypeProjection typeProjection) {
return getJetTypeFqName(typeProjection.getType(), false);
}
}, ", ");
typeArgumentsAsString = "<" + joinedTypeArguments + ">";
}
else {
typeArgumentsAsString = "";
}
return getFqName(declaration).asString() + typeArgumentsAsString;
}
@NotNull
+5 -5
View File
@@ -300,7 +300,7 @@
);
Kotlin.AbstractCollection = Kotlin.createClassNow(Kotlin.Collection, null, {
addAll_xeylzf$: function (collection) {
addAll_4fm7v2$: function (collection) {
var modified = false;
var it = collection.iterator();
while (it.hasNext()) {
@@ -310,7 +310,7 @@
}
return modified
},
removeAll_xeylzf$: function (c) {
removeAll_4fm7v2$: function (c) {
var modified = false;
var it = this.iterator();
while (it.hasNext()) {
@@ -321,7 +321,7 @@
}
return modified
},
retainAll_xeylzf$: function (c) {
retainAll_4fm7v2$: function (c) {
var modified = false;
var it = this.iterator();
while (it.hasNext()) {
@@ -332,7 +332,7 @@
}
return modified
},
containsAll_xeylzf$: function (c) {
containsAll_4fm7v2$: function (c) {
var it = c.iterator();
while (it.hasNext()) {
if (!this.contains_za3rmp$(it.next())) return false;
@@ -428,7 +428,7 @@
add_vux3hl$: function (index, element) {
this.array.splice(index, 0, element);
},
addAll_xeylzf$: function (collection) {
addAll_4fm7v2$: function (collection) {
var it = collection.iterator();
for (var i = this.array.length, n = collection.size(); n-- > 0;) {
this.array[i++] = it.next();
+8 -8
View File
@@ -380,11 +380,11 @@
/**
* @param {Hashtable.<Key, Value>} hashtable
*/
this.putAll_za3j1t$ = hashMapPutAll;
this.putAll_48yl7j$ = hashMapPutAll;
this.clone = function () {
var clone = new Hashtable(hashingFunctionParam, equalityFunctionParam);
clone.putAll_za3j1t$(that);
clone.putAll_48yl7j$(that);
return clone;
};
@@ -530,7 +530,7 @@
this.$size = 0;
this.map = {};
},
putAll_za3j1t$: hashMapPutAll,
putAll_48yl7j$: hashMapPutAll,
entrySet: function () {
var result = new Kotlin.ComplexHashSet();
var map = this.map;
@@ -820,10 +820,10 @@ Kotlin.PrimitiveBooleanHashSet = Kotlin.createClassNow(Kotlin.AbstractPrimitiveH
function HashSet(hashingFunction, equalityFunction) {
var hashTable = new Kotlin.HashTable(hashingFunction, equalityFunction);
this.addAll_xeylzf$ = Kotlin.AbstractCollection.prototype.addAll_xeylzf$;
this.removeAll_xeylzf$ = Kotlin.AbstractCollection.prototype.removeAll_xeylzf$;
this.retainAll_xeylzf$ = Kotlin.AbstractCollection.prototype.retainAll_xeylzf$;
this.containsAll_xeylzf$ = Kotlin.AbstractCollection.prototype.containsAll_xeylzf$;
this.addAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.addAll_4fm7v2$;
this.removeAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.removeAll_4fm7v2$;
this.retainAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.retainAll_4fm7v2$;
this.containsAll_4fm7v2$ = Kotlin.AbstractCollection.prototype.containsAll_4fm7v2$;
this.add_za3rmp$ = function (o) {
return !hashTable.put_wn2jw4$(o, true);
@@ -860,7 +860,7 @@ Kotlin.PrimitiveBooleanHashSet = Kotlin.createClassNow(Kotlin.AbstractPrimitiveH
this.clone = function () {
var h = new HashSet(hashingFunction, equalityFunction);
h.addAll_xeylzf$(hashTable.keys());
h.addAll_4fm7v2$(hashTable.keys());
return h;
};