Fixed KT-2418 Front-end allows enum constants with same name
This commit is contained in:
@@ -164,6 +164,14 @@ public class OverloadResolver {
|
|||||||
) {
|
) {
|
||||||
MultiMap<Name, CallableMemberDescriptor> functionsByName = MultiMap.create();
|
MultiMap<Name, CallableMemberDescriptor> functionsByName = MultiMap.create();
|
||||||
|
|
||||||
|
if (classDescriptor.getKind() == ClassKind.ENUM_CLASS) {
|
||||||
|
MutableClassDescriptor classObjectDescriptor = (MutableClassDescriptor) classDescriptor.getClassObjectDescriptor();
|
||||||
|
assert classObjectDescriptor != null;
|
||||||
|
for (CallableMemberDescriptor memberDescriptor : classObjectDescriptor.getDeclaredCallableMembers()) {
|
||||||
|
functionsByName.putValue(memberDescriptor.getName(), memberDescriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (CallableMemberDescriptor function : classDescriptor.getDeclaredCallableMembers()) {
|
for (CallableMemberDescriptor function : classDescriptor.getDeclaredCallableMembers()) {
|
||||||
functionsByName.putValue(function.getName(), function);
|
functionsByName.putValue(function.getName(), function);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//KT-2418 Front-end allows enum constants with same name
|
||||||
|
|
||||||
|
package kt2418
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
<!REDECLARATION!>FOO<!>
|
||||||
|
<!REDECLARATION!>FOO<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class B {
|
||||||
|
FOO
|
||||||
|
|
||||||
|
fun FOO() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class C {
|
||||||
|
<!REDECLARATION!>FOO<!>
|
||||||
|
|
||||||
|
val <!REDECLARATION!>FOO<!> = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class D {
|
||||||
|
<!REDECLARATION!>FOO<!>
|
||||||
|
|
||||||
|
class <!REDECLARATION!>FOO<!> {}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2245,6 +2245,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
|||||||
doTest("compiler/testData/diagnostics/tests/redeclarations/kt2247.kt");
|
doTest("compiler/testData/diagnostics/tests/redeclarations/kt2247.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt2418.kt")
|
||||||
|
public void testKt2418() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/redeclarations/kt2418.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt2438.kt")
|
@TestMetadata("kt2438.kt")
|
||||||
public void testKt2438() throws Exception {
|
public void testKt2438() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/redeclarations/kt2438.kt");
|
doTest("compiler/testData/diagnostics/tests/redeclarations/kt2438.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user