From 14b4f22484a5e30c95630a092998eac9957bff00 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Fri, 23 Aug 2019 07:49:20 +0300 Subject: [PATCH] Expand compilation scope for IC before backend is run Sometimes IC raises compilation errors when rebuild succeeds. This happens because IC uses serialized decriptors for non-dirty files. Serialized descriptors can be different from source file descriptors. For example, a source file may contain an implicit return type or an implicit visibility for overridden methods, but serialized descriptors always contain explicit return types & methods' visibilities. These problems can be solved by expanding a scope of incremental compilation just after the analysis, but before error reporting & code generation. In other words, we need to compare descriptors before error reporting and code generation. If there are new dirty files, current round of IC must be aborted, next round must be performed with new dirty files. This commit implements IC scope expansion for JS Klib compiler #KT-13677 #KT-28233 Original commit: 2d598d50d7b0a097ea8149c1e8d917efde049c80 --- .../build-with-scope-expansion.log | 22 ++++++++++++++++ .../build-with-scope-expansion.log | 26 +++++++++++++++++++ .../build-with-scope-expansion.log | 10 +++++++ .../pureKotlin/funRedeclaration/dummy.kt | 3 +++ .../build-with-scope-expansion.log | 10 +++++++ .../funVsConstructorOverloadConflict/dummy.kt | 3 +++ .../build-with-scope-expansion.log | 10 +++++++ .../propertyRedeclaration/build.log | 2 +- .../pureKotlin/propertyRedeclaration/dummy.kt | 5 ++++ .../pureKotlin/propertyRedeclaration/prop1.kt | 2 +- .../pureKotlin/propertyRedeclaration/prop2.kt | 4 +-- .../propertyRedeclaration/prop2.kt.new | 7 ++--- 12 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 jps/jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved/build-with-scope-expansion.log create mode 100644 jps/jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded/build-with-scope-expansion.log create mode 100644 jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/build-with-scope-expansion.log create mode 100644 jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/dummy.kt create mode 100644 jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/build-with-scope-expansion.log create mode 100644 jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/dummy.kt create mode 100644 jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build-with-scope-expansion.log create mode 100644 jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/dummy.kt diff --git a/jps/jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved/build-with-scope-expansion.log b/jps/jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved/build-with-scope-expansion.log new file mode 100644 index 00000000000..9997e126b95 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/classHierarchyAffected/enumEntryRemoved/build-with-scope-expansion.log @@ -0,0 +1,22 @@ +================ Step #1 ================= + +Compiling files: + src/Enum.kt + src/getRandomEnumEntry.kt + src/use.kt + src/useEnumImplicitly.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Unresolved reference: C + +================ Step #2 ================= + +Compiling files: + src/Enum.kt + src/getRandomEnumEntry.kt + src/use.kt + src/useEnumImplicitly.kt +End of files +Exit code: OK \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded/build-with-scope-expansion.log b/jps/jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded/build-with-scope-expansion.log new file mode 100644 index 00000000000..26cfbf6c4f3 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/classHierarchyAffected/secondaryConstructorAdded/build-with-scope-expansion.log @@ -0,0 +1,26 @@ +================ Step #1 ================= + +Compiling files: + src/A.kt + src/AChild.kt + src/AConstructorFunction.kt + src/createAFromInt.kt + src/createAFromString.kt + src/useA.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Conflicting overloads: public constructor A(x: String) defined in A, public fun A(x: String): A defined in root package + +================ Step #2 ================= + +Compiling files: + src/A.kt + src/AChild.kt + src/createAFromInt.kt + src/createAFromString.kt + src/useA.kt +End of files +Exit code: OK +------------------------------------------ \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/build-with-scope-expansion.log b/jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/build-with-scope-expansion.log new file mode 100644 index 00000000000..bcf759c201e --- /dev/null +++ b/jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/build-with-scope-expansion.log @@ -0,0 +1,10 @@ +================ Step #1 ================= + +Compiling files: + src/fun1.kt + src/fun2.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Conflicting overloads: public fun function(): Unit defined in test in file fun2.kt, public fun function(): Unit defined in test \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/dummy.kt b/jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/dummy.kt new file mode 100644 index 00000000000..789dc274f72 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/pureKotlin/funRedeclaration/dummy.kt @@ -0,0 +1,3 @@ +package test + +fun dummy() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/build-with-scope-expansion.log b/jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/build-with-scope-expansion.log new file mode 100644 index 00000000000..b7b4c165c73 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/build-with-scope-expansion.log @@ -0,0 +1,10 @@ +================ Step #1 ================= + +Compiling files: + src/fun1.kt + src/fun2.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Conflicting overloads: public constructor function() defined in test.function, public fun function(): Unit defined in test \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/dummy.kt b/jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/dummy.kt new file mode 100644 index 00000000000..789dc274f72 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/pureKotlin/funVsConstructorOverloadConflict/dummy.kt @@ -0,0 +1,3 @@ +package test + +fun dummy() {} \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build-with-scope-expansion.log b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build-with-scope-expansion.log new file mode 100644 index 00000000000..d8e58d77555 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build-with-scope-expansion.log @@ -0,0 +1,10 @@ +================ Step #1 ================= + +Compiling files: + src/prop1.kt + src/prop2.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Conflicting declarations: public val prop1: Int, public val prop1: Int \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build.log b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build.log index 7839df62fd5..144f50805ea 100644 --- a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build.log +++ b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/build.log @@ -10,4 +10,4 @@ End of files Exit code: ABORT ------------------------------------------ COMPILATION FAILED -Conflicting declarations: public val property: Int, public val property: Int \ No newline at end of file +Conflicting declarations: public val prop1: Int, public val prop1: Int \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/dummy.kt b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/dummy.kt new file mode 100644 index 00000000000..c80484f5633 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/dummy.kt @@ -0,0 +1,5 @@ +package test + +fun dummy() { + +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop1.kt b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop1.kt index 14b9ceec2ef..1c855edd0ac 100644 --- a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop1.kt +++ b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop1.kt @@ -1,3 +1,3 @@ package test -val property = 1 \ No newline at end of file +val prop1 = 1 \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt index a46bb3499d4..461b5d22caf 100644 --- a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt +++ b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt @@ -1,5 +1,3 @@ package test -fun dummy() { - -} +val prop2 = 2 diff --git a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt.new b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt.new index 4a10a872d00..2f68bba3b00 100644 --- a/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt.new +++ b/jps/jps-plugin/testData/incremental/pureKotlin/propertyRedeclaration/prop2.kt.new @@ -1,7 +1,4 @@ package test -fun dummy() { - -} - -val property = 1 \ No newline at end of file +val prop1 = 1 +val prop2 = 2 \ No newline at end of file