KT-2566 fix - accessors naming
This commit is contained in:
@@ -27,10 +27,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
* @author max
|
||||
@@ -45,7 +42,7 @@ public abstract class CodegenContext {
|
||||
@Nullable
|
||||
private final CodegenContext parentContext;
|
||||
public final ObjectOrClosureCodegen closure;
|
||||
|
||||
|
||||
HashMap<JetType,Integer> typeInfoConstants;
|
||||
HashMap<Integer,JetType> reverseTypeInfoConstants;
|
||||
int typeInfoConstantsCount;
|
||||
@@ -94,14 +91,6 @@ public abstract class CodegenContext {
|
||||
return contextDescriptor;
|
||||
}
|
||||
|
||||
public String getNamespaceClassName() {
|
||||
DeclarationDescriptor descriptor = contextDescriptor;
|
||||
while(!(descriptor instanceof NamespaceDescriptor)) {
|
||||
descriptor = descriptor.getContainingDeclaration();
|
||||
}
|
||||
return NamespaceCodegen.getJVMClassNameForKotlinNs(DescriptorUtils.getFQName(descriptor).toSafe()).getInternalName();
|
||||
}
|
||||
|
||||
public OwnerKind getContextKind() {
|
||||
return contextKind;
|
||||
}
|
||||
@@ -184,24 +173,7 @@ public abstract class CodegenContext {
|
||||
|
||||
return cur == null ? null : typeMapper.mapType(((ClassDescriptor) cur.getContextDescriptor()).getDefaultType(), MapTypeMode.IMPL);
|
||||
}
|
||||
|
||||
public int getTypeInfoConstantIndex(JetType type) {
|
||||
if (parentContext != CodegenContexts.STATIC) { return parentContext.getTypeInfoConstantIndex(type); }
|
||||
|
||||
if (typeInfoConstants == null) {
|
||||
typeInfoConstants = new LinkedHashMap<JetType, Integer>();
|
||||
reverseTypeInfoConstants = new LinkedHashMap<Integer, JetType>();
|
||||
}
|
||||
|
||||
Integer index = typeInfoConstants.get(type);
|
||||
if (index == null) {
|
||||
index = typeInfoConstantsCount++;
|
||||
typeInfoConstants.put(type, index);
|
||||
reverseTypeInfoConstants.put(index, type);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
DeclarationDescriptor getAccessor(DeclarationDescriptor descriptor) {
|
||||
if (accessors == null) {
|
||||
accessors = new HashMap<DeclarationDescriptor,DeclarationDescriptor>();
|
||||
@@ -234,7 +206,7 @@ public abstract class CodegenContext {
|
||||
pd.getVisibility(),
|
||||
pd.isVar(),
|
||||
pd.isObjectDeclaration(),
|
||||
Name.identifier(pd.getName() + "$bridge$" + accessors.size()),
|
||||
Name.identifier(pd.getName() + "$b$" + getHierarchyCount() + "$" + accessors.size()),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
||||
@@ -245,7 +217,7 @@ public abstract class CodegenContext {
|
||||
myAccessor.getVisibility(),
|
||||
false, false, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
pgd.initialize(myAccessor.getType());
|
||||
|
||||
|
||||
PropertySetterDescriptor psd = new PropertySetterDescriptor(
|
||||
myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(),
|
||||
myAccessor.getVisibility(),
|
||||
@@ -261,14 +233,19 @@ public abstract class CodegenContext {
|
||||
}
|
||||
|
||||
private int getHierarchyCount() {
|
||||
ClassifierDescriptor descriptor = getThisDescriptor();
|
||||
ClassDescriptor descriptor = getThisDescriptor();
|
||||
int c = 0;
|
||||
while(true) {
|
||||
Collection<? extends JetType> supertypes = descriptor.getDefaultType().getConstructor().getSupertypes();
|
||||
if(supertypes.isEmpty())
|
||||
if (supertypes.isEmpty())
|
||||
return c;
|
||||
c++;
|
||||
descriptor = supertypes.iterator().next().getConstructor().getDeclarationDescriptor();
|
||||
for (JetType supertype : supertypes) {
|
||||
descriptor = (ClassDescriptor) supertype.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor.getKind() == ClassKind.CLASS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
open class A {
|
||||
open fun foo() = "OK"
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
override fun foo() = super.foo()
|
||||
}
|
||||
|
||||
trait I
|
||||
|
||||
class C : I, B() {
|
||||
override fun foo() = super<B>.foo()
|
||||
}
|
||||
|
||||
fun box() = C().foo()
|
||||
@@ -0,0 +1,17 @@
|
||||
open class A {
|
||||
open val foo: String = "OK"
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
class E {
|
||||
val foo: String = super<A>@B.foo
|
||||
}
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
class D {
|
||||
val foo: String = super<B>@C.foo
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = C().foo
|
||||
@@ -471,4 +471,14 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt2395.kt");
|
||||
}
|
||||
|
||||
public void testKt2566() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt2566.kt");
|
||||
}
|
||||
|
||||
public void testKt2566_2() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt2566_2.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user