Added test for KT-3367

This commit is contained in:
Valentin Kipyatkov
2014-07-11 13:01:30 +04:00
parent dac1edc35f
commit 4ec746a2e1
4 changed files with 30 additions and 0 deletions
@@ -316,6 +316,7 @@ open class ExpressionVisitor(private val converter: Converter) : JavaElementVisi
}
}
// add qualification for static members from base classes and also this works for enum constants in switch
if (target is PsiMember
&& target.hasModifierProperty(PsiModifier.STATIC)
&& target.getContainingClass() != null
@@ -2701,6 +2701,11 @@ public class JavaToKotlinConverterTestGenerated extends AbstractJavaToKotlinConv
doTest("j2k/tests/testData/ast/switch/emptySwitch.java");
}
@TestMetadata("enumConstants.java")
public void testEnumConstants() throws Exception {
doTest("j2k/tests/testData/ast/switch/enumConstants.java");
}
@TestMetadata("fallDown.java")
public void testFallDown() throws Exception {
doTest("j2k/tests/testData/ast/switch/fallDown.java");
@@ -0,0 +1,12 @@
enum ColorEnum {
GREEN
}
class MyClass {
int method(ColorEnum colorEnum) {
switch (colorEnum) {
case GREEN: return 1;
default: return 2;
}
}
}
@@ -0,0 +1,12 @@
enum class ColorEnum {
GREEN
}
class MyClass {
fun method(colorEnum: ColorEnum): Int {
when (colorEnum) {
ColorEnum.GREEN -> return 1
else -> return 2
}
}
}