Commit Graph

38341 Commits

Author SHA1 Message Date
Dmitry Petrov 52a3713c9c JVM small optimization in temporary vals elimination 2021-12-01 12:13:17 +03:00
Dmitry Petrov f3ca0afd34 JVM run temporary variable elimination before inlining 2021-12-01 12:13:16 +03:00
Dmitry Petrov de3203ee48 JVM KT-49903 prohibit reordering of 'getstatic System.out' 2021-12-01 12:13:13 +03:00
Denis.Zharkov 6082f0b712 FIR2IR: Postpone binding overrides for lazy classes until sources processed 2021-12-01 08:32:20 +00:00
Denis.Zharkov 78ba49ddd8 FIR2IR: Make a component for Fir2IrConverter 2021-12-01 08:32:20 +00:00
Denis.Zharkov 60073239bb FIR2IR: Introduce non-static main conversion method to Fir2IrConverter 2021-12-01 08:32:20 +00:00
Kristoffer Andersen 0dd5ad08f3 [EE-IR] Support inline functions in IR evaluator
Inline functions called by the fragment is detected by the fragment
frontend and the PSI for them is supplied to the compiler backend.

For the purpose of compilation, the inline function is considered as
part of the same source module as the fragment, and then discarded
upon loading the compiled fragment for evaluation.
2021-12-01 00:52:46 +01:00
Kristoffer Andersen 39fee12f32 [IR/FE] BindingContext: Change USED_AS_EXPRESSION to Basic Slice
This commit changes the slice implementation used for
`USED_AS_EXPRESSION`.

Here is the problem as identified and mitigated by this commit:

Slices are key-value maps. They are not total over the domain of keys,
so "looking up" a key not in the slice is a valid operation, yielding
`null`.

A binding context is a collection of slices.

Binding contexts can be stacked as composite binding contexts to
e.g. facilitate scoped analyses. Looking up a key proceeds down the
stack, yielding the first non-null value, or `null` if no slice in the
stack of binding contexts contain that key.

A slice made by `createSimpleSetSlice` models a "set" of keys that can
be enlarged by inclusion: adding `(k, true)` to the slice indicates
`k` belongs to the set. `(k, false)` indicates non-membership.

However, looking up a key _not in_ the slice yields _false_, rather
than null.

Hence, simple set slices do not compose in composite binding traces.

This was encountered porting the expression evaluator to the IR
backend. PSI2IR uses `USED_AS_EXPRESSION` to generate expression body
functions properly. The frontend analysis of the fragment is layered
ontop of the binding context from the editor's analysis of the
underlying project being debugged, which contains speficially the
analysis results of inline functions called from the fragment.
2021-12-01 00:52:46 +01:00
Ilmir Usmanov 8e8a6e6108 Do not count receivers in default parameters mask
If we implement default function with default parameters in inline
class, the receivers will be added to parameter list
(see ac7538a269). But since they
are not present in source parameters, we should not count them when we
compute mask for default parameters.

 #KT-49977 Fixed
2021-11-30 15:09:16 +00:00
Mikhail Glukhikh 7ccd1309e6 FirToConstantValueTransformer: extract lazy dispatchReceiverValue 2021-11-30 18:00:02 +03:00
Mads Ager f220e4a5ed [FIR] Fix a couple of issues in annotation serialization. 2021-11-30 18:00:00 +03:00
Dmitriy Novozhilov f12a010fc8 [Test] Fix file separators in generated spec tests on windows
^KTI-713 Fixed
2021-11-30 17:02:55 +03:00
Hung Nguyen 6ba1b2cc08 KT-45777: Don't include classpath snapshot dir in task output backup
for performance reasons: (1) the snapshots are too big, and (2) they are
usually updated only at the end of the task execution--in a failed task
run, they are usually unchanged and therefore don't need to be restored.
2021-11-30 13:59:19 +03:00
Hung Nguyen 062a8fe56f KT-45777: Ignore Kotlin synthetic classes when computing classpath changes 2021-11-30 13:59:17 +03:00
Hung Nguyen 2b65d673bb KT-45777: Also collect added classes/class members as classpath changes
as they can impact recompilation (examples shown in the code comments).

