Commit Graph

43311 Commits

Author SHA1 Message Date
Evgeniy.Zhelenskiy aceab2ac1f [IR] Fix KT-57973
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-57973
2023-04-17 12:33:10 +00:00
Evgeniy.Zhelenskiy 8c748bfea4 [IR] Add more tests for inline/value classes secondary constructors
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-55333
2023-04-17 12:10:14 +00:00
Mikhail Zarechenskiy fc37885d6d K1: report a warning for invisible setter accessed from a derived class
The issue is that during binding fake overrides, the compiler doesn't
 differ setters from its properties, so the compiler uses the same
 visibility for setter and entire property.

 Changing logic at the binding stage can cause some unpredictable consequences so
 the fix is to do this differentiation right at the reporting stage

 ^KT-56662 Fixed

Merge-request: KT-MR-9565
Merged-by: Michail Zarečenskij <Mikhail.Zarechenskiy@jetbrains.com>
2023-04-17 11:08:16 +00:00
Marco Pennekamp e13d4f2328 [LL FIR] KT-57207 Combine Java symbol providers
- `LLFirCombinedJavaSymbolProvider` combines multiple
  `JavaSymbolProvider`s. Its advantages are: combined index access,
  caching, classpath order disambiguation.
- Scopes can still be optimized with a combined scope instead of a naive
  union scope.

^KT-57207 fixed
2023-04-17 11:07:48 +00:00
Marco Pennekamp 567abd2a1c KT-57207 Implement JavaClassFinder.findClasses
- This change is a prerequisite for allowing combined Java symbol
  providers (in LL FIR) to correctly disambiguate classpath order after
  getting classes with a combined scope, as the index access of the
  combined Java symbol provider is not guaranteed to return the class
  that should be first based on the original dependency order. To be
  able to disambiguate, a combined Java symbol provider needs access to
  all class candidates the index can find.
2023-04-17 11:07:47 +00:00
Marco Pennekamp f2e3c593a1 [FIR] KT-57207 JavaSymbolProvider: Accept existing JavaClasses
- `javaFacade.findClass` is a potentially costly operation. This commit
  extends `JavaSymbolProvider` and its class cache to accept an already
  existing `JavaClass` if provided, circumventing the `findClass`
  operation.
2023-04-17 11:07:46 +00:00
Marco Pennekamp b33c5f77ac [FIR] Move JavaClass.hasMetadataAnnotation to JavaUtils
- This function will be reused in a later commit.
2023-04-17 11:07:46 +00:00
Marco Pennekamp 288606868e [FIR] KT-57207 Avoid FirJavaFacade.knownClassNamesInPackage in the IDE
- `FirJavaFacade.knownClassNamesInPackage` cannot be computed in the IDE
  using the current strategy because there are multiple finders and
  there is no `CliFinder`. However, the cache was still used, which
  caused it to be filled with `null` values and additionally caused
  worse performance in `JavaSymbolProvider` due to hash map accesses via
  `hasTopLevelClassOf`.
- Rewriting the strategy is non-trivial as additional indices are needed
  on the IDE side. See KTIJ-24642.
2023-04-17 11:07:46 +00:00
Alexander Udalov 287e0909cc Kapt+JVM_IR: do not generate super constructor call
#KT-57699 Fixed
 #KT-57939 Fixed
2023-04-17 10:40:15 +00:00
Vladimir Sukharev 3cdf4bae07 [K2/N] Refactor KonanSymbols before re-enabling special backend checks
^KT-55598
Merge-request: KT-MR-9477
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-04-17 10:35:55 +00:00
Mikhail Glukhikh 147a3331a4 RawFirBuilder: fix label bounding for binary operations
#KT-57880 Fixed
2023-04-17 10:21:25 +00:00
Mikhail Glukhikh 089222cecc K2: reproduce KT-57880 2023-04-17 10:21:24 +00:00
Jinseong Jeon ed4cc99db3 FIR: use symbol modality to ensure the retrieval of lazily resolved status
^KT-57578
2023-04-17 10:59:04 +02:00
Jinseong Jeon 5403cc7feb SLC: fix type mapping mode for var
^KT-57578
2023-04-17 10:59:03 +02:00
Jinseong Jeon 95491f223c FIR: fix subtle isFinal counterpart in ConeTypeContext
^KT-57578 Fixed
2023-04-17 10:59:03 +02:00
Alexander Korepanov e8be3043cc [JS IR] Allow restriction of function argument by external type
Add a special annotation @JsExternalTypeArgument for
 marking function parameters. The marked parameter
 accepts an argument with an external type only.

^KT-57479 Fixed
2023-04-17 08:21:10 +00:00
Anna Kozlova f810d435f4 [cls] write flexible type information to cls
^KTIJ-25172
this information would be used to create resolved FirElements from stubs,
so no ProtoBuf would be kept in memory
2023-04-14 18:12:48 +00:00
Nikolay Lunyak 20786bb35a [FIR] Refactor the default messages presence checking
Forbid calling `checkMissingMessages` accidentally
outside tests.

