Commit Graph

95642 Commits

Author SHA1 Message Date
Yahor Berdnikau a7e1d36528 Drop compileOnly dependency on :kotlin-gradle-compiler-types in compiler
This dependency was only required for compiler options Gradle DSL
generation, but was leaking into runtime not-accessible classes.

^KT-54602 Fixed
2022-10-26 16:32:36 +02:00
Troels Bjerre Lund 80b50bcd21 [K/N] Improve performance benchmark build
This unlinks the benchmarksAnalyzer build from being configured automatically
whenever any benchmark build is.

Co-authored-by: Troels Lund <troels@google.com>
2022-10-26 13:02:24 +00:00
mvicsokolova 6a4e9f1d0f Atomicfu JVM IR: fixed visibility modifiers of generated declarations, should be private.
Fix for: https://github.com/Kotlin/kotlinx-atomicfu/issues/258
2022-10-26 12:59:25 +00:00
Ilya Goncharov fd5fba6f09 [JS IR] Fix case with bridge with nested classes
^KT-54686 fixed
2022-10-26 12:56:03 +00:00
Alexander Korepanov 2e48557a0d [JS IR] Update hashing in IC infrastructure
The patch should reduce possible collisions
2022-10-26 10:54:37 +00:00
Alexander Korepanov e2922219f2 [JS IR] Add more JS IC tests for top level properties 2022-10-26 10:54:36 +00:00
Aleksei.Cherepanov 26e7c29a91 [JPS] Rebuild module on facet change
The logic of detecting changes in Kotlin facets was changed from "Include selected fields" to "Include all compiler arguments and exclude selected". This will help to avoid multiple IC issues when new change-sensitive compiler arguments will be added

