Commit Graph

6946 Commits

Author SHA1 Message Date
Victor Petukhov fb76d819f0 [FE] Erase type parameters of super types during intersection type emptiness check as well 2022-04-27 19:50:27 +00:00
Victor Petukhov 0f1d212fc5 [FE] Fix tests 2022-04-27 19:50:27 +00:00
Alexander Udalov 24f3c7dc7d Psi2Ir: fix usage of flexible vararg type after approximation
This only affects JVM IR, and this is similar to how this was done in
the old JVM backend in `CallBasedArgumentGenerator.generateVararg`.

 #KT-52146 Fixed
2022-04-22 14:15:28 +02:00
Alexander Udalov 6734f542b3 JVM IR: sanitize indy lambda proxy names correctly
In case there are several proxy functions for indy lambdas in the same
container, its names are "...__proxy", "...__proxy-0", "...__proxy-1",
..., yet before this change, only the first one was sanitized. So if
it's happening inside a constructor, `<init>` was left unrenamed which
led to ClassFormatError.

 #KT-52040 Fixed
2022-04-21 17:06:16 +02:00
Ivan Kochurkin 8c7fad9a5e [FIR] Support of type arguments in annotations ^KT-48444 Fixed 2022-04-18 15:36:19 +00:00
Ivan Kochurkin 05bed8f751 [FIR] Hide local type for return type of single expression function ^KT-51418 Fixed 2022-04-18 15:36:18 +00:00
Igor Chevdar 231fe42c0a [klibs] Fixed a bug in the signature-to-descriptor searcher
#KT-51927 Fixed
2022-04-14 07:33:56 +00:00
wrongwrong 2da8d53791 Fix callBy for InlineClassAwareCaller in case of >=32 parameters
#KT-51804 Fixed
2022-04-13 23:35:48 +02:00
Ilya Gorbunov 3778b1fde1 Remove ExperimentalStdlibApi no longer required in tests 2022-04-12 15:03:42 +00:00
pyos a07e21d913 JVM: streamline handling of tail-call suspend functions
Just see if every suspend call is followed only by safe instructions or
returns, then insert a suspension point check if there isn't a direct
return.

The first part of this is equivalent to the old implementation, just
refactored. The second part generates strictly more checks; see, for
example, the fixed test, in which the previous implementation failed to
insert a check before a CHECKCAST.

^KT-51818 Fixed
2022-04-11 17:00:26 +00:00
Ilmir Usmanov 1e3f84402d Safely check for suspend function parent
The issue here is that the function can be in unlowered file, and
thus its parent package fragment and not class.

 #KT-49317 Fixed
2022-04-08 23:31:49 +02:00
Dmitriy Novozhilov 6e2402620f [FIR] Fix collecting member candidates on receiver with smartcast
^KT-51460 Fixed
^KT-51827
2022-04-07 12:18:48 +00:00
Sergej Jaskiewicz d7d86a0e95 [JS IR] Lift lambdas that capture no context
If a lambda expression does not capture any local variables, convert
it to a global free function and replace the lambda creation with
a reference to that function.

Example: for the following Kotlin code

```kotlin
fun foo(f: () -> Unit) = f()

fun bar() = foo { console.log("hello") }
```

before this patch, we generated:

```js
function foo(f) {
  return f();
}
function bar() {
  return foo(bar$lambda());
}
function bar$lambda() {
  return function () {
    console.log('hello');
  };
}
```

after this patch, we generate:

```js
function foo(f) {
  return f();
}
function bar() {
  return foo(bar$lambda);
}
function bar$lambda() {
  console.log('hello');
}
```
2022-04-07 10:31:35 +00:00
Ilmir Usmanov 1488790cd3 Replace recursion with a loop
#KT-51530 Fixed
2022-04-07 01:08:22 +00:00
Denis.Zharkov 2a6700e5d5 FIR: Unignore all blackbox tests on context receivers 2022-04-06 16:05:39 +00:00
Denis.Zharkov 4349060db1 K1: Support referencing class context receivers in a form of this@Name 2022-04-06 16:05:34 +00:00
Mikhail Glukhikh 9bd6a9c069 FIR: handle 'SinceKotlin' as a special kind of deprecated
#KT-51850 Fixed
2022-04-06 12:51:20 +00:00
Ilya Goncharov 002d62de89 rra/ilgonmic/revert-signatures-changes
[JS IR] Fix line number test

