better JetTypeMapper.getFQName
This commit is contained in:
@@ -190,7 +190,7 @@ public class CodegenContexts {
|
|||||||
|
|
||||||
final Type type = enclosingClassType(typeMapper);
|
final Type type = enclosingClassType(typeMapper);
|
||||||
outerExpression = type != null
|
outerExpression = type != null
|
||||||
? StackValue.field(type, JvmClassName.byInternalName(typeMapper.getFQName(contextType)), "this$0", false)
|
? StackValue.field(type, typeMapper.getClassFQName(contextType), "this$0", false)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -269,9 +269,9 @@ public class JetTypeMapper {
|
|||||||
String local = getLocalNameForObject(object);
|
String local = getLocalNameForObject(object);
|
||||||
if (local == null) return null;
|
if (local == null) return null;
|
||||||
|
|
||||||
DeclarationDescriptor containingClass = getContainingClass(descriptor);
|
ClassDescriptor containingClass = getContainingClass(descriptor);
|
||||||
if (containingClass != null) {
|
if (containingClass != null) {
|
||||||
return getFQName(containingClass) + "$" + local;
|
return getClassFQName(containingClass).getInternalName() + "$" + local;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return getFQName(getContainingNamespace(descriptor)) + "/" + local;
|
return getFQName(getContainingNamespace(descriptor)) + "/" + local;
|
||||||
@@ -296,11 +296,12 @@ public class JetTypeMapper {
|
|||||||
*
|
*
|
||||||
* @see DescriptorUtils#getFQName(DeclarationDescriptor)
|
* @see DescriptorUtils#getFQName(DeclarationDescriptor)
|
||||||
*/
|
*/
|
||||||
public String getFQName(DeclarationDescriptor descriptor) {
|
@NotNull
|
||||||
|
private String getFQName(@NotNull DeclarationDescriptor descriptor) {
|
||||||
descriptor = descriptor.getOriginal();
|
descriptor = descriptor.getOriginal();
|
||||||
|
|
||||||
if(descriptor instanceof FunctionDescriptor) {
|
if (descriptor instanceof FunctionDescriptor) {
|
||||||
return getFQName(descriptor.getContainingDeclaration());
|
throw new IllegalStateException("requested fq name for function: " + descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor.getContainingDeclaration() instanceof ModuleDescriptor || descriptor instanceof ScriptDescriptor) {
|
if (descriptor.getContainingDeclaration() instanceof ModuleDescriptor || descriptor instanceof ScriptDescriptor) {
|
||||||
@@ -327,26 +328,22 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||||
|
|
||||||
|
if (container == null) {
|
||||||
|
throw new IllegalStateException("descriptor has no container: " + descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
Name name = descriptor.getName();
|
Name name = descriptor.getName();
|
||||||
if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) {
|
|
||||||
return closureAnnotator
|
|
||||||
.classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor))
|
|
||||||
.getInternalName();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor instanceof ClassDescriptor) {
|
if (descriptor instanceof ClassDescriptor && name.isSpecial()) {
|
||||||
ClassDescriptor clazz = (ClassDescriptor) descriptor;
|
ClassDescriptor clazz = (ClassDescriptor) descriptor;
|
||||||
JvmClassName className = closureAnnotator.classNameForClassDescriptorIfDefined(clazz);
|
JvmClassName className = closureAnnotator.classNameForClassDescriptor(clazz);
|
||||||
if (className != null) {
|
return className.getInternalName();
|
||||||
return className.getInternalName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container != null) {
|
String baseName = getFQName(container);
|
||||||
String baseName = getFQName(container);
|
if (!baseName.isEmpty()) {
|
||||||
if (!baseName.isEmpty()) {
|
return baseName + (container instanceof NamespaceDescriptor ? "/" : "$") + name.getIdentifier();
|
||||||
return baseName + (container instanceof NamespaceDescriptor ? "/" : "$") + name.getIdentifier();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name.getIdentifier();
|
return name.getIdentifier();
|
||||||
|
|||||||
Reference in New Issue
Block a user