Test: Updated ClasspathChangesComputerTest
2021-11-30 13:59:17 +03:00
Hung Nguyen 6bee7948e7 KT-45777: Don't compute snapshots for inaccessible classes
Also visit a class file with ASM once to extract all information we need
in advance, instead of visiting the class file each time some piece of
info is needed.
2021-11-30 13:59:14 +03:00
Hung Nguyen f52be5f471 KT-45777: Move classpath diffing to incremental Kotlin compiler (2/2)
as we need access to the lookup tracker to compute classpath changes
more efficiently and reduce the size of the saved classpath snapshot.

The previous commit only changed the files' paths, this
commit actually updates the files' contents.

Note that classpath snapshotting still happens in Gradle artifact
transforms. (However, the previous commit also moved the code for
classpath snapshotting together with the code for classpath diffing as
they are closely related.)
2021-11-30 13:59:13 +03:00
Hung Nguyen dfaf195e1d KT-45777: Move classpath diffing to incremental Kotlin compiler (1/2)
This commit only changes the files' paths, the next commit will update
the files' contents.

See the next commit for more context.
2021-11-30 13:59:12 +03:00
Dmitriy Novozhilov c46e9943cc [FIR] Get rid of FirExtension.key
In reality plugin key was used only in two ways:
- found corresponding generator for member scope of generated class
- pass it to declaration origin so it can be read in backend IR plugin

Because of first usage plugin key was required to be an object, which
  reduces functionality of second usage, because there was no way to
  pass any additional info via key to IR (in future this usecase will be
  covered with IR declaration attributes, but right now we don't have
  them)

So now generator which created some class is now saved in its attributes
  and plugins can use any keys they want. And since there is no other
  usages of `FirExtension.key` it removed from FirExtension API at all
2021-11-30 12:57:53 +03:00
Dmitriy Novozhilov e7af50fe2b [FIR] Allow all extensions register declaration predicates 2021-11-30 12:57:52 +03:00
Dmitriy Novozhilov ce218b8a0b [FIR] Make FirExtensionRegistrar a proper extension point
After that commit it's allowed to register any FIR plugin using
  existing extension infrastructure (`-Xplugin` CLI argument,
  plugin.xml for IDE plugins, etc)
2021-11-30 12:57:50 +03:00
Ilya Muradyan 6917ff7d2a [scripting] Move earlierScripts to the frontend descriptor
^KT-20488 fixed
2021-11-30 09:11:59 +03:00
Mads Ager 09da67767e [JVM_IR] Fix mangling of inline class inherited interface methods.
^KT-49864 Fixed
2021-11-30 03:33:56 +03:00
Sergej Jaskiewicz 887e91328f [JS IR] Allow value classes in external decls
Instances of value classes are passed unboxed, unless the instance is
nullable _and_ the value class wraps another nullable value.

#KT-43224 Fixed
2021-11-29 21:51:29 +00:00
Alexander Udalov 3f47725eb9 Add regression test for coroutines issue KT-49294 2021-11-29 22:09:59 +01:00
Anton Bannykh 5b66c4cdc3 [JS IR] speed up temporary name resolving 2021-11-29 21:09:35 +03:00
Anton Bannykh 2259c6f75d [JS IR IC] assert cross-file tag are not null and fix tests 2021-11-29 21:09:35 +03:00
Anton Bannykh 33cd7e982c [IR] support storing signatures for non-public symbols 2021-11-29 21:09:34 +03:00
Anton Bannykh d74ab1538b [JS IR] fix IC pipeline and unmute tests 2021-11-29 21:09:33 +03:00
Anton Bannykh 3be44a3540 [JS IR] fix missing signature 2021-11-29 21:09:33 +03:00
Anton Bannykh ef4ef8c930 [JS IR] switch to the IC Ir2Js and fix tests 2021-11-29 21:09:31 +03:00
Mikhail Glukhikh cebe25ff39 FE: don't create KtFile stubs on virtual files without ids
This commit is kinda revert of the change in platform 203:
https://github.com/JetBrains/intellij-community/commit/5d91f7bf2e5718d715c0d90ed1a212ea845fb2a3

