fix KT-2167 (enum generation)
#KT-2167 fixed
This commit is contained in:
@@ -311,6 +311,21 @@ public class JetTypeMapper {
|
|||||||
throw new IllegalStateException("missed something");
|
throw new IllegalStateException("missed something");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (descriptor instanceof ClassDescriptor) {
|
||||||
|
ClassDescriptor klass = (ClassDescriptor) descriptor;
|
||||||
|
if (klass.getKind() == ClassKind.OBJECT) {
|
||||||
|
if (klass.getContainingDeclaration() instanceof ClassDescriptor) {
|
||||||
|
ClassDescriptor containingKlass = (ClassDescriptor) klass.getContainingDeclaration();
|
||||||
|
if (containingKlass.getKind() == ClassKind.ENUM_CLASS) {
|
||||||
|
return getFQName(containingKlass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (klass.getKind() == ClassKind.ENUM_ENTRY) {
|
||||||
|
return getFQName(klass.getContainingDeclaration());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||||
Name name = descriptor.getName();
|
Name name = descriptor.getName();
|
||||||
if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) {
|
if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// http://youtrack.jetbrains.com/issue/KT-2167
|
||||||
|
|
||||||
|
enum class Season {
|
||||||
|
WINTER
|
||||||
|
SPRING
|
||||||
|
SUMMER
|
||||||
|
AUTUMN
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() = Season.SPRING
|
||||||
|
|
||||||
|
fun box() =
|
||||||
|
if (foo() == Season.SPRING) "OK"
|
||||||
|
else "fail"
|
||||||
@@ -34,4 +34,9 @@ public class EnumGenTest extends CodegenTestCase {
|
|||||||
blackBoxFile("enum/simple.kt");
|
blackBoxFile("enum/simple.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testAsReturnExpression() {
|
||||||
|
blackBoxFile("enum/asReturnExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user