KT-11100 Fix generation of name of FakeCallableDescriptorForObject that is presumably used to express invoke operator on (companion) objects
This commit is contained in:
@@ -59,4 +59,8 @@ public final class ClassObjectTest extends SingleFileTranslationTest {
|
|||||||
public void testObjectInCompanionObject() throws Exception {
|
public void testObjectInCompanionObject() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInvokeOperatorInCompanionObject() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.name.FqName;
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -383,6 +384,19 @@ public final class StaticContext {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Rule<JsName> fakeCallableDescriptor = new Rule<JsName>() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public JsName apply(@NotNull DeclarationDescriptor descriptor) {
|
||||||
|
if (!(descriptor instanceof FakeCallableDescriptorForObject)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
FakeCallableDescriptorForObject fakeCallableDescriptor = (FakeCallableDescriptorForObject) descriptor;
|
||||||
|
return getNameForDescriptor(fakeCallableDescriptor.getReferencedDescriptor());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
addRule(namesForDynamic);
|
addRule(namesForDynamic);
|
||||||
addRule(localClasses);
|
addRule(localClasses);
|
||||||
addRule(namesForStandardClasses);
|
addRule(namesForStandardClasses);
|
||||||
@@ -390,6 +404,7 @@ public final class StaticContext {
|
|||||||
addRule(propertyOrPropertyAccessor);
|
addRule(propertyOrPropertyAccessor);
|
||||||
addRule(predefinedObjectsHasUnobfuscatableNames);
|
addRule(predefinedObjectsHasUnobfuscatableNames);
|
||||||
addRule(overridingDescriptorsReferToOriginalName);
|
addRule(overridingDescriptorsReferToOriginalName);
|
||||||
|
addRule(fakeCallableDescriptor);
|
||||||
addRule(memberDeclarationsInsideParentsScope);
|
addRule(memberDeclarationsInsideParentsScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// See KT-11100
|
||||||
|
package foo
|
||||||
|
|
||||||
|
class Div {
|
||||||
|
var className: String? = null
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
operator fun invoke(init: Div.() -> Unit): Div {
|
||||||
|
val div = Div()
|
||||||
|
div.init()
|
||||||
|
return div
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val x = Div {
|
||||||
|
className = "ui container"
|
||||||
|
}
|
||||||
|
assertEquals("ui container", x.className)
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user