From 8ec8fa47a47b84648cdaa4e2c7c48639f41caee1 Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 20 Jan 2012 14:52:48 +0400 Subject: [PATCH 1/5] KT-1078 Problem with visibility in do-while --- .../ControlStructureTypingVisitor.java | 14 ++++++++++++-- .../testData/diagnostics/tests/scopes/kt1078.jet | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/scopes/kt1078.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java index 8f9424acf64..2343a383dba 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java @@ -20,7 +20,10 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver; import org.jetbrains.jet.lang.types.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import static org.jetbrains.jet.lang.diagnostics.Errors.*; import static org.jetbrains.jet.lang.resolve.BindingContext.*; @@ -182,7 +185,14 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { else if (body != null) { WritableScope writableScope = newWritableScopeImpl(context).setDebugName("do..while body scope"); conditionScope = writableScope; - context.getServices().getBlockReturnedTypeWithWritableScope(writableScope, Collections.singletonList(body), CoercionStrategy.NO_COERCION, context); + List block; + if (body instanceof JetBlockExpression) { + block = ((JetBlockExpression)body).getStatements(); + } + else { + block = Collections.singletonList(body); + } + context.getServices().getBlockReturnedTypeWithWritableScope(writableScope, block, CoercionStrategy.NO_COERCION, context); } JetExpression condition = expression.getCondition(); checkCondition(conditionScope, condition, context); diff --git a/compiler/testData/diagnostics/tests/scopes/kt1078.jet b/compiler/testData/diagnostics/tests/scopes/kt1078.jet new file mode 100644 index 00000000000..2667028763e --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/kt1078.jet @@ -0,0 +1,16 @@ +//KT-1078 Problem with visibility in do-while + +package kt1078 + +fun test() : B { + do { + val x = foo() + } while(x.bar()) // x is not visible here! + return B() +} + +class B() { + fun bar() = true +} + +fun foo() = B() \ No newline at end of file From f541cce098aa16cb49bc410604fa1ddf654d8ae0 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 20 Jan 2012 19:17:32 +0400 Subject: [PATCH 2/5] Get full/core versions of IDEA using update_dependencies.xml. Don't use plugin SDK anymore. --- .gitignore | 1 + .idea/ant.xml | 8 ++++++ .idea/libraries/idea_full.xml | 10 +++++++ .idea/libraries/intellij_core.xml | 10 +++++++ .idea/runConfigurations/IDEA.xml | 18 +++++++++++++ compiler/backend/backend.iml | 3 ++- compiler/cli/cli.iml | 3 ++- compiler/frontend.java/frontend.java.iml | 3 ++- compiler/frontend/frontend.iml | 3 ++- compiler/tests/compiler-tests.iml | 3 ++- grammar/grammar.iml | 3 ++- idea/idea.iml | 5 ++-- update_dependencies.xml | 34 ++++++++++++++++++++++++ 13 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 .idea/libraries/idea_full.xml create mode 100644 .idea/libraries/intellij_core.xml create mode 100644 .idea/runConfigurations/IDEA.xml create mode 100644 update_dependencies.xml diff --git a/.gitignore b/.gitignore index 31cd6f6cd36..4e23564ea5c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ examples/.idea/workspace.xml confluence/target confluence/target out +ideaSDK .idea/dictionaries/yozh.xml .idea/codeStyleSettings.xml .idea/workspace.xml diff --git a/.idea/ant.xml b/.idea/ant.xml index 37ffae42808..f128e62d687 100644 --- a/.idea/ant.xml +++ b/.idea/ant.xml @@ -34,6 +34,14 @@ + + + + + + + + diff --git a/.idea/libraries/idea_full.xml b/.idea/libraries/idea_full.xml new file mode 100644 index 00000000000..30b7644b98f --- /dev/null +++ b/.idea/libraries/idea_full.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/intellij_core.xml b/.idea/libraries/intellij_core.xml new file mode 100644 index 00000000000..d14331541a7 --- /dev/null +++ b/.idea/libraries/intellij_core.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/IDEA.xml b/.idea/runConfigurations/IDEA.xml new file mode 100644 index 00000000000..137959a7b23 --- /dev/null +++ b/.idea/runConfigurations/IDEA.xml @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/compiler/backend/backend.iml b/compiler/backend/backend.iml index c2cb311107b..89c20773203 100644 --- a/compiler/backend/backend.iml +++ b/compiler/backend/backend.iml @@ -5,12 +5,13 @@ - + + diff --git a/compiler/cli/cli.iml b/compiler/cli/cli.iml index 0b81faef09d..87b178e8745 100644 --- a/compiler/cli/cli.iml +++ b/compiler/cli/cli.iml @@ -5,13 +5,14 @@ - + + diff --git a/compiler/frontend.java/frontend.java.iml b/compiler/frontend.java/frontend.java.iml index 51021970c69..94b95ad5bde 100644 --- a/compiler/frontend.java/frontend.java.iml +++ b/compiler/frontend.java/frontend.java.iml @@ -5,10 +5,11 @@ - + + diff --git a/compiler/frontend/frontend.iml b/compiler/frontend/frontend.iml index 538b9791539..d0a04b011b4 100644 --- a/compiler/frontend/frontend.iml +++ b/compiler/frontend/frontend.iml @@ -5,8 +5,9 @@ - + + diff --git a/compiler/tests/compiler-tests.iml b/compiler/tests/compiler-tests.iml index 05bb0565855..e3a58fc3f6e 100644 --- a/compiler/tests/compiler-tests.iml +++ b/compiler/tests/compiler-tests.iml @@ -5,13 +5,14 @@ - + + diff --git a/grammar/grammar.iml b/grammar/grammar.iml index 538b9791539..c03fc491744 100644 --- a/grammar/grammar.iml +++ b/grammar/grammar.iml @@ -5,8 +5,9 @@ - + + diff --git a/idea/idea.iml b/idea/idea.iml index 39519927146..3b2a3f833e0 100644 --- a/idea/idea.iml +++ b/idea/idea.iml @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@ - + @@ -23,6 +23,7 @@ + diff --git a/update_dependencies.xml b/update_dependencies.xml new file mode 100644 index 00000000000..6fe47687e80 --- /dev/null +++ b/update_dependencies.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b3eb44e769029e8701c0398649530fea01092a36 Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 20 Jan 2012 19:31:04 +0400 Subject: [PATCH 3/5] removed some string methods from library.jet --- compiler/frontend/src/jet/Library.jet | 10 ------- .../tests/QualifiedExpressions.jet | 4 ++- .../jetbrains/jet/codegen/ClassGenTest.java | 6 ----- .../jet/codegen/ExtensionFunctionsTest.java | 4 --- .../jet/codegen/NamespaceGenTest.java | 13 --------- .../org/jetbrains/jet/codegen/StdlibTest.java | 27 +++++++++++++++++++ .../testData/checker/QualifiedExpressions.jet | 4 ++- stdlib/ktSrc/String.kt | 6 +++++ 8 files changed, 39 insertions(+), 35 deletions(-) diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index 91afe33923d..127344a5d25 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -50,16 +50,6 @@ class String() : Comparable { fun plus(other : Any?) : String fun equals(other : Any?) : Boolean - fun equalsIgnoreCase(other: String?) : Boolean - - fun substring(start: Int): String - fun substring(start: Int, end: Int): String - - fun startsWith(prefix: String, toffset: Int): Boolean - fun startsWith(prefix: String): Boolean - fun endsWith(suffix: String): Boolean - - fun trim(): String } diff --git a/compiler/testData/diagnostics/tests/QualifiedExpressions.jet b/compiler/testData/diagnostics/tests/QualifiedExpressions.jet index 135fbc2e89a..3ce867b2def 100644 --- a/compiler/testData/diagnostics/tests/QualifiedExpressions.jet +++ b/compiler/testData/diagnostics/tests/QualifiedExpressions.jet @@ -8,4 +8,6 @@ fun test(s: String?) { val e: String = s?.length ?: "empty" val f: Int = s?.length ?: b ?: 1 val g: Int? = e? startsWith("s")?.length -} \ No newline at end of file +} + +fun String.startsWith(s: String): Boolean = true \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index e2a33a757cd..833e3d9766c 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -191,12 +191,6 @@ public class ClassGenTest extends CodegenTestCase { // System.out.println(generateToText()); } - public void testKt344 () throws Exception { - loadFile("regressions/kt344.jet"); -// System.out.println(generateToText()); - blackBox(); - } - public void testKt508 () throws Exception { loadFile("regressions/kt508.jet"); // System.out.println(generateToText()); diff --git a/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java b/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java index c03aebc041c..9468b0c810b 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ExtensionFunctionsTest.java @@ -26,10 +26,6 @@ public class ExtensionFunctionsTest extends CodegenTestCase { assertThrows(foo, Exception.class, null, new StringBuilder()); } - public void testGeneric() throws Exception { - blackBoxFile("extensionFunctions/generic.jet"); - } - public void testVirtual() throws Exception { blackBoxFile("extensionFunctions/virtual.jet"); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index fc4f3fa3249..31e176f1819 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -503,19 +503,6 @@ public class NamespaceGenTest extends CodegenTestCase { assertEquals("aaa", tuple4._3); } - public void testPredicateOperator() throws Exception { - loadText("fun foo(s: String) = s?startsWith(\"J\")"); - final Method main = generateFunction(); - try { - assertEquals("JetBrains", main.invoke(null, "JetBrains")); - assertNull(main.invoke(null, "IntelliJ")); - } - catch (Throwable t) { -// System.out.println(generateToText()); - t.printStackTrace(); - } - } - public void testEscapeSequence() throws Exception { loadText("fun foo() = \"a\\nb\\$\""); final Method main = generateFunction(); diff --git a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java index c9cad2d4bc3..fc2b4786668 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java @@ -4,6 +4,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.compiler.CompileEnvironment; import org.jetbrains.jet.compiler.CompileSession; +import java.lang.reflect.Method; + /** * @author alex.tkachman */ @@ -83,4 +85,29 @@ public class StdlibTest extends CodegenTestCase { public void testKt274 () { // blackBoxFile("regressions/kt274.kt"); } + + //from ClassGenTest + public void testKt344 () throws Exception { + loadFile("regressions/kt344.jet"); +// System.out.println(generateToText()); + blackBox(); + } + + //from ExtensionFunctionsTest + public void testGeneric() throws Exception { + blackBoxFile("extensionFunctions/generic.jet"); + } + + //from NamespaceGenTest + public void testPredicateOperator() throws Exception { + loadText("fun foo(s: String) = s?startsWith(\"J\")"); + final Method main = generateFunction(); + try { + assertEquals("JetBrains", main.invoke(null, "JetBrains")); + assertNull(main.invoke(null, "IntelliJ")); + } catch (Throwable t) { +// System.out.println(generateToText()); + t.printStackTrace(); + } + } } diff --git a/idea/testData/checker/QualifiedExpressions.jet b/idea/testData/checker/QualifiedExpressions.jet index 73a2c4c677e..0527d08943d 100644 --- a/idea/testData/checker/QualifiedExpressions.jet +++ b/idea/testData/checker/QualifiedExpressions.jet @@ -8,4 +8,6 @@ fun test(s: String?) { val e: String = s?.length ?: "empty" val f: Int = s?.length ?: b ?: 1 val g: Int? = e? startsWith("s")?.length -} \ No newline at end of file +} + +fun String.startsWith(s: String): Boolean = true \ No newline at end of file diff --git a/stdlib/ktSrc/String.kt b/stdlib/ktSrc/String.kt index fe5912fa03e..0dd9653012b 100644 --- a/stdlib/ktSrc/String.kt +++ b/stdlib/ktSrc/String.kt @@ -8,6 +8,8 @@ inline fun String.lastIndexOf(s: String) = (this as java.lang.String).lastIndex inline fun String.lastIndexOf(s: Char) = (this as java.lang.String).lastIndexOf(s.toString()) +inline fun String.equalsIgnoreCase(s: String) = (this as java.lang.String).equalsIgnoreCase(s) + inline fun String.indexOf(s : String) = (this as java.lang.String).indexOf(s) inline fun String.indexOf(p0 : String, p1 : Int) = (this as java.lang.String).indexOf(p0, p1) @@ -34,6 +36,10 @@ inline fun String.substring(i : Int) = (this as java.lang.String).substring(i).s inline fun String.substring(i0 : Int, i1 : Int) = (this as java.lang.String).substring(i0, i1).sure() +inline fun String.startsWith(prefix: String) = (this as java.lang.String).startsWith(prefix) + +inline fun String.startsWith(prefix: String, toffset: Int) = (this as java.lang.String).startsWith(prefix, toffset) + inline val String.size : Int get() = length() From 496ced4f1a9f1bc8edbfbab7518d7c7ee8a2fe8e Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 20 Jan 2012 19:32:02 +0400 Subject: [PATCH 4/5] test for default std.io.* --- compiler/testData/codegen/regressions/kt528.kt | 1 - compiler/testData/codegen/regressions/kt529.kt | 1 - compiler/testData/codegen/regressions/kt533.kt | 1 - compiler/testData/codegen/regressions/kt864.jet | 1 - compiler/testData/compiler/smoke/Smoke.kt | 2 -- 5 files changed, 6 deletions(-) diff --git a/compiler/testData/codegen/regressions/kt528.kt b/compiler/testData/codegen/regressions/kt528.kt index d656fb2f6f7..39dcc7a0892 100644 --- a/compiler/testData/codegen/regressions/kt528.kt +++ b/compiler/testData/codegen/regressions/kt528.kt @@ -1,6 +1,5 @@ package mask -import std.io.* import java.io.* import java.util.* import java.util.Iterator as It diff --git a/compiler/testData/codegen/regressions/kt529.kt b/compiler/testData/codegen/regressions/kt529.kt index 546a345b1c7..55ba07dfc5e 100644 --- a/compiler/testData/codegen/regressions/kt529.kt +++ b/compiler/testData/codegen/regressions/kt529.kt @@ -1,6 +1,5 @@ package mask -import std.io.* import java.io.* import java.util.* diff --git a/compiler/testData/codegen/regressions/kt533.kt b/compiler/testData/codegen/regressions/kt533.kt index 3ad813a6e0b..d6e28177601 100644 --- a/compiler/testData/codegen/regressions/kt533.kt +++ b/compiler/testData/codegen/regressions/kt533.kt @@ -1,6 +1,5 @@ package mask -import std.io.* import java.io.* import java.util.* diff --git a/compiler/testData/codegen/regressions/kt864.jet b/compiler/testData/codegen/regressions/kt864.jet index 40bdba3dade..6771b2eb2cf 100644 --- a/compiler/testData/codegen/regressions/kt864.jet +++ b/compiler/testData/codegen/regressions/kt864.jet @@ -1,4 +1,3 @@ -import std.io.* import std.util.* import java.io.* import java.util.* diff --git a/compiler/testData/compiler/smoke/Smoke.kt b/compiler/testData/compiler/smoke/Smoke.kt index c5ece2faf60..840ee72ff76 100644 --- a/compiler/testData/compiler/smoke/Smoke.kt +++ b/compiler/testData/compiler/smoke/Smoke.kt @@ -1,7 +1,5 @@ package Smoke -import std.io.* - fun main(args: Array) { print(args) } From 53f7c9d0072037af06014bc2007011e39d120c2d Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 20 Jan 2012 20:35:41 +0400 Subject: [PATCH 5/5] Avoid dropping config/system on each IDEA binaries update --- .idea/runConfigurations/IDEA.xml | 6 ++++++ Jet.iml | 5 ++++- update_dependencies.xml | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.idea/runConfigurations/IDEA.xml b/.idea/runConfigurations/IDEA.xml index 137959a7b23..9b094ed38cc 100644 --- a/.idea/runConfigurations/IDEA.xml +++ b/.idea/runConfigurations/IDEA.xml @@ -11,7 +11,13 @@