New J2K: do not recalculate types for binary & unary expressions and rewrite assignment expressions conversion

#KT-33679 fixed
This commit is contained in:
Ilya Kirillov
2019-09-05 19:40:15 +03:00
parent c93d810685
commit dca0dc1933
45 changed files with 775 additions and 889 deletions
@@ -0,0 +1,19 @@
class Test {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
a = b += c = d *= e;
//-----
a = b;
//-----
a += b;
//-----
a += b = c;
//-----
a = b += c;
}
}
@@ -0,0 +1,32 @@
internal object Test {
@JvmStatic
fun main(args: Array<String>) {
var a = 0
var b = 0
var c = 0
var d = 0
val e = 0
d *= e
c = d
b += c
a = b
//-----
a = b
//-----
a += b
//-----
b = c
a += b
//-----
b += c
a = b
}
}
@@ -0,0 +1,19 @@
class Test {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
a = b += (c) = ((d *= e));
//-----
a = (((b)));
//-----
a += (b);
//-----
a += b = (c);
//-----
a = ((b) += (c));
}
}
@@ -0,0 +1,30 @@
internal object Test {
@JvmStatic
fun main(args: Array<String>) {
var a = 0
var b = 0
var c = 0
var d = 0
val e = 0
c = e.let { d *= it; d }
b += c
a = b
//-----
a = b
//-----
a += b
//-----
b = c
a += b
//-----
a = c.let { b += it; b }
}
}
@@ -1 +1 @@
5 /*operand '5'*/ shl /*left shift*/ 16 /*operand '16'*/ or (/*or*/ 1 /*operand '1'*/ shr /*right shift*/ 8 /*operand '8'*/) or /*or*/ 0 /*operand '0'*/ /*post comment*/
/*pre*/ 5 /*operand '5'*/ shl /*left shift*/ 16 /*operand '16'*/ or (/*or*/ 1 /*operand '1'*/ shr /*right shift*/ 8 /*operand '8'*/) or /*or*/ 0 /*operand '0'*/ /*post comment*/
@@ -0,0 +1,19 @@
class Test {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
//-----
int f = a = b += c = d *= e;
//-----
int g = a;
//-----
int h = a = b;
//-----
int i = a += b;
//-----
int j = a += b = c;
}
}
@@ -0,0 +1,35 @@
internal object Test {
@JvmStatic
fun main(args: Array<String>) {
var a = 0
var b = 0
var c = 0
var d = 0
val e = 0
//-----
d *= e
c = d
b += c
a = b
val f = a
//-----
val g = a
//-----
a = b
val h = a
//-----
a += b
val i = a
//-----
b = c
a += b
val j = a
}
}
@@ -0,0 +1,14 @@
class Test {
public static void main(String[] args) {
boolean a = true;
boolean b = true;
boolean c = true;
boolean d = true;
boolean e = true;
if (a = b |= (c) = ((d &= e))) ;
while ((((((a = b)))))) ;
do {
} while ((((a) ^= (b))));
}
}
@@ -0,0 +1,14 @@
internal object Test {
@JvmStatic
fun main(args: Array<String>) {
var a = true
var b = true
var c = true
var d = true
val e = true
if (e.let { d = d and it; d }.also { c = it }.let { b = b or it; b }.also { a = it });
while (b.also { a = it });
do {
} while (b.let { a = a xor it; a })
}
}
@@ -0,0 +1,15 @@
class Test {
public static void main(String[] args) {
boolean a = true;
boolean b = true;
boolean c = true;
boolean d = true;
boolean e = true;
if (a = b |= c = d &= e) ;
while (a = b) ;
do {} while (a ^= b);
System.out.println(a &= b = c);
System.out.println(a = b != c);
}
}
@@ -0,0 +1,16 @@
internal object Test {
@JvmStatic
fun main(args: Array<String>) {
var a = true
var b = true
var c = true
var d = true
val e = true
if (e.let { d = d and it; d }.also { c = it }.let { b = b or it; b }.also { a = it });
while (b.also { a = it });
do {
} while (b.let { a = a xor it; a })
println(c.also { b = it }.let { a = a and it; a })
println(b != c.also { a = it })
}
}
@@ -1 +1,3 @@
class Nya /*comment before*/(/*1*//*3*/ /*4*/private val i: Int)
class Nya /*comment before*/
/* comment after*/ // and after again
(/*1*//*3*/ /*4*/private val i: Int)
+1 -1
View File
@@ -2,6 +2,6 @@ import java.util.stream.Collectors
internal class JavaCode {
fun toJSON(collection: Collection<Int>): String {
return "[" + collection.stream().map { obj: Int -> obj.toString() }.collect(Collectors.joining(", ")).toString() + "]"
return "[" + collection.stream().map { obj: Int -> obj.toString() }.collect(Collectors.joining(", ")) + "]"
}
}
@@ -1,6 +1,5 @@
class CharToString {
private val value: String? = null
fun test(): String {
return '"'.toString() + value + '"'
}
@@ -1,17 +0,0 @@
import java.util.Iterator;
public class TestMutableIterator implements Iterator<String> {
@Override
public boolean hasNext() {
return false;
}
@Override
public String next() {
return null;
}
@Override
public void remove() {
}
}
@@ -1,7 +1,7 @@
import java.util.ArrayList
class Test {
internal var list: List<List<Int>> = ArrayList()
internal var list: List<MutableList<Int>> = ArrayList()
fun test() {
list[0].add(1)
}