#KT-49833 Fixed
2021-11-29 18:42:23 +03:00
Mikhail Glukhikh d16b5c8bd8 FE: make error message more precise #KT-49598 Fixed 2021-11-28 11:32:11 +03:00
Mikhail Glukhikh 0290ca07af FE: fix some error messages (filed -> field)
#KT-49600 Fixed
2021-11-28 11:32:10 +03:00
Mikhail Glukhikh 7fe08d5a38 FE: fix some error messages (must have only -> must only have)
#KT-49609 Fixed
2021-11-28 11:32:10 +03:00
Mikhail Glukhikh c15c7f7dc8 FE: fix visibility check in LazyImportScope #KT-23727 Fixed 2021-11-28 11:32:07 +03:00
Mikhail Glukhikh 4550999288 FE: use proper version in version requirement error message
#KT-48690 Fixed
2021-11-28 11:31:51 +03:00
Mikhail Glukhikh 2f1d415e4d FE: report DECLARATION_CANT_BE_INLINED at 'inline' modifier
#KT-44022 Fixed
2021-11-28 11:31:51 +03:00
Alexander Udalov 4df937ff7f JVM IR: keep property for $receiver field of optimized delegated properties
For properties which delegate to other property via the getValue
operator from stdlib (see KT-39054), we generate `$receiver` field which
stores the receiver of the property reference used in the delegate. The
problem was that this backing field was missing `correspondingProperty`.
It's needed because it is used as a map key to store static fields in
`JvmCachedDeclarations.getStaticBackingField`. If it's null, accesses to
the static $receiver fields are not remapped correctly in
`RemapObjectFieldAccesses` and
`MoveOrCopyCompanionObjectFieldsLowering`, which led to ICCE or NSFE.

 #KT-49793 Fixed
2021-11-26 19:21:16 +01:00
Alexander Udalov 29c1fe1be1 Minor, move tests on KT-39054 into a subdirectory 2021-11-26 19:18:25 +01:00
Denis.Zharkov 85e6c90052 FIR: Temporary adjust diagnostic tests
Elvis now is being resolved a bit differently and in case
of inconsistent types, the while expression has error type,
but no diagnostic is reported since the element has no valid source element

When one sets the source
https://github.com/JetBrains/kotlin/commit/817316cdc93457c1de7cf10c3b422e3a4b486e5b
it brings back the issue KT-45989 that was effectively unresolved but hidden
due to diagnostic loss

^KT-45989 Open
2021-11-26 19:39:52 +03:00
Denis.Zharkov 7eb758fab1 FIR: Avoid propagation of @Exact annotation through elvis 2021-11-26 19:39:52 +03:00
Denis.Zharkov 0d9ad62d4a Fix inference for lambdas with with extension function expected type
^KT-49832 Fixed
^KT-49836 Fixed
2021-11-26 19:39:51 +03:00
Denis.Zharkov 3fb17cfa9a Minor. Reformat PostponedArgumentInputTypesResolver.kt 2021-11-26 19:39:50 +03:00
Denis.Zharkov 61fe70b600 Minor. Rename isAnonymousFunction to isFunctionExpression 2021-11-26 19:39:50 +03:00
Denis.Zharkov c0a46eaefd FIR: Fix inference of nullable unit lambda at RHS of elvis 2021-11-26 19:39:49 +03:00
Denis.Zharkov 46217318c0 FIR: Load final static constant Java fields as non-nullable 2021-11-26 19:39:48 +03:00
Denis.Zharkov dba04bcf80 Fix extraction of type for start projected type
Some existing tests start failing after previous commits
2021-11-26 19:39:48 +03:00
Denis.Zharkov 07440ee4a1 FIR: Fix incorrect inference errors for <expr>::class
Do not use outer expect type for <expr>
2021-11-26 19:39:46 +03:00
Denis.Zharkov 3ec7866ead FIR: Fix inference for case of non-nullable RHS of elvis
Some existing tests start failing after previous commits adding @Exact
attribute to `?:`

They have a form:
var x: String? = nullable()

if (x == null) {
   x = nullable() ?: "" // considering @Exact the whole elvis is inferred to nullable from expect type
}

x.length // should be smart cast
2021-11-26 19:39:46 +03:00