Commit Graph

867 Commits

Author SHA1 Message Date
Dmitrii Gridin b2c8d7e777 [FIR] do not treat external ide annotations as real one
Such annotations are supposed to affect only diagnostic warnings

^KT-62310 Fixed
2023-10-13 12:16:12 +00:00
Mikhail Glukhikh 156097fe17 Restore KotlinCompilerVersion.IS_PRE_RELEASE
This commit is a slightly modified revert of 4f29c113.
IS_PRE_RELEASE allows to make LATEST_STABLE version behave as
experimental when this flag is set to true.
The general goal is to prepare fix of KT-62058; after this commit
one can do it by changing IS_PRE_RELEASE flag to true.
The fix of KT-62058 is planned to be done during bootstrapping.
This preparation and the future fix are parts of umbrella KT-61951.
2023-09-21 20:09:25 +00:00
Mikhail Glukhikh 8b8088720b Rename: DeserializedContainerAbiStability.IR_UNSTABLE -> UNSTABLE
Related to KT-62056
2023-09-21 11:14:09 +00:00
Mikhail Glukhikh a77b758efa LV 2.0: drop reporting FIR_COMPILED_CLASS and relevant stuff
#KT-62056 Fixed
Related to KT-59171, KT-61951
2023-09-21 11:14:09 +00:00
Kirill Rakhman 2e4d486131 [FIR] Use enhanced scope to guess array type in annotation loading
Otherwise, we return null for any java annotation because the
unenhanced scope doesn't contain any properties.

#KT-61856 Fixed
2023-09-20 08:02:37 +00:00
Nikolay Lunyak ec9cb8beb6 [FIR] Rename JvmNames -> JvmStandardClassIds
This is more consistent with the code of
the common compiler checkers.

It would be nice to refactor the contents
of this object further, but it's out
of scope of the current branch.

^KT-54596
2023-09-19 22:14:09 +00:00
Nikolay Lunyak 986f1624ec [FIR] Remove jvm-specific annotations from common compiler code
^KT-54596 Fixed
2023-09-19 22:14:09 +00:00
Dmitriy Novozhilov 97cf240450 [FIR] Reuse enhancement storage during creation of synthetic properies
^KT-61972 Fixed
2023-09-18 15:09:07 +00:00
Mikhail Glukhikh f8ada456e4 K2: rename FakeOverrideTypeCalculator to CallableCopyTypeCalculator
This commits performs a rename.
According to KT-61443 this calculator is applicable not only to
fake (substitution/intersection) overrides.
2023-09-15 15:21:10 +00:00
Kirill Rakhman b9b99366e7 [FIR] Use resolvedType instead of coneTypeOrNull in java.deserialization
#KT-61367
2023-09-14 10:03:02 +00:00
Nikolay Lunyak aacfc31c90 [FIR] Resolve the continuation type inside createSuspendView()
Normally such types are resolved during enhancement,
but creating the suspend view happens before
enhancement, so the type may have not been resolved.

^KT-59915 Fixed
2023-09-13 11:18:06 +00:00
Kirill Rakhman 2bc25d4f6e [FIR] Properly check for visibility in FirTypeIntersectionScopeContext
This fixes a false positive OVERRIDING_FINAL_MEMBER caused by a
package-private member in a different package being added to the
list of overridden symbols. However, in Java, package-private members
from different packages are effectively like private members in that
they cannot be overridden.

#KT-61696 Fixed
2023-09-12 10:46:46 +00:00
Kirill Rakhman 16ae83bde0 [FIR] Fix Java sealed class inheritors
This fixes NO_ELSE_IN_WHEN diagnostics when using java sealed
classes in an exhaustive when.

#KT-58216 Fixed
2023-09-11 07:37:37 +00:00
Marco Pennekamp f64cc184f4 [FIR] Refactoring: Introduce base implementations for delegating scopes
- The implementations of some FIR scopes contain a significant amount of
  delegation to some original scope. This pollutes the implementation of
  such scopes and makes them harder to read.
  `FirDelegatingContainingNamesAwareScope` and `FirDelegatingTypeScope`
  can be used as base classes which delegate by default.