(#KTIJ-17137, #KT-51536, #KTIJ-17170, #KTIJ-17300, #KT-47983) Fixed

Merge-request: KT-MR-7455
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2022-10-26 09:45:27 +00:00
Mikhail Glukhikh 50cd560d09 K1: add more tests for BI assignment checker, fix corner cases
Related to KT-54004
2022-10-26 09:21:49 +00:00
Mikhail Glukhikh 87af855087 Use callElement instead of reportOn in BuilderInferenceAssignmentChecker
This commit fixes the breach in reportOn usage
Related to KT-54004
2022-10-26 09:21:49 +00:00
Mikhail Glukhikh 8e48636b29 K1: don't report assignment TYPE_MISMATCH in BI under feature ON
Related to KT-54004
2022-10-26 09:21:48 +00:00
pyos 6c6d653e85 FE: don't lose annotations on Java primitive arrays
but only use them to enhance for warnings for now.

^KT-48861 Fixed
2022-10-26 09:33:40 +02:00
Troels Bjerre Lund c6e4d034cb [K/N] Fix large array allocations ^KT-54659
If the count argument is above 2**29, then memberSize does not fit in
uint32_t.

Co-authored-by: Troels Lund <troels@google.com>

Merge-request: KOTLIN-MR-533
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2022-10-25 19:18:54 +00:00
Igor Chevdar 94a2479015 [K/N][IR] Replaced end-to-end indexing with in-file one
We don't want the names of classes/functions to be dependant on the files order,
this could be bad for per-file caches and/or incremental compilation.
2022-10-25 17:44:07 +00:00
Igor Chevdar 7a7f1d559d [K/N][IR] Refactored a bit FunctionReferenceLowering 2022-10-25 17:44:06 +00:00
Sergej Jaskiewicz d16bbb1145 [JS] [tests] Look for properties in local.properties 2022-10-25 16:59:12 +00:00
Nicklas Ansman 1417c8961b KAPT: pass KAPT generated classes to kotlinc classpath
Make sure to pass .class files generated by annotation processors
to KotlinCompile task. This way, Kotlin files can refer to symbols
generated in these .class files during annotation processing.

Disable the test in Kapt3ClassLoadersCacheIT

#KT-33847 Fixed
2022-10-25 17:11:01 +02:00
Mikhail Glukhikh 80fa765333 K1: introduce synthetic assignment checker with deprecation for KT-54305
#KT-54305 Fixed
Related to KT-54309
2022-10-25 12:33:09 +00:00
Mikhail Glukhikh 7bd512fbb3 FE: add test for KT-54305 2022-10-25 12:33:08 +00:00
Johan Bay 9f3d8130db Remove unnecessary deprecation annotation
Private members on private companion objects have proper visibility
so there is no need for the @Deprecated annotation.

^KT-54539 Fixed
2022-10-25 14:03:11 +02:00
Alexander Udalov b42a7be0de Psi2ir: keep nullability when substituting function type for SAM type
After we added "careful approximation of contravariant projections" in
584b70719e, some SAM conversions started to require an additional
implicit cast of the functional value before it is converted to the SAM
interface. The target type of this implicit cast was computed
incorrectly because it didn't contain nullability of the SAM type. This
could lead to a situation where a nullable value was incorrectly cast to
a non-null type, which caused a missing null check and NPE at runtime.

For example, let's consider the test `kt54600.kt`. SAM conversion
happens in the constructor call `J(filter)`. Before 584b70719e, the IR
for that argument was (irrelevant things are omitted for simplicity):

  TYPE_OP SAM_CONVERSION type=Condition<String!>!
    GET_VAR filter type=Function1<String, Boolean>?

After 584b70719e, the IR became:

  TYPE_OP SAM_CONVERSION type=Condition<Any?>!
    TYPE_OP IMPLICIT_CAST type=Function1<Any?, Boolean>
      GET_VAR filter type=Function1<String, Boolean>?

Note the two changes:
* The resulting SAM type changed from `Condition<String!>` to
  `Condition<Any?>`. This is exactly the point of the "careful
  approximation" change, because just erasing the "in" projection from
  the parameter type is incorrect, see the explanation for that change.
* The value is now implicitly cast to the _non-null_ function type
  before it is SAM-converted. The presence of the cast is fine, but the
  fact that it's to a non-null type is an oversight.

The target type for this cast is computed at
`KotlinType.getSubstitutedFunctionTypeForSamType` in psi2ir. Now it
extracts the nullability from the SAM type and retains it in the
resulting function type.

After this change, the IR for the argument becomes:

  TYPE_OP SAM_CONVERSION type=Condition<Any?>!
    TYPE_OP IMPLICIT_CAST type=Function1<Any?, Boolean>!
      GET_VAR filter type=Function1<String, Boolean>?

Note that the target type is now flexible, as the resulting SAM type.
Another option would be to make it nullable, as the type of the
functional value, but there doesn't seem to be any difference.

 #KT-54600 Fixed
2022-10-25 11:20:23 +00:00
Mikhail Glukhikh c0789b5207 PSI/FIR->IR translators: return to 1.7.10 behavior for field references
In 1.7.20 we used the nearest Java-based receiver for such field
references in backend. Now we are using use-site receiver again,
it can lead to accidental usage of derived class property backing field.

This is effectively a revert of KT-49507 fix, see commits:
- fa914f20
- b0a6508d

#KT-54393 Fixed
#KT-49507 Planned
#KT-52338 Planned
2022-10-25 08:36:01 +00:00
Jinseong Jeon 14213ddad2 AA: fix expected type for lambda with explicit label 2022-10-24 22:07:05 +02:00
Vsevolod Tolstopyatov b29309478e Take into account 'KTypeImpl.classifier' in its hashCode and equals
Since KT-53308, we started to cache results of typeOf invocation
in reflection. The cache uses the origin 'KClassifier' as a key with
an optional list of 'KTypeProjection' in type argument position,
and computed result as a value.

Without classifier check, the caching produces incorrect execution in
a very specific classloaders usage which is leveraged
by IDEA source-tree:

* All Kotlin stdlib and reflect classes are always loaded by the same
  classloader
* Other classes that depend on Kotlin are loaded by separate
  classloaders

The reproducer:

* Attempt to use typeOf<kotlin.List<Foo>> from one classloader caches
  the resulting KType
* Attempt to use typeOf<kotlin.List<Foo>> from another classloader
  for the same 'Foo' that differs only in classloader reuses the
  computed KType, meaning that KType type argument classifier
  is simply incorrect and points to the 'Foo' from the first classloader

#KT-54611 Fixed
#KT-54629 Fixed

Merge-request: KT-MR-7470
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-10-24 19:05:08 +00:00
Pavel Punegov c098ba789c [K/N][perf] JS IR Gradle DSL syntax changed to JS
Merge-request: KOTLIN-MR-532
Merged-by: Pavel Punegov <pavel.punegov@jetbrains.com>
2022-10-24 17:58:18 +00:00
Sebastian Sellmair fb5ae330fc [Gradle][MPP] KotlinTargetHierarchyDsl: Add test for custom hierarchy
^KT-53570 Verification Pending
2022-10-24 14:34:50 +00:00
sebastian.sellmair fef1de8620 [Gradle][MPP] KotlinTargetHierarchyBuilderImpl: Support KotlinWithJavaTarget
^KT-53570 Verification Pending
2022-10-24 14:34:49 +00:00
sebastian.sellmair c332c928fc [Gradle][MPP] Refine naming for KotlinTargetHierarchyBuilder
^KT-53570 Verification Pending
2022-10-24 14:34:49 +00:00
sebastian.sellmair 1a519a8159 [Gradle][MPP] Add test cases for KotlinTargetHierarchy*
^KT-53570 Verification Pending
2022-10-24 14:34:49 +00:00
Sebastian Sellmair da8a18920d [Gradle][MPP] Mark KotlinTargetsContainer and KotlinTargetHierarchyBuilder with KotlinTargetsDsl annotation
To prevent confusing shortcuts defined on `KotlinTargetsContainer`
when declaring a KotlinTargetHierarchy:

e.g.

```kotlin
kotlin {
    targetHierarchy.default {
        common {
            ios() // <- [DSL_SCOPE_VIOLATION]
            //'fun ios(): Unit' can't be called in this context
            // by implicit receiver. Use the explicit one if necessary
        }
    }
 }
```

^KT-53570 Verification Pending
2022-10-24 14:34:48 +00:00
Sebastian Sellmair 0c114b9664 [Gradle][MPP] CommonizerHierarchicalIT: Use targetHierarchy API
^KT-53570 Verification Pending
2022-10-24 14:34:48 +00:00
Sebastian Sellmair e84dac45d7 [Gradle][MPP] Update kotlin-gradle-plugin-api api reference
^KT-53570 Verification Pending
2022-10-24 14:34:48 +00:00
Sebastian Sellmair 1823e0fad4 [Gradle][MPP] KotlinTargetHierarchyBuilderImpl: only build child groups if explicitly included
^KT-53570 Verification Pending
2022-10-24 14:34:47 +00:00
Sebastian Sellmair 487368d9df [Gradle][MPP] KotlinTargetHierarchyDescriptor: Remove function supertype
^KT-53570 Verification Pending
2022-10-24 14:34:47 +00:00
Sebastian Sellmair a8a861e1ce [Gradle][MPP] KotlinTargetHierarchyBuilder: implement w/ include & exclude predicates
^KT-53570 Verification Pending
2022-10-24 14:34:47 +00:00
Sebastian Sellmair c5d6162578 [Gradle][MPP] Implement initial KotlinTargetHierarchy APIs
^KT-53570 Verification Pending
2022-10-24 14:34:46 +00:00
Ivan Kylchik 1fc2575052 Use correct toString method in IrCompileTimeChecker for analysis 2022-10-24 13:14:16 +00:00
Ivan Kylchik 5b16b2c71e Properly verify args in string concatenation expression for interpreter
If string concatenation contains object value, then this argument
will not have explicit toString call. We must find and check toString
method manually.

#KT-54615
2022-10-24 13:14:16 +00:00
Alexander Udalov c813e03c1e Kapt+JVM_IR: do not generate nested enum as final
#KT-54187 Fixed
2022-10-24 12:48:22 +00:00
Dmitriy Novozhilov 766a51069c Advance bootstrap to 1.8.20-dev-1438 2022-10-24 12:24:40 +00:00
Alexander Korepanov 39666dafa5 [JS IR] Make JS IR IC info messages more pretty and usable 2022-10-24 12:05:05 +00:00
Anton Lakotka f5d9819c3f [Gradle] Update watchosDeviceArm64 target preset
^KT-54583 Verification Pending
2022-10-24 11:20:52 +00:00
Anton Lakotka fe2ee9886d [Gradle] watchosDeviceArm64 should not run simulator tests
This reverts commit 640ba1ec

^KT-54583 Verification Pending
2022-10-24 11:20:51 +00:00
Pavel Punegov 259d58c817 [K/N] Rename jsIr preset usage back to js
Merge-request: KT-MR-7467
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2022-10-24 10:44:23 +00:00
Artem Kobzar 14e4febb05 [K/JS] Exclude default from the regular reserved keywords to give ability to export declarations with default export ^KT-54480 Fixed
fix(KT-54480): exclude default from the regular reserved keywords to give ability to export intities with default export.

Merge-request: KT-MR-7459
Merged-by: Artem Kobzar <Artem.Kobzar@jetbrains.com>
2022-10-24 10:12:30 +00:00
Yahor Berdnikau 57578b569e Substitute stdlib-jdk7{,8} dependencies with stdlib
Only when dependencies contain kotlin-stdlib-1.8+ dependency. Such
substitution could be disabled via 'gradle.properties' by adding 'kotlin
.stdlib.jdk.variants.substitution=false'.

^KT-54136 Fixed
2022-10-24 09:21:22 +00:00
pyos 65c153a722 JVM: consider casts of null to be redundant
These should only have ever been necessary for field type inference in
coroutines, which should have been fixed by 0fc676a20c.

Unlike 903a5d69a4, this time the change is in an optimization pass.
Advantage: optimization passes have a closer to the JVM view of the
bytecode, which makes this change significantly more likely to be correct.
Disadvantage: technically we don't really guarantee optimization passes
other than FixStack will run at all. For KT-54581 this is 100% fine
since the problem itself is caused by redundant checkcast elimination in
the first place (otherwise there would've been a redundant cast to
String), but for KT-53146 this means the fix is somewhat incidental and
not necessarily guaranteed.

^KT-53146 Fixed
^KT-54581 Fixed
2022-10-24 11:11:21 +02:00
vladislav.grechko 6f4a60ac91 Fix equality comparison for inline class over inline class
^KT-54536: Fixed
2022-10-21 21:17:40 +00:00
vladislav.grechko db133bedf9 Fix ClassCastException on equality comparison on inline class objects
^KT-54603: Fixed
2022-10-21 21:17:40 +00:00
Ilya Goncharov 2abceb1ca5 [Gradle, JS] Enable test when fixed problems with klib
This reverts commit 03bea0dbaa.
2022-10-21 14:56:26 +00:00
Alexander Udalov 8812f632cc Fix optimization of property delegates of platform types
The old code didn't replace the delegate field access because it was
wrapped into a TYPE_OP IMPLICIT_NOTNULL.

 #KT-54463 Fixed
2022-10-21 13:23:38 +00:00