Commit Graph

96279 Commits

Author SHA1 Message Date
pyos 623dfdd5a3 FIR DFA: generate more correct implications on as/as?
^KT-54851 Fixed
2022-11-22 15:44:28 +00:00
pyos 6a2d74e211 FIR DFA: generate type implications on all null comparisons 2022-11-22 15:44:28 +00:00
pyos bc9b358c9f FIR DFA: bring into compliance with De Morgan's laws
I don't even know if this affects any real code, but it did uncover
some deeper issues, like the fact that `!is` did not add any statements
when `true`.
2022-11-22 15:44:27 +00:00
pyos 3436535e7a FIR DFA: deprioritize branches with no reassignments in flow unions
callBothLambdas({ x = "..." }, { x is Int })
  // the assignment always executes, so x is String | (String & Int);
  // the latter is always a subtype of the former so it can be ignored
2022-11-22 15:44:27 +00:00
pyos fd609416c6 Minor: FIR DFA: do not merge type statements for aliases
The result is the same as for whatever is being aliased
2022-11-22 15:44:26 +00:00
pyos 2ae06a8d46 FIR DFA: when removing a variable, move type statements about dependents
val c = C("...")
  val d = c
  if (c.x == null) return
  c.x.length // c.x has type String
  d.x.length // d.x -> c.x through d -> c
  c = C(null) // remove alias d -> c
  d.x.length // info from c.x moved to d.x

^KT-54824 Fixed
2022-11-22 15:44:26 +00:00
pyos 3cea2d7243 FIR DFA: assert that type statements are not attached to aliases 2022-11-22 15:44:25 +00:00
pyos ceb1607057 FIR DFA: when breaking aliasing, keep the rest of the group together
var a = ...
  var b = a
  var c = a
  a = ...
  // b and c still aliased
2022-11-22 15:44:25 +00:00
pyos 7c8e9ac316 FIR DFA: remove RealVariableAndType 2022-11-22 15:44:24 +00:00
pyos 33363ba1fc Add more variable aliasing tests 2022-11-22 15:44:23 +00:00
Vladimir Dolzhenko a8bef8ac81 Prevent unsafe publication of not full initialized instance
#KTIJ-22182
2022-11-22 15:24:38 +00:00
Egor Kulikov 067036c162 RawFirBuilder refactoring
Second step for KT-52615
Get rid of PsiHandlingMode
Get rid of source in FirLazyBlock
Refactor lazy creation

