Allow singletons and functions with the same name
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user