Checking Parcelize default messages inside a test.
2023-04-14 13:07:03 +00:00
Pavel Kunyavskiy 95541da9a1 [K/N] Remove unused default dependencies from klib
^KT-55603
2023-04-13 18:28:51 +00:00
Artem Kobzar 5dc6da2b33 [K/JS] Add serialization/deserialization for JsImport/JsExport nodes 2023-04-13 12:58:46 +00:00
Ilya Chernikov df35e5431c FIR: fix libs filtering for abs/rel paths combinations
Some of the incoming paths "absoluteness" may not match the
one of the corresponding library path, and that leaded to incorrect
filtering out some items in the deserialized symbol providers.
Fix the filtering to account for the mismatch.
#KT-57535 fixed
2023-04-13 11:18:38 +00:00
Kirill Rakhman 030866cb0b [FIR] Rewrite ConeKotlinType.hasError() using ConeKotlinType.contains() 2023-04-13 10:50:36 +00:00
Kirill Rakhman 1f29490118 [FIR] Report when typealias expansion contains deprecated type
#KT-57843 Fixed
2023-04-13 10:50:36 +00:00
Kirill Rakhman 206fad4256 [FIR] Report deprecations on deprecated super constructor calls
#KT-57350 Fixed
2023-04-13 10:50:35 +00:00
Dmitriy Novozhilov b253a3a47e [FIR] Don't lose non-serializable properties during metadata deserialization
^KT-57941 Fixed
2023-04-13 10:38:52 +00:00
Steven Schäfer 37bbf447a3 FIR: Add missing iterator function to array types in IrBuiltInsOverFir
Fixes part of KT-57627
2023-04-13 09:52:02 +00:00
Artem Kobzar c695da1bed [K/JS] Allow declare inline functions inside external declarations with a million suppresses ^KT-48154 Fixed 2023-04-13 08:53:57 +00:00
Artem Kobzar 09bccd272d [K/JS] Prevent Char boxing on value or reference equals call 2023-04-13 08:39:03 +00:00
Ivan Kochurkin 9a09565cf6 [K2, MPP] Handle overloaded properties
^KT-57532 Fixed
2023-04-12 20:43:57 +00:00
mcpiroman 7a189dc0ac [IR] Make IrMemberAccessExpression.origin mutable
Align it with all other element types where origin is mutable.
This was left unchanged previously probably because the
IrMemberAccessExpression was not handled by the tree generator.
2023-04-12 19:50:23 +02:00
mcpiroman 9831a4b9ec [IR] Autogenerate IrMemberAccessExpression 2023-04-12 19:50:23 +02:00
mcpiroman 9145cf7035 IR tree gen: allow lists of nullable elements and arrays 2023-04-12 19:50:23 +02:00
mcpiroman 62c72dedcf [IR] Prepare IrMemberAccessExpression for being autogenerated 2023-04-12 19:50:23 +02:00
Alexander Udalov 9fa5bd386c IR: minor, move IrMemberAccessExpression utils to a separate file
To help git understand that IrMemberAccessExpression is moved in the
subsequent commits where it's changed to be auto-generated.
2023-04-12 19:50:23 +02:00
Alexander Udalov 35776ed4fa IR: remove obsolete descriptor-based utils for IrMemberAccessExpression
Except `putTypeArguments`, which is moved to psi2ir where it's used.
2023-04-12 19:50:23 +02:00
Alexander Udalov 36183c411a IR: rename IrMemberAccessExpression.type/valueArguments 2023-04-12 19:50:23 +02:00
Denis.Zharkov fa8eca7a7b K2: Fix invokeExtension resolution when property type is implicit
^KT-57947 Fixed
2023-04-12 14:40:56 +00:00
Artem Kobzar f0aa6c6d32 [K/JS Gradle] Remove forceLegacyBackendUsage from KotlinGradlePlugin previously added with the compiler flags refactoring, also fix bootstrap compilation of atomicfu plugin 2023-04-12 14:04:34 +00:00
Kirill Rakhman 592baee852 [FIR] When call candidates resolve to errors, select the least bad ones
This fixes a scenario when INVISIBLE_REFERENCE is suppressed, but we
resolved to the wrong overload because when none of the candidates were
applicable, more or less the first one was chosen.

Because we call `fullyProcessCandidate` on the candidates, their
applicability can change which can lead to a situation where the
applicability of a ConeAmbiguityError is different to all its
candidates. The changes in coneDiagnosticToFirDiagnostic.kt account for
that, otherwise code like candidates.first { it.applicability ==
CandidateApplicability.UNSAFE_CALL } can throw NoSuchElementException.

