JS backend: fixed name clash when override native class.
This commit is contained in:
@@ -28,9 +28,11 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.getContainingClass;
|
||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.isOverride;
|
||||
|
||||
public final class AnnotationsUtils {
|
||||
|
||||
@@ -72,18 +74,23 @@ public final class AnnotationsUtils {
|
||||
|
||||
@Nullable
|
||||
public static String getNameForAnnotatedObjectWithOverrides(@NotNull DeclarationDescriptor declarationDescriptor) {
|
||||
Set<DeclarationDescriptor> descriptors;
|
||||
List<DeclarationDescriptor> descriptors;
|
||||
|
||||
if (declarationDescriptor instanceof CallableMemberDescriptor &&
|
||||
((CallableMemberDescriptor) declarationDescriptor).getKind() != CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
isOverride((CallableMemberDescriptor) declarationDescriptor)) {
|
||||
|
||||
Set<CallableMemberDescriptor> overriddenDeclarations =
|
||||
BindingContextUtils.getAllOverriddenDeclarations((CallableMemberDescriptor) declarationDescriptor);
|
||||
//noinspection unchecked
|
||||
descriptors = ContainerUtil.<CallableMemberDescriptor, DeclarationDescriptor>map2Set(overriddenDeclarations, Function.ID);
|
||||
|
||||
descriptors = ContainerUtil.mapNotNull(overriddenDeclarations, new Function<CallableMemberDescriptor, DeclarationDescriptor>() {
|
||||
@Override
|
||||
public DeclarationDescriptor fun(CallableMemberDescriptor descriptor) {
|
||||
return isOverride(descriptor) ? null : descriptor;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
descriptors = ContainerUtil.newHashSet(declarationDescriptor);
|
||||
descriptors = ContainerUtil.newArrayList(declarationDescriptor);
|
||||
}
|
||||
|
||||
for (DeclarationDescriptor descriptor : descriptors) {
|
||||
|
||||
@@ -18,8 +18,9 @@ class B(val b: Int) : A(b / 2) {
|
||||
fun boo(i: String): String = "B.boo($i: String)"
|
||||
|
||||
fun bar(i: String): String = "B.bar($i: String)"
|
||||
override fun baz(i: Int): String = "B.baz($i: Int)"
|
||||
fun bar(): String = "B.bar()"
|
||||
override fun baz(i: Int): String = "B.baz($i: Int)"
|
||||
fun bar(d: Double): String = "B.bar($d: Double)"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
@@ -38,6 +39,7 @@ fun box(): String {
|
||||
if (b.bar("apl") != "B.bar(apl: String)") return "b.bar(\"apl\") != \"B.bar(apl: String)\", it: ${b.bar("apl")}"
|
||||
if (b.baz(34) != "B.baz(34: Int)") return "b.baz(34) != \"B.baz(34: Int)\", it: ${b.baz(34)}"
|
||||
if (b.bar() != "B.bar()") return "b.bar() != \"B.bar()\", it: ${b.bar()}"
|
||||
if (b.bar(2.213) != "B.bar(2.213: Double)") return "b.bar(2.213) != \"B.bar(2.213: Double)\", it: ${b.bar(2.213)}"
|
||||
|
||||
val a: A = b
|
||||
|
||||
|
||||
Reference in New Issue
Block a user