2023-09-08 11:13:28 +00:00
Kirill Rakhman 9a2307ad44 [FIR] Fix expression types in java annotations
#KT-61518 Fixed
2023-09-08 07:40:30 +00:00
Mikhail Glukhikh 4d9457862f K2: add sourceElement for binary Java classes
#KT-60555 Fixed
2023-09-06 13:14:16 +00:00
Alexander Udalov fec2d063c1 K2: report PRE_RELEASE_CLASS on JVM
Note that 3 tests are still muted, but for another reason: for FIR
versions of the tests, we need to compile the "pre-release library" with
the next language version which is 2.1. But since currently
LanguageVersion.LATEST_STABLE is 1.9, the compiler refuses to read
metadata of version 2.1, regardless of its own language version. Which
is correct, but it leads to irrelevant errors in the test output -- the
ones about the incompatible metadata version, NOT about the
prereleaseness.

These 3 tests can be unmuted once the default language version is
switched to 2.0.

 #KT-60780 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 8738ffb84f K2: suppress exception when reading unsupported metadata
Before the change, the compiler threw exception in the unmuted tests,
because it tried to load metadata even though it had an unsupported
version. Use the same approach as in K1 (see
DeserializedDescriptorResolver).

Now the tests are unmuted, but note that test data differs from K1. K1
does not report errors related to the class `a.A` because it loads this
class as a _Java class_, so calling its constructor and methods somehow
works. This behavior is questionable since the compiler surely knows
that it is a Kotlin class, but with an unsupported metadata version.
Trying to interpret it as a Java class may lead to subtle problems. So
it's safer for now to avoid loading Kotlin classes with unsupported
metadata versions in K2.

 #KT-60795 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 8f720ad24b K2: support -Xskip-metadata-version-check
#KT-60795
2023-09-06 08:05:34 +00:00
Alexander Udalov 7d60b5df43 K2: report INCOMPATIBLE_CLASS in JVM
#KT-60795
2023-09-06 08:05:34 +00:00
Alexander Udalov db8fb30343 K2: minor cleanup in JvmClassFileBasedSymbolProvider 2023-09-06 08:05:34 +00:00
Dmitriy Novozhilov fa4c6d55c1 [FIR] Store mapped jvm declarations in session component, share it between MPP modules
^KT-61640 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.testJavaMethodWithTypeParameter
2023-09-05 14:43:43 +00:00
Dmitriy Novozhilov bb36beb364 [FIR] Share enhancedSymbolStorage between common and platform sessions
This is needed for two reasons:
1. common and platform modules are analyzed in the same setup with same
   dependencies and configurations, so the results of the enhancement for
   any function will be completely identical. So by sharing enhanced
   symbol storage, we avoid recomputation enhanced functions and improve
   performance
2. There is a goal to have some unique key for IR declarations in FIR2IR.
   For regular declarations, the key is just Fir symbol, and for fake-overrides
   it is a pair of original symbol and fake override owners lookup tag.
   But for enhanced functions the symbol is not unique, because we create
   different symbols for the same enhanced function for different modules.
   So this change fixes this problem

^KT-60397 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there are some test breaks in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.testStarImportOfExpectEnumWithActualTypeAlias
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.DefaultArguments.testNestedEnumEntryValue
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.Basic.testEnumEntryNameCall
2023-09-05 14:43:43 +00:00
Dmitriy Novozhilov 1868b29cc9 [FIR] Don't map java functions which override kotlin builtin function with erased parameter type if it's not needed
There is a case when we shouldn't hide a function even if it overrides
  builtin member with value parameter erasure: if substituted kotlin
  overridden has the same parameters as current java override. Such
  situation may happen only in case when `Any`/`Object` is used as
  parameterization of supertype:

// java
class MySuperMap extends java.util.Map<Object, Object> {
    @Override
    public boolean containsKey(Object key) {...}

    @Override
    public boolean containsValue(Object key) {...}
}

In this case, the signature of override, made based on the correct
  kotlin signature, will be the same (because of { K -> Any, V -> Any }
  substitution for both functions). And since the list of all such
  functions is well-known, the only case when this may happen is when
  value parameter types of kotlin overridden are `Any`

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
`FirPsiBlackBoxCodegenTestGenerated.SpecialBuiltins.testMapGetOrDefault`
2023-09-05 10:18:24 +00:00
Kirill Rakhman f08d4b8bb1 [FIR] Improve condition for sorting equivalent calls by source first
This accommodates for declarations generated by plugins that don't have
a source.
2023-09-05 07:08:28 +00:00
Kirill Rakhman 4e041494be [FIR] Report DEPRECATION when Java declaration is deprecated in javadoc
#KT-60682
2023-08-31 10:19:33 +00:00
Kirill Rakhman a42cb2f37f [FIR] Allow treating candidates from the same non-source module as equivalent
This situation occurs in Native metadata compilation and lead to
false-positive OVERLOAD_RESOLUTION_AMBIGUITY reports.

#KT-61461 Fixed
2023-08-29 09:29:52 +00:00
Kirill Rakhman 7fde5af7f8 [FIR] Rename FirExpression.coneType to resolvedType 2023-08-24 07:54:57 +00:00
Kirill Rakhman 8d7c5b375e [FIR] Replace usages of FirExpression.typeRef with coneTypeOrNull
#KT-59855 Fixed
2023-08-24 07:54:57 +00:00
Kirill Rakhman 9ec814b7ad [FIR] Replace FirExpression.typeRef.coneType (and variants) with FirExpression.coneType
#KT-59855
2023-08-24 07:54:56 +00:00
Mikhail Glukhikh 27afee8683 K2: generate bounds for inner-class based raw types properly
#KT-58579 Fixed
2023-08-22 11:40:26 +00:00
Nikolay Lunyak f238ffa4bf [FIR] Make FirErrorConstructor a FirDiagnosticHolder 2023-08-22 09:13:16 +00:00
Kirill Rakhman fa77e3952d [FIR] Bring equivalent call behavior closer to K1
#KT-61159 Fixed
2023-08-21 12:11:58 +00:00
Ilya Kirillov bdfc68468f [FIR] optimize direct allocation of empty ConeTypeProjection arrays
On the snapshot from KTIJ-26260 empty ConeTypeProjection arrays take about 10mb
2023-08-18 11:36:42 +00:00
Kirill Rakhman 724d527fd8 [FIR] Fixes for call conflict resolution
Let ConeCompositeConflictResolver pass the results of the previous
resolver to the next one.
Otherwise, we get false positive conflicts when a set of candidates
can't be fully reduced by one resolver but could be resolved by the
subsequent application of multiple ones.
This change makes ConeCompositeConflictResolver order-dependent and
thus, ConeOverloadConflictResolver must be invoked last, because it
must work on a pre-filtered list.

Also, let ConeEquivalentCallConflictResolver use
FirStandardOverrideChecker instead of compareCallsByUsedArguments
because it's stricter.

This all fixes a false positive overload resolution ambiguity in common
metadata compilation that is caused by stdlib using the new KMP
format.
Now stdlib metadata is in the classpath, and so declarations from the
stdlib are returned from both MetadataSymbolProvider and
KlibBasedSymbolProvider.
This isn't a problem per se because duplicate candidates are filtered
out by ConeEquivalentCallConflictResolver (K1 works analogously), but
in the case of top-level functions with generic receivers like
Collection<T>.toTypedArray, the check failed because of the direct
comparison of receiver types.

