Commit Graph

423 Commits

Author SHA1 Message Date
Yahor Berdnikau 0cad069522 [Build] Pin api and language level to 1.8 in Kotlin compiler modules used by KGP
This is required to be able to compile KGP and it's dependencies which
set LV to 1.4 when repo will use LV 1.9. This caused by the change how
enums are compiled (KT-48872).
2023-02-18 13:26:54 +00:00
Dmitriy Novozhilov 79e4df72bf [CLI] Introduce utilities for creating FirSession hierarchy in CLI for all platforms
Also support session creation and compilation for HMPP projects

^KT-56209 Fixed
2023-02-17 11:08:51 +00:00
Dmitriy Novozhilov d4bb740a62 [CLI] Store information about HMPP module for source files 2023-02-17 11:08:50 +00:00
Aleksei.Cherepanov f640a7be2e Add the possibility to mute Gradle IC tests by folder
If you need to mute a test for Gradle IC, the only way is to add exclude pattern and regenerate tests aka remove unnecessary tests. But the filter is absolute, so if you have the same test name in different subfolders (e.g. `pureKotlin/classRemoved/` and `classHierarchyAffected/classRemoved`) you cannot disable only one of them. This commit adds logic to specify which name pattern in which subfolder should be excluded
2023-02-15 18:33:27 +00:00
Svyatoslav Scherbina cf4934f539 [FIR2IR] Make convertToIrAndActualize() more reusable across backends 2023-02-07 14:16:30 +00:00
Ivan Kochurkin 0f9107c153 [FIR2IR] Remove passing excess arguments to jvm backend functions and classes
generateModuleInFrontendIRMode, runBackend

FirJvmBackendExtension, ModuleCompilerIrBackendInput
2023-02-01 11:42:45 +00:00
Aleksei.Cherepanov 090a58ccc4 Change allConstants test
Currently, FIR compilation of `const val b: Byte = 50 + 50` shows an error, but old compiler doesn't (it shows only warning). Since this is an incremental test, it should not be affected by compiler errors, but should only test for .kt usage without recompilation.

#KT-54991 In Progress
2023-01-30 13:45:39 +00:00
Aleksei.Cherepanov a0fa438735 Revert "FIR IC: fix test with behavior different from non-tight cycle variants"
This reverts commit c4a29651 as it is no longer needed after IC fix: `5ba3053e` "[IC] Do not report recompilation of non-existing files", because now fix-ic-build.log duplicates the main build.log

#KT-54991 In Progress
2023-01-30 13:45:38 +00:00
Aleksei.Cherepanov 848e1001f8 Add test for IC issue with typealias
If typealias is defined in a separate file, then after changing some base types, an incremental compilation of Kotlin could not find all affected files, because of lack of information, which it can not get on the class file analyzing phase. FIR provides a new approach to IC compilation: now we can run the frontend several times, which allows us to obtain all necessary information and use it to mark all affected files for recompilation.
Relates to KT-54991

