Codegen should just skip (local) type alias declarations.

This commit is contained in:
Dmitry Petrov
2016-06-09 19:35:31 +03:00
parent c04b16d6cc
commit a4267f069d
3 changed files with 27 additions and 0 deletions
@@ -360,6 +360,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return visitClassOrObject(klass);
}
@Override
public StackValue visitTypeAlias(@NotNull KtTypeAlias typeAlias, StackValue data) {
return StackValue.none();
}
private StackValue visitClassOrObject(KtClassOrObject declaration) {
ClassDescriptor descriptor = bindingContext.get(CLASS, declaration);
assert descriptor != null;
@@ -0,0 +1,16 @@
class Cell<TC>(val x: TC)
object OkHost {
val value = "OK"
}
fun <T> id(x: T): T {
typealias C = Cell<T>
val c: C = C(x)
return c.x
}
fun box(): String {
typealias OK = OkHost
return id(OK.value)
}
@@ -14581,6 +14581,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("localTypeAlias.kt")
public void testLocalTypeAlias() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/localTypeAlias.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/simple.kt");