#KT-57776 Fixed
2023-04-12 14:03:39 +00:00
Igor Yakovlev edf4e80165 [Wasm] Fix for ReturnableBlockLowering invalid ir type for converted inlined blocks 2023-04-12 13:24:02 +00:00
Igor Yakovlev 08273623e6 [JS/Wasm] Remove redundant code
returnableBlockMap is never mutated, so the code that uses it seems to be dead
2023-04-12 13:24:00 +00:00
Nikita Bobko 9ca7ee3b97 Don't forget to configure JdkHome for CompilerConfiguration
Review: https://jetbrains.team/p/kt/reviews/9562

This commit fixes IdeaJsr223Test in kotlin plugin. The test failure was
caused by b50a803b6f commit where we
dropped `put(JVMConfigurationKeys.JDK_HOME, ...)` from
`configureJdkClasspathRoots`. Ilya Chernikov says that it's incorrect to
set JDK_HOME in `configureJdkClasspathRoots`.

To reproduce the test failure:
1. Update `.idea/libraries/kotlinc_kotlin_dist.xml` and
   `.idea/libraries/kotlinc_kotlin_jps_plugin_classpath.xml` with new
   Kotlin (in other words: bump bundled JPS)
2. Run the test

Test failure stacktrace:
```
javax.script.ScriptException: error: cannot access 'java.io.Serializable' which is a supertype of 'kotlin.Int'. Check your module classpath for missing or conflicting dependencies
y.first() + 2
          ^
  at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.asJsr223EvalResult(KotlinJsr223JvmScriptEngineBase.kt:104)
  at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.compileAndEval(KotlinJsr223JvmScriptEngineBase.kt:63)
  at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.eval(KotlinJsr223JvmScriptEngineBase.kt:31)
  at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)
  at org.jetbrains.kotlin.idea.repl.IdeaJsr223Test.testJsr223Engine(IdeaJsr223Test.kt:31)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  at junit.framework.TestCase.runTest(TestCase.java:177)
  at com.intellij.testFramework.UsefulTestCase.lambda$runBare$11(UsefulTestCase.java:479)
  at com.intellij.testFramework.UsefulTestCase.lambda$wrapTestRunnable$13(UsefulTestCase.java:500)
```
2023-04-12 13:16:10 +00:00
Kirill Rakhman aab1959cc4 [FIR2IR] Fix codegen for lambda with dynamic receiver
#KT-57835 Fixed
2023-04-12 13:10:43 +00:00
Denis.Zharkov 39639e08f9 K2: Fix incorrect inference of delegated property type
It was working incorrectly, because we've been trying to fix
P1 variable to intersectTypes(String?, StubForP2) that should result
to String? because we've got stubEqualsToAnything enabled there,
but nullability was being chosen incorrectly because
`StubForP2.isNullableType()` returned false

NB: The code inside `is ConeTypeVariable` case wasn't working properly
because it always `lookupTag.toSymbol(session)` always returned null,
thus there was effectively five dead lines of code there.

^KT-57814 Fixed
^KT-57921 Related
2023-04-12 11:31:43 +00:00
Nikolay Lunyak caa7bee917 [FIR] KT-57835: Prevent the compiler crash
^KT-57835 Fixed
2023-04-12 10:20:44 +00:00
Dmitriy Novozhilov f8ef478647 [FIR] Assume smartacsts on member properties from friend modules as stable
^KT-57893 Fixed
2023-04-12 08:59:03 +00:00
Ivan Kylchik 08ba63df90 Implement proper name interpretation for suspend functions
#KT-57313 Fixed
2023-04-11 21:28:13 +00:00
Simon Ogorodnik 98aca55a2a KT-57927: Fix deserialization of K2JVMCompilerArguments in FP/MT tests
Due to changes in 9dcd40d7b7
classpath and pluginClasspath arguments become Arrays
Now we need to update arguments representation to properly deserialize
it

^KT-57927
2023-04-11 18:10:36 +00:00
Dmitriy Novozhilov af05646fe3 [FIR] Don't expand typealiases in annotations during type deserialization
During extracting type attributes from annotations we should expand
  typealiases of annotation type to handle cases when user makes a typealias
  on some special annotation, like `kotlin.internal.Exact`. And to exapnd
  typealias we should resolve annotation class id to symbol.
This leads to a cycle during class deserialization, if some nested annotation
  is used as type annotation in some declaration in the same class

```
interface SomeInterface {
    interface NestedInterface : @Ann Some

    interface Some

    @Target(AnnotationTarget.TYPE)
    annotation class Ann
}
```
Attempt to find symbol for SomeInterface.Ann during deserialization of
  SomeInterface.NestedInterface wil lead to second attempt to deserialize
  class SomeInterface, which eventually leads to StackOverFlow. And at the
  same time expanding typealiases for annotations from binaries has not
  much sense, because types in binaries are already expanded

So to fix this issue it's enough to just not expand typealiases on type
  annotations for types of deserialized declarations

^KT-57876 Fixed
2023-04-11 16:02:57 +00:00
Iaroslav Postovalov fb80c0cb0d Override toString function in stdlib delegates
Co-authored-by: ilya-g <ilya.gorbunov@jetbrains.com>
2023-04-11 14:46:29 +00:00