diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 585220fa7e4..a9c2d67fa2a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,11 +6,9 @@ - - + - - + @@ -49,7 +47,7 @@ - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + localhost @@ -1042,7 +1040,7 @@ - + @@ -1058,7 +1056,7 @@ - + @@ -1096,7 +1094,7 @@ @@ -1143,27 +1141,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -1178,16 +1155,9 @@ - - - - - - - - + @@ -1250,7 +1220,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/translator/src/org/jetbrains/k2js/translate/ExpressionVisitor.java b/translator/src/org/jetbrains/k2js/translate/ExpressionVisitor.java index 4c84e827a89..a72ad7771ea 100644 --- a/translator/src/org/jetbrains/k2js/translate/ExpressionVisitor.java +++ b/translator/src/org/jetbrains/k2js/translate/ExpressionVisitor.java @@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.resolve.constants.NullValue; import org.jetbrains.jet.lexer.JetTokens; import java.util.List; @@ -26,6 +27,9 @@ public final class ExpressionVisitor extends TranslatorVisitor { CompileTimeConstant compileTimeValue = context.bindingContext().get(BindingContext.COMPILE_TIME_VALUE, expression); assert compileTimeValue != null; + if (compileTimeValue instanceof NullValue) { + return context.program().getNullLiteral(); + } Object value = compileTimeValue.getValue(); if (value instanceof Integer) { return context.program().getNumberLiteral((Integer) value); diff --git a/translator/test/org/jetbrains/k2js/test/TraitTest.java b/translator/test/org/jetbrains/k2js/test/TraitTest.java index 7ca25dc8305..c77284576a1 100644 --- a/translator/test/org/jetbrains/k2js/test/TraitTest.java +++ b/translator/test/org/jetbrains/k2js/test/TraitTest.java @@ -33,4 +33,9 @@ public final class TraitTest extends AbstractClassTest { public void classDerivesFromTraitAndClass() throws Exception { testFooBoxIsTrue("classDerivesFromTraitAndClass.kt"); } + + @Test + public void example() throws Exception { + testFooBoxIsTrue("example.kt"); + } } diff --git a/translator/testFiles/trait/cases/example.kt b/translator/testFiles/trait/cases/example.kt new file mode 100644 index 00000000000..d8a1ef20f37 --- /dev/null +++ b/translator/testFiles/trait/cases/example.kt @@ -0,0 +1,13 @@ +namespace foo + +trait AL { + fun get(index: Int) : Any? = null +} + +class SmartArrayList() : AL { +} + +fun box() : Boolean { + val c = SmartArrayList() + return (null == c.get(0)) +} \ No newline at end of file