Merge-request: KT-MR-7753
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2022-11-22 14:43:53 +00:00
Pavel Kunyavskiy 27949bccf6 [K/N] Simplify enumsSupport 2022-11-22 13:51:23 +00:00
Pavel Kunyavskiy bc8ccc496b [K/N] Fix per-file caches with new instance functions 2022-11-22 13:51:23 +00:00
Pavel Kunyavskiy 68f78f1e5f [K/N] Make instance a property not a field
This enables inlining machinery, and allows to avoid frame in simple
cases.
2022-11-22 13:51:23 +00:00
Pavel Kunyavskiy d3adfec2fb [K/N] Rework object and enum classes initialization
Now it works with common logic for all static scope not with custom one.
2022-11-22 13:51:22 +00:00
Pavel Kunyavskiy 7006eb938d [K/N] Apply initializers lowering to any declaration container 2022-11-22 13:51:22 +00:00
Pavel Kunyavskiy 9516094755 [K/N] Rename file initializers to static initializers 2022-11-22 13:51:21 +00:00
Pavel Kunyavskiy d09a18c88b [K/N] Get rid of outdated module initializers 2022-11-22 13:51:20 +00:00
Pavel Kunyavskiy cf80a86855 [K/N] Some strange fix to make wasm target happy 2022-11-22 13:51:20 +00:00
Anna Kozlova 1906a41d9a fix testdata after merge 2022-11-22 13:31:41 +01:00
Marco Pennekamp 93f560eb4d [Analysis API] Add call resolution tests for KTIJ-23373
- The Java functions aren't recognized as candidates during the test
  (`FULL_JDK` isn't helping), so I've replicated the tests with local
  extension functions and confirmed that they uncover the same
  exception.
2022-11-22 13:13:35 +01:00
Marco Pennekamp 60dbe73f60 [Analysis API] Create substitutor from type arguments defensively
- Call candidate collection sometimes provides candidate symbols to
  `createConeSubstitutorFromTypeArguments` with fewer type parameters
  than type arguments provided by `FirQualifiedAccess`, which lead to
  an NPE. Because call candidates collected for the purposes of the
  Analysis API are best-effort guesses, we can ignore the additional
  type arguments.

^KTIJ-23373 fixed
^KTIJ-21506 fixed
2022-11-22 13:13:35 +01:00
Pavel Kirpichenkov ad6582160b Add test for KT-55019 2022-11-22 10:56:25 +00:00
Nikolay Lunyak c5469d5fb5 [FIR] KT-53988: Report ILLEGAL_SELECTOR for constants as selectors
Merge-request: KT-MR-7756
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>

^KT-53988 Fixed
2022-11-22 10:54:09 +00:00
Leonid Startsev f627d81d53 Make diagnostic for @MetaSerializable on nested annotation
K2 plugin API has a limitation that meta annotations from plugin predicates
can't be used on nested annotations because their resolve process includes supertypes
resolve, that can be affected by the plugin itself. Therefore, @MetaSerializable
can't be applied to nested annotation classes in K2, which is reflected by
this diagnostic.

For old FE, diagnostic is lowered to WARNING with deprecation message.
2022-11-22 10:53:28 +00:00
Leonid Startsev 9586bf74e0 Use .fullyExpandedType to get serializable annotation from inside typealias
to correctly handle 'global customization via typealias' feature
in K2 serialization plugin.
2022-11-22 10:53:28 +00:00
Leonid Startsev 76fc7ce0ad Fix creating FirSerializableProperties for external classes.
External classes do not have primary constructor, so we need to use 0 as
value parameter count for them to be externally serializable when possible.
2022-11-22 10:53:27 +00:00
Leonid Startsev 56cd150554 Enable FIR plugin in SerializationComponentRegistrar
so real projects can be built with K2 and serialization.

Correctly register renderer for serialization plugin errors.
2022-11-22 10:53:27 +00:00
Anna Kozlova 702d0b4d54 [compiler] missed type parameters in local properties (KTIJ-23583)
even though local variables won't contain type parameters,
let's build fir for them
2022-11-22 10:47:45 +00:00
Anna Kozlova 3fdd0aacd3 [compiler] preserve fir receiver in tree
when selector is invalid expression,
ensure that fir tree still contains receiver as well as selector

KTIJ-23578
2022-11-22 10:46:59 +00:00
Mikhail Glukhikh 1aae9d6456 FIR2IR: generate this reference to non-source class properly
#KT-53983 Fixed
2022-11-22 10:01:16 +00:00
Andrei.Tyrin dc8ac50ddf [Gradle][MPP] Flag for suppressing warning for Android Style folders
^KT-54464 Verification Pending
2022-11-22 09:51:53 +00:00
Sebastian Sellmair ace17c71e7 [Gradle] Implement IdeNativePlatformDependencyResolver.test - non native source sets
KT-54974
2022-11-22 09:48:31 +00:00
Sebastian Sellmair 4bcd8b4b66 [Gradle] Implement IdeNativePlatformDependencyResolver
KT-54974
2022-11-22 09:48:31 +00:00
Ivan Kylchik e3f8aa255a Fix StackOverflow in interpreter for case with recursive enum init
#KT-54884 Fixed
2022-11-21 20:03:18 +00:00
Alexander Shabalin d512420204 [K/N] Refactor Executor out of ExecutorService without gradle dependency
Merge-request: KT-MR-7622
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
2022-11-21 19:52:29 +00:00
Igor Chevdar e16cfd5485 [K/N][IR] Suspend tail call optimization for coroutines
Even if a coroutine class has to be built for a suspend function, we
still can perform tail call optimization for it.
2022-11-21 19:32:41 +00:00
Igor Chevdar b100dfe8be [K/N][IR] Implemented suspend tail call optimization
If for a suspend function all calls to other suspend functions a tail calls,
it is not needed to build the coroutine implementation.
2022-11-21 19:32:40 +00:00
Igor Chevdar 68e6317159 [K/N][tests] Added FileCheck tests on suspend tail call optimization 2022-11-21 19:32:39 +00:00
Jaebaek Seo c55efe62a3 [AA] handles FIR isUsedAsExpression for return within function block
For the following example:

```
fun foo(bar: Int) {
  <expr>if (bar == 4) return "Four"
  else return "Int"</expr>
}
```

AA FE1.0 `isUsedAsExpression` returns `false`.
Since the current AA FIR `isUsedAsExpression` returns `true` for the
above example, this commit fixes it.
2022-11-21 18:26:41 +01:00
Ilya Kirillov b6481ed891 [FIR] do not use FirValueParameter for function type parameter
As it is a different abstraction, introduced FirFunctionTypeParameter instead

Also, fix syntax checkers for function type parameter

^KT-55035 fixed
2022-11-21 16:17:51 +00:00
Leonid Startsev 1b9fdeadfe Do not enable serialization plugin intrinsics in K2
because they lead to an unbound symbol errors
2022-11-21 16:15:46 +00:00
Leonid Startsev 715a730819 Insert a runtime exception if star-projection type is encountered in serializer<T>() intrinsic
This makes behavior consistent with non-intrinsified version of this function and serializer(KType).

#KT-54878 Fixed
2022-11-21 16:15:46 +00:00
Aleksei.Cherepanov de5fd767d4 Suppress warning for mvn+kapt+jdk9
Suppress the warning about lack of tools.jar, as this jar does not present in JDK9+

#KT-47110 Fixed
2022-11-21 15:22:27 +00:00
Jinseong Jeon f2bc25c71d SLC: fix visibility/static modifer of property in companion 2022-11-21 15:55:13 +01:00
Jinseong Jeon e2901c81ac SLC: populate fields from companion in annotation 2022-11-21 15:55:12 +01:00
Sebastian Sellmair f02fd2e04e [Gradle] Implement smoke test for external android target prototype resolving sdk
KT-54981
2022-11-21 14:11:27 +00:00
Sebastian Sellmair 83af85706d [Gradle] ExternalKotlinTarget Api: Implement 'configureIdeImport' API
^KT-55010 Verification Pending
2022-11-21 14:11:27 +00:00
Yahor Berdnikau 19f4e39ee7 Fix toolchain test fails jvm target validation
Happens after changes for KT-54933 was merged earlier than for KT-55004.
2022-11-21 14:59:01 +01:00