Fix bogus smartcast on enum entry members

Previously, enum entries were treated by the data-flow subsystem similar
to other class/singletons. As a consequence, calls like
'Enum.ENTRY.property' had IdentifierInfo of 'property'.

However, specially for enum entries, descriptor of 'property' is one and
the same for all entries. It means that from the data-flow point of
view, 'Enum.ONE.property' and 'Enum.TWO.property' are *one and the same
data-flow values*.

It could obviously lead to some bogus smartcasts, so this commit
introduces separate IdentifierInfo.EnumEntry and uses it to build proper
qualified values.

^KT-20772 Fixed
This commit is contained in:
Dmitry Savvinov
2018-05-04 16:13:51 +03:00
committed by Dmitry Savvinov
parent ce6543b1cb
commit 952f67dafc
6 changed files with 72 additions and 1 deletions
@@ -18849,6 +18849,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/smartCasts/elvisRHS.kt");
}
@TestMetadata("enumEntryMembers_after.kt")
public void testEnumEntryMembers_after() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/enumEntryMembers_after.kt");
}
@TestMetadata("enumEntryMembers_before.kt")
public void testEnumEntryMembers_before() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/enumEntryMembers_before.kt");
}
@TestMetadata("equals.kt")
public void testEquals() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/equals.kt");
@@ -18849,6 +18849,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/smartCasts/elvisRHS.kt");
}
@TestMetadata("enumEntryMembers_after.kt")
public void testEnumEntryMembers_after() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/enumEntryMembers_after.kt");
}
@TestMetadata("enumEntryMembers_before.kt")
public void testEnumEntryMembers_before() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/enumEntryMembers_before.kt");
}
@TestMetadata("equals.kt")
public void testEquals() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/equals.kt");