[JS IR] Ignore isInstance repl test

[JS IR] Ignore isInstance repl test

[JS IR] Add test with unsafe variance

Revert "[JS IR] Optimize away upcasts"

This reverts commit 8149189585.

Get rid of duplicated signatures

Revert "[JS IR] Consider erasing type parameters in return type in js signatures"

This reverts commit 6adcbe081e.

Revert "rra/ilgonmic/exported-bridges-2 [JS IR] Use js name for signature"

This reverts commit 00289d35

[JS IR] Leave as is

[JS IR] Add test with overloading by generic

[JS IR] Add test from master

[JS IR] Add tests from master

Merge-request: KT-MR-5987
Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com>

^KT-51700 fixed
^KT-51523 fixed
^KT-51685 fixed
2022-04-05 15:35:12 +00:00
Alexander Udalov df86290083 Add another test for KT-49715 and fix JS IR behavior
#KT-49715
 #KT-51798 Fixed
2022-04-05 01:06:57 +02:00
Xin Wang 24105139ea Handle methods descriptor clash in data class
1. Extension functions declared in data classes are generated earlier by `generateMembersDeclaredInClassBody`
2. Extension functions fake override from parent class are generated earlier by `generateFakeOverrideMemberDeclarations`

So it is safe to filter out extension functions inside `generateAdditionalMembersForDataClass`

 #KT-49715
 #KT-51798
2022-04-05 01:06:57 +02:00
Pavel Kunyavskiy 4873f18067 [K/N] Enable definitely not null cast test for native 2022-03-31 09:02:14 +00:00
Ilmir Usmanov 7579be6c68 Generate CHECKCAST after ACONST_NULL in coroutines
If we do not do this, the state-machine builder will not know the type
of the ACONST_NULL, defaulting to Object, leading to VerifyError.
Alternatively, we could use LVT to deduce the type, but getting types
from LVT is something I got rid of long time ago, and I have no desire
to return it back.

Generating CHECKCAST hints the state-machine builder the type of the
variable avoiding the issue of VerifyError. However, this CHECKCAST
replaces StrictBasicValue.NULL_VALUE with BasicValue in
OptimizationBasicInterpreter. To preserve optimization on not-spilling
known nulls, introduce BasicValues, which represent typed nulls and
create BasicInterpreter, which is aware of them. This way we have the
best of two worlds - we do not spill known nulls, and we know the type
of ACONST_NULL.

 #KT-51718 Fixed
2022-03-30 14:27:29 +00:00
Ilya Chernikov 5d6e2b57a7 Sort sealed class inheritors to ensure reproducible builds with IC
without this sorting the inheritors field in the metadata may depend on
whether some inheritors are compiled in the IC round or not.
2022-03-30 08:35:30 +00:00
Pavel Kunyavskiy 7ba4d9e1f0 Rework nullability in IR 2022-03-30 06:27:59 +00:00
Svyatoslav Scherbina 8bb178e4a7 Native: ignore delegatedProperty/provideDelegate/kt39588.kt box test
It performs unchecked cast from `String` to `List<Any>`, which
legitimately fails when global optimizations are enabled.

^KT-48749 Declined
2022-03-29 13:27:44 +00:00
Svyatoslav Scherbina cf581738c3 Native: improve ClassCastException message for local classes
Previously it was like "null cannot be cast to MyObject" or
"MyObject cannot be cast to null", because `KClass.qualifiedName` is
`null` for local classes (including anonymous ones).

Use `KClass.toString()` instead, for both object actual dynamic type
and cast target type. This string representation is generally more
meaningful for such cases, and contains useful details for local
classes.
2022-03-28 08:21:55 +00:00
Evgeniy.Zhelenskiy 28bf83ceac [IR] Unite inline class and multi-field value class representation
#KT-1179
2022-03-24 11:38:43 +00:00
Evgeniy.Zhelenskiy 282ab398c6 [IR] Generify lowerings
#KT-1179
2022-03-24 11:38:42 +00:00
Victor Petukhov 22b2554368 [FE 1.0] Support suspend only SAM conversions
^KT-50477 Fixed
2022-03-24 09:28:28 +00:00
Steven Schäfer 1134dc3858 JVM IR: Resolve fake overrides during inline class mangling
This is necessary to determine which mangling scheme to use (KT-51672).
2022-03-24 00:38:34 +00:00
Victor Petukhov 3aabc8d666 [FE 1.0] Substitute anonymous object's supertypes while using that in public declarations
^KT-46136 Fixed
2022-03-23 21:13:32 +00:00
Mikhail Glukhikh b327f5c731 Substitute type variables properly in ConeOverloadConflictResolver
#KT-46187 Fixed
2022-03-23 09:54:46 +00:00
Alexander Udalov ae2c4753df Fix incorrect test data on KCallable.call for inline classes 2022-03-18 12:29:05 +01:00
Alexander Udalov 8b56babb1d Fix type mapping of nullable inline class types in reflection
Based on #4761.

 #KT-31141 Fixed

