Commit Graph

37423 Commits

Author SHA1 Message Date
Ilmir Usmanov b0088fd06d Minor. Ignore test on JS_IR 2021-09-20 21:29:58 +00:00
Ilmir Usmanov 91491eef06 Fixup end label of local variable if it is before start label
In that case, put end label to next label after start label.
2021-09-20 21:29:58 +00:00
pyos ade9f5a1e8 JVM: rename a couple ValueKinds to make their purpose clearer 2021-09-20 19:29:44 +02:00
pyos f786084a0a JVM_IR: mark direct uses of inline lambdas as conditionally suspend
They may or may not be inlined later.

IDK how the test passes when both modules are compiled with the old
backend - perhaps this has something to do with the fact that when `f`
is compiled with the IR backend, the call to `x()` is followed by `pop`
and `getstatic kotlin/Unit.INSTANCE`? This is probably why the original
issue in kotlinx.coroutines reports that everything works fine with
kotlinx-coroutines-core:1.4.3.

^KT-46879 Fixed
^KT-48801 Fixed
2021-09-20 19:29:44 +02:00
Igor Yakovlev 41a69ad388 [WASM] Add receiver capturing to callable references 2021-09-20 19:08:22 +03:00
Igor Yakovlev b8d11f7938 [WASM] Add text section to implement debug info 2021-09-20 19:08:21 +03:00
Dmitriy Novozhilov 8286927e8c [FIR] Support .jar output with -Xuse-fir flag
To proper support we need to fully implement main function detector,
  see KT-44557

^KT-42868 Fixed
2021-09-20 15:29:45 +03:00
Roman Artemev 0bfc88fad0 [JS IC] Implement test infra for incremental caches 2021-09-20 12:23:36 +03:00
Roman Artemev c692b0b2e0 [JS IC] Make EPs for cache generation and test 2021-09-20 12:23:36 +03:00
Roman Artemev 7f424732bf [JS IC] Make API to store d.ts and sourceMap IC data 2021-09-20 12:23:35 +03:00
Roman Artemev f85a59b7f3 [JS IC] Write cache info in per-file mode too
- make sure that file is existed and not crashes the compiler
2021-09-20 12:23:35 +03:00
Roman Artemev a55be02007 [JS IC] Support binary ast in disk cache 2021-09-20 12:23:34 +03:00
Pavel Punegov 0b2a8c0c25 [K/N][Test] Ignore test with deprecated StringBuilder.deleteCharAt 2021-09-20 12:16:54 +03:00
Igor Chevdar 3a4e8e7a61 [K/N][IR] Used .isFakeOverride instead of a special origin 2021-09-18 19:46:09 +05:00
Steven Schäfer ae27be16eb AsmLikeInstructionListingTest: Print owner for FieldInsnNode 2021-09-18 00:25:58 +02:00
Igor Laevsky e23b4df519 [WASM] Remove workaround for frontend bug 2021-09-17 19:17:45 +03:00
Alexander Udalov 987a346015 JVM IR: support cyclic module dependencies
The only way to make the compiler compile several modules with a
dependency loop is via the "build file", given by -Xbuild-file and used
in the JPS (IntelliJ built-in build system) plugin.

For the old frontend/backend it works like this: we _analyze_ sources of
all modules once, as if it's one big module, and then for each module,
we _generate_ (invoke backend) only sources of that module. Backend
needs to be invoked separately per-module because every module has its
own destination directory specified in the build file.

For JVM IR, this separation into just two steps, analyze and generate,
was problematic because there's psi2ir, which works like frontend, in
that it needs the global analysis result to be able to create and link
IR correctly. So, in case of JVM IR, we need to run psi2ir on the whole
module after analysis and before generation.

In this change, psi2ir is run on the whole module via
`CodegenFactory.convertToIr` (which does nothing in the old backend),
and then parts of the resulting IR module are extracted according to the
original separation of the combined module into individual modules via
`getModuleChunkBackendInput` by matching IrFile against KtFile. And
then, backend is run for each such module.

 #KT-45915 Fixed
 #KT-48668 Fixed
2021-09-17 17:39:49 +02:00
Alexander Udalov 5d6ca27c93 JVM IR: introduce CodegenFactory.convertToIr
The steps of psi2ir and JVM backend need to be separated in the API
because in case of cyclic module dependencies (which are allowed in JPS)
psi2ir should be run first on all sources, and then JVM backend on each
module separately. `CodegenFactory.convertToIr` does nothing in the old
backend.

Also, move the ignoreErrors to GenerationState for simplicity.
2021-09-17 17:39:48 +02:00
Dmitriy Novozhilov bfeb9c219d [FE 1.0] Correctly set USED_AS_EXPRESSION for unreachable catch clauses
^KT-48806 Fixed
2021-09-17 18:38:19 +03:00
Nikolay Lunyak ba8dc49a31 [FIX] Move backing field bytecodeListing tests to a separate folder 2021-09-17 15:29:35 +03:00
Nikolay Lunyak 54067628ff [FIX] Add a checker for unsupported explicit backing fields 2021-09-17 14:36:39 +03:00
Nikolay Lunyak 7921e64540 [FIX] Add the ExplicitBackingFields language feature 2021-09-17 14:36:39 +03:00
Dmitry Gridin 9ceb477523 [light classes] fix cache value creation
Cause: we are implicitly wrapping `jvmDefaultMode` that leads to
incorrect result

