From c7bb6a08d4ff09d47f3289501e71973047a45d83 Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 28 Oct 2011 13:41:07 +0400 Subject: [PATCH] Existing tests for 'val reassignment' of function parameters fixed --- compiler/testData/checker/NamespaceQualified.jet | 2 +- .../checker/regression/ScopeForSecondaryConstructors.jet | 4 ++-- .../checkerWithErrorTypes/full/FlowAnalyseVariables.jet | 7 +++++++ .../checkerWithErrorTypes/full/NamespaceQualified.jet | 2 +- .../full/regression/ScopeForSecondaryConstructors.jet | 4 ++-- compiler/testData/codegen/functions/nothisnoclosure.jet | 2 +- compiler/testData/codegen/objects/objectLiteral.jet | 2 +- .../org/jetbrains/jet/codegen/PrimitiveTypesTest.java | 8 ++++---- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/compiler/testData/checker/NamespaceQualified.jet b/compiler/testData/checker/NamespaceQualified.jet index 120b3b73d34..7b63689a4f8 100644 --- a/compiler/testData/checker/NamespaceQualified.jet +++ b/compiler/testData/checker/NamespaceQualified.jet @@ -52,7 +52,7 @@ abstract class Sum() : Iteratee { } abstract class Collection : Iterable { - fun iterate(iteratee : Iteratee) : O { + fun iterate(var iteratee : Iteratee) : O { for (x in this) { val it = iteratee.process(x) if (it.isDone) return it.result diff --git a/compiler/testData/checker/regression/ScopeForSecondaryConstructors.jet b/compiler/testData/checker/regression/ScopeForSecondaryConstructors.jet index 2cac1044074..80b5a321d89 100644 --- a/compiler/testData/checker/regression/ScopeForSecondaryConstructors.jet +++ b/compiler/testData/checker/regression/ScopeForSecondaryConstructors.jet @@ -1,4 +1,4 @@ - class Foo(var bar : Int, barr : Int, val barrr : Int) { + class Foo(var bar : Int, var barr : Int, var barrr : Int) { { bar = 1 barr = 1 @@ -7,7 +7,7 @@ this : Foo } - this(val bar : Int) : this(1, 1, 1) { + this(var bar : Int) : this(1, 1, 1) { bar = 1 this.bar 1 : Int diff --git a/compiler/testData/checkerWithErrorTypes/full/FlowAnalyseVariables.jet b/compiler/testData/checkerWithErrorTypes/full/FlowAnalyseVariables.jet index 81a49d26b02..0a92f3741a7 100644 --- a/compiler/testData/checkerWithErrorTypes/full/FlowAnalyseVariables.jet +++ b/compiler/testData/checkerWithErrorTypes/full/FlowAnalyseVariables.jet @@ -48,6 +48,13 @@ fun t2() { fun doSmth(s: String) {} fun doSmth(i: Int) {} +class A() {} + +fun t4(a: A, val b: A, var c: A) { + a = A() + b = A() + c = A() +} } namespace reassigned_vals { diff --git a/compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet b/compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet index a298efcacfe..213e2867d94 100644 --- a/compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet +++ b/compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet @@ -52,7 +52,7 @@ abstract class Sum() : Iteratee { } abstract class Collection : Iterable { - fun iterate(iteratee : Iteratee) : O { + fun iterate(var iteratee : Iteratee) : O { for (x in this) { val it = iteratee.process(x) if (it.isDone) return it.result diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet b/compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet index 2cac1044074..80b5a321d89 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet +++ b/compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet @@ -1,4 +1,4 @@ - class Foo(var bar : Int, barr : Int, val barrr : Int) { + class Foo(var bar : Int, var barr : Int, var barrr : Int) { { bar = 1 barr = 1 @@ -7,7 +7,7 @@ this : Foo } - this(val bar : Int) : this(1, 1, 1) { + this(var bar : Int) : this(1, 1, 1) { bar = 1 this.bar 1 : Int diff --git a/compiler/testData/codegen/functions/nothisnoclosure.jet b/compiler/testData/codegen/functions/nothisnoclosure.jet index cb161d00ce0..a53afefb72e 100644 --- a/compiler/testData/codegen/functions/nothisnoclosure.jet +++ b/compiler/testData/codegen/functions/nothisnoclosure.jet @@ -1,4 +1,4 @@ -fun loop(times : Int) { +fun loop(var times : Int) { while(times > 0) { val u : fun(value : Int) : Unit = { System.out?.println(it) diff --git a/compiler/testData/codegen/objects/objectLiteral.jet b/compiler/testData/codegen/objects/objectLiteral.jet index a457840fefc..ca3f96cf336 100644 --- a/compiler/testData/codegen/objects/objectLiteral.jet +++ b/compiler/testData/codegen/objects/objectLiteral.jet @@ -1,5 +1,5 @@ class C(x: Int, val y : Int) { - fun initChild(x: Int) : java.lang.Object { + fun initChild(var x: Int) : java.lang.Object { return object : java.lang.Object() { override fun toString(): String? { x = x + y diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index 389d6be3b04..c2365b7b71d 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -169,25 +169,25 @@ public class PrimitiveTypesTest extends CodegenTestCase { } public void testPreDecrement() throws Exception { - loadText("fun foo(a: Int): Int { return --a;}"); + loadText("fun foo(var a: Int): Int { return --a;}"); final Method main = generateFunction(); assertEquals(9, main.invoke(null, 10)); } public void testPreIncrementLong() throws Exception { - loadText("fun foo(a: Long): Long = ++a"); + loadText("fun foo(var a: Long): Long = ++a"); final Method main = generateFunction(); assertEquals(11L, main.invoke(null, 10L)); } public void testPreIncrementFloat() throws Exception { - loadText("fun foo(a: Float): Float = ++a"); + loadText("fun foo(var a: Float): Float = ++a"); final Method main = generateFunction(); assertEquals(2.0f, main.invoke(null, 1.0f)); } public void testPreIncrementDouble() throws Exception { - loadText("fun foo(a: Double): Double = ++a"); + loadText("fun foo(var a: Double): Double = ++a"); final Method main = generateFunction(); assertEquals(2.0, main.invoke(null, 1.0)); }