#KT-60943 Fixed
2023-08-11 10:54:24 +00:00
Nikolay Lunyak 4a9ba1c9ac [FIR] Expand typealiases when checking deprecations
^KT-59901 Fixed
2023-08-04 10:11:57 +00:00
Dmitrii Gridin 3b9b9327a4 [FIR] add debug info to CME from bounds
^KT-59007
^KT-60324
2023-08-04 08:12:50 +00:00
Leonid Startsev 7f795f212f Support instantiation of Java annotations with defaults
For annotations defined in Java, IrProperties do not contain initializers in backing fields,
as annotation properties are represented as Java methods.
Therefore, it is not possible to use initializer values as default values for constructor parameters.

However, K2 stores default values in annotation's constructor parameters,
so it is possible to fix this issue if they're properly transfered to the IR
and inspected in JvmAnnotationImplementationTransformer

#KT-47702 Fixed
#KT-47702 tag fixed-in-k2
2023-08-03 10:25:13 +00:00
Alexander Udalov 2b84463ec8 K2: remove dependency fir-deserialization -> metadata.jvm 2023-08-02 14:50:10 +00:00
Alexander Udalov bdd94dddaa K2: remove dependency fir-deserialization -> deserialization.common.jvm
Move FirConstDeserializer to fir:java.
2023-08-02 14:50:10 +00:00
Alexander Udalov 3e313bca78 K2: remove dependency fir-deserialization -> compiler.common.jvm
- Rename DeserializedClassConfigurator -> FirDeserializationExtension to
  abstract the existing behavior (about the Serializable supertype), as
  well as any future JVM-specific deserialization behavior.
- Rename JvmDeserializedClassConfigurator ->
  FirJvmDeserializationExtension and move it to fir:java.
2023-08-02 14:50:10 +00:00
Ivan Kochurkin 2eba7da5eb [FIR] Rename FirArrayOfCall to FirArrayLiteral 2023-07-27 17:53:44 +00:00
Dmitrii Gridin 480c794444 [FIR] drop redundant JavaTypeParameterStack usage from Java annotations
It is safe just to use `JavaTypeParameterStack.EMPTY`
as Java annotations are not expected to use containing type parameters

^KT-59342
2023-07-18 16:48:53 +00:00
Dmitrii Gridin 32ad4380b3 [FIR] make java annotation mapping lazily
to avoid contract violations from getDeprecation

^KT-59342 Fixed
^KT-60520
2023-07-18 16:48:53 +00:00
Ilya Kirillov 743662ec7f [FIR] remove user code leaks from compiler.fir.java module, add more information to some errors 2023-07-18 11:49:21 +00:00
Dmitriy Novozhilov 73b580572b [FE] Move @PrivateForInline optIn into :core:compiler.common
This is needed to be able to use it in backend modules too
2023-07-17 21:02:40 +00:00
Mikhail Glukhikh c350280e64 K2: fix enhancement building for Java methods with type parameters
Before this commit, we copied each type parameter during method
enhancement, while not copying the symbol. This led to symbol clashes
in MPP scenarios and various other problems.

Now we create a fully-functional type parameter copy in enhancement
and perform a substitution of old type parameters with new ones
in receiver type, value parameter types, return type,
and type parameter upper bounds.

#KT-59766 Fixed
#KT-59738 Fixed
2023-07-14 16:17:49 +00:00
Dmitrii Gridin b67b37cdb3 [FIR] FirJavaFacade: do not duplicate record constructor
The fresh version of intellij has all record-related declarations,
so an additional fake constructor leads to errors like
KTIJ-25364 (OVERLOAD_RESOLUTION_AMBIGUITY)

^KTIJ-25366 Fixed
^KTIJ-25364 Fixed
^KTIJ-25368 Fixed
^KTIJ-25370 Fixed
2023-07-13 09:21:38 +00:00
Denis.Zharkov e98890cece K2: Remove a bunch of unused declarations 2023-07-11 13:12:22 +00:00
Mikhail Glukhikh f8ca440e96 K2: resolve Java enum entries from the beginning (related to KT-59464) 2023-07-11 08:28:04 +00:00