#KT-28233 Fixed
2023-01-30 13:45:37 +00:00
Ilya Goncharov 1150ec6882 [JS] Implementation dependencies for JS klibs
^KT-56158 fixed
2023-01-27 13:31:59 +00:00
nataliya.valtman 3aade8ad95 Mark removed source file as deleted for compiler
#KT-55905 Fixed
2023-01-25 09:43:10 +00:00
Roman Efremov 14b4cdc7c4 Write "hasEnumEntries" flag into metadata when feature enabled
^KT-53929 Fixed
2023-01-23 12:53:04 +01:00
hungvietnguyen f172c50f27 New IC: Ignore LookupSymbols that refer to file facades (#5069)
A LookupSymbol should only refer to either a class, a class member, or a
package member.

When a LookupSymbol refers to a file facade (e.g.,
LookupSymbol(name="FooKt", scope="com.example")), it is redundant as it
doesn't impact the IC analysis to find files to recompile.

Previously, the new IC (ClasspathChangesComputer) would fail when
detecting that IncrementalJvmCache reported these redundant
LookupSymbols. With this change, the new IC will just ignore them.

Note: A better approach would be to fix IncrementalJvmCache to not
report these LookupSymbols, but it will require some significant
cleanup/refactoring work, so we can consider it later.

Test: New KotlinOnlyClasspathChangesComputerTest.testRenameFileFacade
^KT-55021 Fixed
2023-01-19 12:21:29 +01:00
Alexander.Likhachev 3dcf5af4b0 [IC] Add methods to write without explicit registering in a transaction
#KT-49785 In Progress
2023-01-17 22:15:57 +00:00
Alexander.Likhachev 581bc89849 [IC] Introduce ICContext to simplify configuration propagation to caches
#KT-49785 In Progress
2023-01-17 22:15:56 +00:00
Alexander Likhachev 0260d1d63f [IC] Move marking a transaction as successful up
#KT-49785 In Progress
2023-01-17 22:15:55 +00:00
Alexander Likhachev 274c9b6294 [IC] Register JS IC header file and lookup counter in transaction
#KT-49785 In Progress
2023-01-17 22:15:53 +00:00
Alexander Likhachev 20ed029ba5 [Gradle, IC] Add gradle property to control precise compilation outputs backup
#KT-49785 In Progress
2023-01-17 22:15:52 +00:00
Alexander Likhachev 6a91dd6bac [IC] Add KDoc for compilation transactions
#KT-49785 In Progress
2023-01-17 22:15:52 +00:00
Alexander Likhachev 7d471dafa3 [IC] Lower logging level inside RecoverableCompilationTransaction
#KT-49785 In Progress
2023-01-17 22:15:52 +00:00
Alexander Likhachev 5461667421 [IC] Measure time metrics in CompilationTransaction
#KT-49785 In Progress
2023-01-17 22:15:51 +00:00
Alexander Likhachev 1a5d2a7b7e [IC] Implement compiler outputs backup logic
#KT-49785 In Progress
2023-01-17 22:15:50 +00:00
Alexander Likhachev 3806105821 [IC] Introduce transactions to be able to revert compiler output changes
#KT-49785 In Progress
2023-01-17 22:15:50 +00:00
Hung Nguyen 908dbf32cf IC: Clean up closing caches logic in IncrementalCompilerRunner.kt
Make the code more readable and address a small issue where we
did not close caches when returning `ICResult.RequiresRebuild`
(it was not exactly a correctness issue because we would recompile
non-incrementally in that case).

^KT-55709 In progress (This is a follow-up on a previous change for this
    bug)
2023-01-17 17:22:59 +05:30
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Ivan Kochurkin 5d273ce839 [FIR & FIR2IR] Prepare test and CLI infrastructure to support MPP
- Move out getAnalyzerServices from FirFrontendFacade to TestSetupUtils
- Simplify DependencyListForCliModule. Now it takes BinaryModuleData as input
- FirOutArtifact contains several FirOutputArtifactPart
- Simplify FirFrontendFacade
2023-01-13 12:55:57 +00:00
Ivan Kochurkin bcfdbaa6a6 [FIR] Use ModuleCompilerAnalyzedOutput instead of FirResult
Remove FirResult since it has the same semantics value
2023-01-13 12:55:55 +00:00
Hung Nguyen 63a0660cc3 IC: Close caches before falling back to non-incremental compile
Previously, we didn't close caches if incremental compilation failed.
The assumption was that we would fall back to non-incremental
compilation, where it shouldn't matter whether caches were closed or not
as non-incremental compilation should be able to recover from a
corrupted state of the caches.

However, this choice might have caused issues such as KT-55709 where
non-incremental compilation fails after fallback.

In this commit, we will now always close the caches before falling back,
just to be safe.

TODO:
  1. We'll need to verify whether not closing the caches was the actual
     cause of KT-55709, and that this commit fixes it.
  2. Even if this commit fixes the issue, we'll need to see why
     non-incremental compilation fails to recover from unclosed caches
     (it would remain unsafe if that was not addressed).

^KT-55709 In progress (see TODO #1 above)
2023-01-13 00:00:42 +01:00
Dmitriy Novozhilov bc93556dbb [FIR] Allow FirElementSerializer.packagePartProto accept multiple files
This is needed for cases when there are multiple files with same name
 and `@JvmMultifileClass` annotation
2023-01-12 17:45:05 +00:00
Alexander Udalov 3c4b5529af Update year to 2023 in COPYRIGHT_HEADER.txt
This commit is the result of changing the year to 2023 in
COPYRIGHT_HEADER.txt and running all `generate*` tasks in
`generators/build.gradle.kts`.
2023-01-02 22:52:15 +01:00
Alexander Udalov 7a9c59aeb5 JVM IR: do not serialize metadata for actualized optional expectations
Optional-expectation annotations which have an actual counterpart should
have never been serialized to the kotlin_module's proto. See for example
the original (correct) implementation in the old JVM backend in
`PackageCodegenImpl.addDescriptorToOptionalAnnotationsIfNeeded`.

 #KT-55611 Fixed
2023-01-02 15:30:27 +00:00
Artem Kobzar fbf06b5495 [K/JS] Add a secret system property to enable the old Kotlin/JS compiler only for tests until it will be removed from the sources 2022-12-29 13:32:01 +00:00
Andrey Uskov 2be68065af Report lines number and LpS in build reports
#KT-55540 Fixed
2022-12-26 17:18:44 +03:00
Dmitriy Novozhilov 5d6cb2b691 [Test] Use IrPluginContext for searching declarations for DUMP_EXTERNAL_CLASS check 2022-12-09 12:02:07 +00:00
Andrey Uskov 41ff283856 Don't call File.getCanonicalPath in KGP
Relates to KT-54579.
2022-12-04 18:49:30 +00:00
Ilya Chernikov 30df65c321 FIR2IR: pass external builtins to module descriptor
to support scenario when builtins are deserialized from KLib
2022-11-12 14:34:07 +01:00
Hung Nguyen cdbbead157 Handle changes to inline functions/property accessors with @JvmNames
If we detect a change in an inline function `foo` with @JvmName
`fooJvmName`, we have two options:
   1. Report that function `foo` has changed
   2. Report that method `fooJvmName` has changed

Similarly, if we detect a change in an inline property accessor with
JvmName `getFoo` of property `foo`, we have two options:
   1. Report that property `foo` has changed
   2. Report that property accessor `getFoo` has changed

The compiler is guaranteed to generate `LookupSymbol`s corresponding to
option 1 when referencing inline functions/property accessors, but it is
not guaranteed to generate `LookupSymbol`s corresponding to option 2.
(Currently the compiler seems to support option 2 for *inline*
functions/property accessors, but that may change.)

Therefore, we will choose option 1 as it is cleaner and safer.

^KT-54144 In progress

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress

Extract KotlinClassInfo to a separate class

to reduce the size of IncrementalJvmCache and prepare for the next
change.

^KT-54144 In progress

Ignore inline functions that are not found in the bytecode

^KT-54144 In progress

Add unit test for handling `@JvmName`s

Test: KotlinOnlyClasspathChangesComputerTest
             #testFunctionsAndPropertyAccessorsWithJvmNames
^KT-54144 Fixed

Update unit tests for handling `@JvmName`s

In a previous commit, we made a behavior change for inline property
accessors: The existing behavior is that if the implementation of an
inline getter has changed, only usages of the getter will be impacted
but not usages of the setter (and vice versa).

After that previous commit, usages of *both* the getter and setter will
now be impacted (i.e., we might compile slightly more files). This is
because a change to either the getter or the setter will now be
considered a change to the property, which will help simplify our change
analysis.

This commit updates the relevant unit tests to reflect the new behavior.

Test: Updated Incremental*TestGenerated.PureKotlin#testInlinePropertyInClass
      and Incremental*TestGenerated.PureKotlin#testInlinePropertyOnTopLevel

^KT-54144 Fixed
2022-11-10 10:03:55 +01:00
nataliya.valtman 9b212cfa86 Revert "Extract KotlinClassInfo to a separate class"
This reverts commit ec3da62672.
2022-11-07 13:59:32 +01:00
Hung Nguyen ec3da62672 Extract KotlinClassInfo to a separate class
to reduce the size of IncrementalJvmCache and prepare for the next
change.

^KT-54144 In progress

Handle changes to inline functions/property accessors with `@JvmName`s

If we detect a change in an inline function `foo` with @JvmName
`fooJvmName`, we have two options:
   1. Report that function `foo` has changed
   2. Report that method `fooJvmName` has changed

Similarly, if we detect a change in an inline property accessor with
JvmName `getFoo` of property `foo`, we have two options:
   1. Report that property `foo` has changed
   2. Report that property accessor `getFoo` has changed

The compiler is guaranteed to generate `LookupSymbol`s corresponding to
option 1 when referencing inline functions/property accessors, but it is
not guaranteed to generate `LookupSymbol`s corresponding to option 2.
(Currently the compiler seems to support option 2 for *inline*
functions/property accessors, but that may change.)

Therefore, we will choose option 1 as it is cleaner and safer.

^KT-54144 In progress

Ignore inline functions that are not found in the bytecode

^KT-54144 In progress

Add unit test for handling `@JvmName`s

Test: KotlinOnlyClasspathChangesComputerTest
             #testFunctionsAndPropertyAccessorsWithJvmNames
^KT-54144 Fixed

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress
2022-11-07 13:10:02 +01:00
Andrey Uskov 3832c6a520 Do not use File.canonicalPath in incremental caches
This fix improves performance of incremental compilation on Windows
machines.
When portable JPS caches are used, DirtyFilesHolder.getRemovedFiles
could return file names which are not allowed on current platform.
Previously it resulted in IOException on File.getCanonicalFile.
#KT-53735 Fixed
2022-10-20 09:04:45 +00:00
nataliya.valtman 57f1405d95 Don't report compilation exceptions into error.log 2022-10-14 15:41:49 +00:00
nataliya.valtman 2379185398 Log daemon exception for In process compilation into error.log 2022-10-14 15:41:48 +00:00
Ilya Goncharov c726360ad2 Change policy with legacy compiler backend
[JS] Remove incremental js jps test

[JS] Remove test of maven js archetype

[JS] Fix another one test

[JS] Fix tests for jps

[JS] Try to fix maven test data

[JS] Fix test data

[JS] Fix test data for ant

[JS] Fix jsExtraHelp test

[JS] Fix test run from not-Gradle build tools

[JS] Set flag without compiler error

[JS] Disable warnings and errors in legacy compiler called from Gradle

[JS] Proofread messages

[JS] Not proofread messages

KT-42326
2022-09-29 13:56:30 +00:00
Nikolay Krasko 1630386712 Move to JDK_X_Y variables 2022-09-21 22:53:19 +00:00
Ilya Goncharov cab79d950f [Gradle, JS] outputName -> moduleName 2022-09-21 10:58:25 +00:00
Ilya Goncharov f320efedd3 [JS, Tests] Migrate IR tests onto outputDir and outputName 2022-09-21 10:58:21 +00:00
nataliya.valtman 4863e5d47b Store errors into separate files 2022-09-20 14:11:25 +02:00
Hung Nguyen 03f83ff339 New IC: Include inline property accessors in class/package members
Problem: ClasspathChangesComputer (a core component of the new IC) uses
the existing inline function analysis from the old IC
(IncrementalJvmCache.InlineFunctionsMap). If an inline property accessor
has changed, the inline function analysis will report the name of the
property accessor, not the name of the property.
ClasspathChangesComputer doesn't see the property accessor's name in the
list of class/package members, so it will throw an exception.

Solution: There are 2 options:
  1. If an inline property accessor has changed, the inline function
     analysis can report the name of the property instead of the
     property accessor.
  2. ClasspathChangesComputer can include property accessors in the list
     of class/package members.

In this commit, we will choose option 2 as it is simpler.

Test: New KotlinOnlyClasspathChangesComputerTest.testPropertyAccessors

Small cleanup - PLS SQUASH INTO PREVIOUS COMMIT

  - Address review
  - Fix failed tests
  - Add some trivial changes

^KT-53871 Fixed
2022-09-19 11:50:08 +02:00
Hung Nguyen def886cd31 Clean up fall-back logic in IncrementalCompilerRunner
Make it clear that there 3 distinct cases:
   1. Incremental compilation completed with an ExitCode.
   2. Incremental compilation was not possible for some valid reason
      (e.g., for a clean build), and we will perform non-incremental
      compilation.
   3. Incremental compilation failed with an exception.
      In this case, we will:
        - Print a warning with a stack trace
        - Ask the user to file a bug
        - Collect rebuild reason enum for analytics
           + TODO: Collect the stack trace too
        - Fall back to non-incremental compilation

Test: Existing BaseIncrementalCompilationMultiProjectIT.testFailureHandling_UserError,
      Updated BaseIncrementalCompilationMultiProjectIT.testFailureHandling_ToolError

^KT-53015: In progress
2022-09-19 07:33:16 +03:00
Alexander Udalov d50cf81e42 Remove tests on incremental compilation with old JVM backend
#KT-48532 Fixed
2022-09-16 00:16:31 +02:00