^KTIJ-19042 Fixed
^EA-357501 Fixed
2021-09-17 03:49:38 +00:00
Tianyu Geng 765cad8448 FIR checker: substitute type parameters in dispatch receiver type
Consider the following code:

```
fun test(a: List<String>) {
  a.first()
}
```

The dispatch receiver type of `first` in this case is `List<T>` before
this change. After this change, it's `List<String>`.

In addition, this change also replace the dispatch receiver type with
the more specific type if available. For example, consider the following

```
class MyList: ArrayList<String>()

fun test(a: MyList) {
  a.get(0)
}
```
The dispatch receiver type of `get` is `MyList`, instead of
`ArrayList<String>`. That is, a fake override is created in this case.
2021-09-17 01:59:06 +03:00
Tianyu Geng d77db2cda6 FIR checker: expose API to check if two types are compatible
This is useful for quickfixes offering casts. We don't want to offer
user to cast incompatible types.

Also, explicitly allow compare to `Nothing` and handle `Nothing` from intersection
2021-09-17 01:59:05 +03:00
Tianyu Geng 5b0ca06e95 FIR checker: make SMARTCAST_IMPOSSIBLE report the desired type at receiver position
Previously the smartcast type is reported. This is undesirable because
usually this type is an intersection and hence not denotable.
2021-09-17 01:59:03 +03:00
Tianyu Geng 951812f130 FIR checker: record whether type mismatch is due to nullability
This is useful for downstream quickfixes.
2021-09-17 01:59:01 +03:00
Tianyu Geng d3e8cc577c FIR checker: fix local type approximation on delegated property
Previously types of delegated property is not approximated, which can
cause local types to leak through public APIs.
2021-09-16 22:38:08 +03:00
Tianyu Geng 76e192fc8a FIR Checker: check AMBIGUOUS_ANONYMOUS_TYPE_INFERRED
Also change
org.jetbrains.kotlin.fir.types.TypeUtilsKt#hideLocalTypeIfNeeded to skip
approximating anonymous objects if there are multiple super type refs so
that resolution behaves the same (for uncompilable code).

Note that this change does not implement check for
ApproximateAnonymousReturnTypesInPrivateInlineFunctions as the check is
already turned on in 1.5 and will likely not needed when FIR becomes
stable.
2021-09-16 22:38:06 +03:00
Igor Laevsky 6432388778 [WASM] Don't handle ref.cast of nulls. Spec was updated a while ago 2021-09-16 20:24:45 +03:00
Igor Laevsky 15668e2266 [WASM] Lower Unit to Void in order to mark statements with no result 2021-09-16 20:24:44 +03:00
Igor Laevsky 9685695769 [WASM] Fold redundant patterns with drop instruction on a wasm level 2021-09-16 20:24:43 +03:00
Alexander Likhachev 612b96bd54 [Daemon] Introduce the way to get Kotlin daemon compiler version
#KT-48294 In Progress
2021-09-16 13:25:18 +00:00
Svyatoslav Kuzmich 0abc798da9 [Wasm] Add JS interop tests 2021-09-16 14:20:35 +03:00
Svyatoslav Kuzmich a32b86d016 [Wasm] Simple support for external classes and interfaces
* Map these types to Wasm externref
* Don't generate any declaration code for now

Casting and accessing members is not supported yet
2021-09-16 14:20:35 +03:00
Svyatoslav Kuzmich 35a5c9ea71 [Wasm] Support exporting functions via @kotlin.js.JsExport
Previously we exported main function only.
Extend this feature to arbitrary number of annotated functions.
Type restrictions and conversions are similar to imported functions.
2021-09-16 14:20:35 +03:00
Svyatoslav Kuzmich c0d48e3417 [Wasm] Support external functions 2021-09-16 14:14:58 +03:00
Svyatoslav Kuzmich 7e399202a2 [Wasm] Support generating browser-compatible JS harness
* Use fetch and instantiateStreaming
* Call main export if it is present
* Produce a variable with module name that contains a
  promise of module exports
2021-09-16 14:14:58 +03:00
Igor Chevdar e194a07358 [tests] Added some tests 2021-09-16 10:54:14 +00:00
Andrey Uskov 8f963bed7c Optimized performance of recordPackageLookup
#KT-47909 Fixed
2021-09-16 12:07:55 +03:00
Elena Lepilkina 45493b6542 [IR] Support simple cases of inlining fake override getters/setters 2021-09-16 07:55:15 +00:00
Ilmir Usmanov 9e4f234941 Minor. Add space after when
Co-authored-by: Louis CAD <louis.cognault@gmail.com>
2021-09-15 22:28:32 +02:00
Ilmir Usmanov 755b92b0e9 Document coroutines codegen. Remove mentions of experimental coroutines 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 4d1545d522 More minor changes 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 6a150fffe6 Minor spelling changes 2021-09-15 22:28:32 +02:00
Ilmir Usmanov de3ffc4a89 Remove obsolete FIXME 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 0372d9050a Clarify tail-call optimization for functions returning Unit
Review fixes.
2021-09-15 22:28:32 +02:00
Ilmir Usmanov 1cdae75dc3 Document coroutines codegen: debug 2021-09-15 22:28:32 +02:00
Ilmir Usmanov 995062cb19 Document coroutines codegen: callable references
returning inline classes
2021-09-15 22:28:32 +02:00
Ilmir Usmanov fce06305b9 Document coroutines codegen: inliner part 3: returning inline classes
Update the information, mention, that there are two markers, not just
one
2021-09-15 22:28:32 +02:00