Allow singletons and functions with the same name

This commit is contained in:
Alexander Udalov
2013-12-02 16:12:03 +04:00
parent dcedbed7e1
commit 080bd42f88
3 changed files with 30 additions and 0 deletions
@@ -91,6 +91,10 @@ public class OverloadResolver {
MultiMap<Key, ConstructorDescriptor> inNamespaces = MultiMap.create();
for (MutableClassDescriptor klass : context.getClasses().values()) {
if (klass.getKind().isSingleton()) {
// Constructors of singletons aren't callable from the code, so they shouldn't participate in overload name checking
continue;
}
DeclarationDescriptor containingDeclaration = klass.getContainingDeclaration();
if (containingDeclaration instanceof NamespaceDescriptor) {
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) containingDeclaration;
@@ -0,0 +1,21 @@
fun Foo() = 42
object Foo {
fun Bar() = 239
object Bar
}
<!CONFLICTING_OVERLOADS!>fun En()<!> = 239
enum class <!CONFLICTING_OVERLOADS!>En<!> {
ENTRY
SUBCLASS { }
fun ENTRY() = 42
fun SUBCLASS() = ENTRY()
}
@@ -5033,6 +5033,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/redeclarations/RedeclaredTypeParameters.kt");
}
@TestMetadata("SingletonAndFunctionSameName.kt")
public void testSingletonAndFunctionSameName() throws Exception {
doTest("compiler/testData/diagnostics/tests/redeclarations/SingletonAndFunctionSameName.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/regressions")