| Index: editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
|
| diff --git a/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java b/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
|
| index 929785dc1cb460671aa50378dcd09d779bd331e7..bb4dae7d837beab1ec9c1abe2a6e53d966af735f 100644
|
| --- a/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
|
| +++ b/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
|
| @@ -1187,7 +1187,11 @@ public class SemanticTest extends AbstractSemanticTest {
|
| "package test;",
|
| "public class Test {",
|
| " static int foo() {return 42;}",
|
| - " static void bar() {",
|
| + " static void barA() {",
|
| + " int foo = foo();",
|
| + " baz(foo);",
|
| + " }",
|
| + " static void barB() {",
|
| " int foo = foo();",
|
| " baz(foo);",
|
| " }",
|
| @@ -1202,7 +1206,11 @@ public class SemanticTest extends AbstractSemanticTest {
|
| toString(
|
| "class Test {",
|
| " static int foo() => 42;",
|
| - " static void bar() {",
|
| + " static void barA() {",
|
| + " int foo2 = foo();",
|
| + " baz(foo2);",
|
| + " }",
|
| + " static void barB() {",
|
| " int foo2 = foo();",
|
| " baz(foo2);",
|
| " }",
|
| @@ -1212,6 +1220,94 @@ public class SemanticTest extends AbstractSemanticTest {
|
| getFormattedSource(unit));
|
| }
|
|
|
| + public void test_giveUniqueName_variableInitializer_localNames() throws Exception {
|
| + File file = setFileLines(
|
| + "test/Test.java",
|
| + toString(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "package test;",
|
| + "public class Test {",
|
| + " static int foo() {return 42;}",
|
| + " static void barA() {",
|
| + " int foo2 = 2;",
|
| + " int foo = foo();",
|
| + " baz(foo);",
|
| + " int foo3 = 3;",
|
| + " }",
|
| + "}",
|
| + ""));
|
| + Context context = new Context();
|
| + context.addSourceFolder(tmpFolder);
|
| + context.addSourceFile(file);
|
| + CompilationUnit unit = context.translate();
|
| + assertEquals(
|
| + toString(
|
| + "class Test {",
|
| + " static int foo() => 42;",
|
| + " static void barA() {",
|
| + " int foo2 = 2;",
|
| + " int foo4 = foo();",
|
| + " baz(foo4);",
|
| + " int foo3 = 3;",
|
| + " }",
|
| + "}"),
|
| + getFormattedSource(unit));
|
| + }
|
| +
|
| + public void test_giveUniqueName_variableInitializer_onlyHierarchyNames() throws Exception {
|
| + setFileLines(
|
| + "test/A.java",
|
| + toString(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "package test;",
|
| + "public class A {",
|
| + " static int foo3;",
|
| + "}",
|
| + ""));
|
| + setFileLines(
|
| + "test/B.java",
|
| + toString(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "package test;",
|
| + "public class B {",
|
| + " static int foo2;",
|
| + "}",
|
| + ""));
|
| + setFileLines(
|
| + "test/Test.java",
|
| + toString(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "package test;",
|
| + "public class Test extends B {",
|
| + " static int foo() {return 42;}",
|
| + " static void bar() {",
|
| + " int foo = foo();",
|
| + " baz(foo);",
|
| + " }",
|
| + "}",
|
| + ""));
|
| + Context context = new Context();
|
| + context.addSourceFolder(tmpFolder);
|
| + context.addSourceFiles(tmpFolder);
|
| + CompilationUnit unit = context.translate();
|
| + assertEquals(
|
| + toString(
|
| + "class A {",
|
| + " static int foo3 = 0;",
|
| + "}",
|
| + "class B {",
|
| + " static int foo2 = 0;",
|
| + "}",
|
| + "class Test extends B {",
|
| + " static int foo() => 42;",
|
| + " static void bar() {",
|
| + " int foo3 = foo();",
|
| + " baz(foo3);",
|
| + " }",
|
| + "}"),
|
| + getFormattedSource(unit));
|
| + }
|
| +
|
| public void test_giveUniqueName_withStatic() throws Exception {
|
| setFileLines(
|
| "test/Super.java",
|
|
|