Co-authored-by: wrongwrong <boranti1995@gmail.com>
2022-03-18 12:29:05 +01:00
wrongwrong a1b6c9f546 Fixed a bug where DEFAULT_CONSTRUCTOR_MARKER appeared twice as an argument
#KT-27598 Fixed

Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
2022-03-17 00:54:09 +01:00
Alexander Korepanov 69295f2cf0 [JS IR] IC invalidation refactoring
- Huge refactoring for IC
  - Update hash combination logic
  - Introduce value class for IC hashes
  - Calc md5 directly by function IR
  - Split IC logic by classes
  - Move JsIrLinkerLoader into separate file
  - CacheUpdateStatus is a sealed class
  - Render TYPE_PARAMETER reified flag

^KT-51081 Fixed
^KT-51084 Fixed
2022-03-15 05:34:19 +00:00
Mikhael Bogdanov 6b00b51e6d Generate fake variables for default lambdas during inline
#KT-51557 Fixed
2022-03-14 08:48:26 +00:00
Xin Wang 4277827506 Don't transform irBranch if tableswitch can't be generated
#KT-34466 Fixed
2022-03-12 14:30:00 +03:00
wrongwrong c4735f9f29 Add tests for KFunction involving value classes
See KT-31141.
2022-03-10 23:28:40 +01:00
Mikhail Glukhikh 4178c8156a Fix NPE in KtSourceElement.elementType #KT-44152 Fixed 2022-03-10 09:01:58 +00:00
Alexander Udalov 1e26888dd9 Psi2ir: fix parameter indices when generating extension invoke call
Incorrect `valueParameter` was passed to `generateValueArgument`, which
resulted in incorrect type being considered for generating suspend
conversion.

 #KT-50949 Fixed
2022-03-09 15:19:38 +01:00
Alexander Udalov f7f64be269 Remove unneeded .txt dumps in codegen box tests
These are only used in diagnostic tests, and for codegen tests they are
basically useless.
2022-03-08 14:19:37 +01:00
Alexander Udalov 328853dffe Add tests for obsolete issues
(Test for KT-37331 is added to multiplatform/defaultArguments/suspend.kt.)

 #KT-30080
 #KT-33641
 #KT-36237
 #KT-36952
 #KT-37331
 #KT-38920
 #KT-39256
 #KT-42415
 #KT-44636
 #KT-45704
 #KT-47084
 #KT-47894
2022-03-08 14:19:37 +01:00
Ilmir Usmanov 254ada88d1 Minor. Add test with inline class inside inline class's init block 2022-03-04 05:23:23 +03:00
Dmitry Petrov fdb01d96f0 JVM_IR JavaSamConversionEqualsHashCode 2022-03-03 09:01:42 +00:00
Dmitriy Novozhilov 4022918ea2 [FIR2IR] Properly generate arguments for annotation constructors calls in default values of annotation constructors 2022-02-28 11:42:35 +03:00
Alexander Udalov 157db778fd Rework support of Iterator.iterator optimization in ForLoopsLowering
- Fix the predicate used for finding the member function `next`: check
  that there's no extension receiver parameter, don't filter out
  abstract functions.
- Do not copy iterator expression, instead change the type in all
  references to the iterator variable.
- Fix some style issues.

 #KT-47171 Fixed
2022-02-28 01:39:31 +01:00
Xin Wang 1b776bd5b6 JVM_IR: Specialize iterator if possible
fixes KT-47171
2022-02-28 01:39:31 +01:00
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00
Dmitry Petrov a1db077af9 JVM_IR KT-51458 fix DNN types handling in JvmStringConcatenationLowering 2022-02-25 10:09:14 +03:00