Commit Graph

928 Commits

Author SHA1 Message Date
Ilya Chernikov 854127bcc8 Fix testdata after switching Kotlin to version 1.8
(see the previous commit with the same title for details)
2022-07-01 14:31:45 +02:00
Mikhail Glukhikh 38f4a35be2 FIR: introduce flexible types pretty rendering for no arguments case
#KT-52020 Fixed
2022-06-29 16:50:05 +00:00
Ilya Gorbunov 988446c4b1 Update builtins dumps for open ranges
#KT-52932
2022-06-28 00:08:09 +00:00
Dmitriy Novozhilov fcc5b804a8 [FIR] Add forgotten resolution of annotations on get class calls 2022-06-27 08:11:31 +00:00
Dmitriy Novozhilov ed8187109a [FIR] Fix forgotten level changes during building CFG for !! 2022-06-21 14:10:37 +00:00
Victor Petukhov fa7809cd80 [FE] Remove BuilderInference annotation from tests 2022-06-21 15:01:56 +02:00
Mikhail Glukhikh 065e852199 FIR: support more precise diagnostics about parameter names
#KT-52762 Fixed
2022-06-20 11:28:55 +00:00
Mikhail Glukhikh 9fbafc3eb9 Add test for KT-52762 2022-06-20 11:28:55 +00:00
Ivan Kochurkin 9f69ea1786 [FIR] Add TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM diagnostics, ^KT-52327 Fixed 2022-06-17 23:26:16 +00:00
Jinseong Jeon a2da690afd Test: add java source files as JavaSourceRoot
so that those can be properly populated in SingleJavaRootsIndex
2022-06-16 22:14:17 +02:00
pyos c2ae74c7cd FIR CFG: when unifying flows, group statements by assignment
Consider a function `run2` that has 2 lambda arguments called in place.
We don't know the order in which they're called, so here:

    var x: Any? = something
    run2(
      { x = null },
      { x as String },
    )
    // <--

it's not correct to simply `&&` the statements together, as that would
produce `x is Nothing? && x is String && x is Any?`. Instead, statements
should be grouped by assignment first, and different groups are `||`-ed.
This means in the above example we now get `x is Nothing? || (x is Any?
&& x is String)` == `x is String?`.
2022-06-15 20:05:50 +00:00
pyos 63b0708ed5 FIR CFG: join/unify data flow from postponed lambdas at each level
For example:

    foo(
        // `if` joins A & B
        if (condition)
            run { ... } // A
        else
            run { ... }, // B
        run { ... } // C
    ) // `foo` unifies `A & B` and `C`, so if it is not resolved itself,
      // further `if`s, `when`s, safe calls outside it, etc. continue
      // building the correct type predicate until the next completed
      // call.

^KT-44512 Fixed
2022-06-15 20:05:49 +00:00
pyos 755c54553a FIR CFG: add more KT-44512 related tests 2022-06-15 20:05:48 +00:00
Alexander Udalov 08f18c2940 Fix metadata deserialization for context receivers with type table
In DeserializedClassDescriptor and MemberDeserializer, only the
`contextReceiverTypeList` field was used, and not
`contextReceiverTypeIdList` which is used when `-Xuse-type-table` is
enabled. The convention is to use a bunch of utilities declared in
`protoTypeTableUtil.kt` which deal with both methods of reading types.
Also, simplify the deserialization code in FIR (which was correct for
some reason).
2022-06-15 16:45:30 +02:00
Dmitriy Novozhilov fb57e1ecd5 [FIR] Add two kinds of Java origin to distinguish source and library declarations 2022-06-07 14:12:23 +00:00
Roman Golyshev 166c771e1b [FIR IDE] Ensure resolve to CONTRACTS phase in ReturnTypeCalculator
If we want to analyse some function's call, we need to know about its
contracts, otherwise resolving the following code would be broken.
Computing return type of function is a prerequisite to using it in any
sensible way, so it's the best place to resolve it to CONTRACTS

KT-50733
2022-06-06 09:14:37 +00:00
Nikolay Lunyak ee58b52a3d [FIR] Fix false positive NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY 2022-06-02 13:47:29 +00:00
Nikolay Lunyak d7e8dc65f5 [FIR] Update smartcast tests 2022-06-02 13:47:25 +00:00
Roman Golyshev 01ce499bb2 [FIR] Unify some special names to make code more uniform 2022-06-01 00:11:17 +04:00
Denis.Zharkov c766f20554 FIR: Adjust override checker to definitely-not-nullable types
^KT-52201 Related
2022-05-19 16:54:05 +00:00
Denis.Zharkov bf96abeed1 FIR: Fix special members came from superclass
class JavaSuperClass {
  // members impls with special signature, but it doesn't override any Kotlin specials
}

class KotlinInterface {
   // special members
}

class JavaSubClass extends JavaSuperClass implements KotlinInterface {
   // we should obtain members from JavaSuperClass with their Kotlinish
   // signature, not the Java one
}
2022-05-19 16:54:00 +00:00
Denis.Zharkov f70ae2df3a FIR: Refine inference constraints when type variable in flexible position
That issue might be fixed via changing
TypeVariableMarker.shouldBeFlexible at ConeConstraintSystemUtilContext
but this and some other tricks have been added because of incorrect
handling of constraints where type variable has a flexible bound

^KT-51168 Fixed
2022-05-19 16:53:59 +00:00
Ivan Kylchik 51ccc32a3f Update test data after introducing IntrinsicConstEvaluation annotation 2022-05-18 21:19:57 +03:00
Roman Golyshev 254151d82c [FIR IDE] Use proper FirSessions in FirSupertypesResolution
Symbols might be from other modules, so we need to use corresponding
`FirSession`s; otherwise it would be impossible to query symbols
from `firProvider`

^KTIJ-21714 Fixed
2022-05-12 21:22:22 +04:00
Ilya Kirillov b5ad6f5db4 [analysis api] move analysis session classes to separate packages, use KtAnalysisApiInternals to mark internal API 2022-05-12 16:15:14 +02:00
Dmitriy Novozhilov 2796d21ec6 [FIR] Create snapshot of tower data context for postponed callable referneces
This fixes an issue if type of some implicit receiver was changed because
  of changed smartcast in outer scope

^KT-51228 Fixed
2022-05-12 12:15:31 +03:00
Roman Golyshev 1d5cb8ab75 [FIR] Get FirSession from declaration in ReturnTypeCalculatorWithJump
If the session is from the other module, it might not know about
FirFiles which are relevant for transforming and resolving the
declaration

^KT-52136 Fixed
2022-04-21 19:23:20 +00:00
Roman Golyshev 32fa2fc476 [FIR] Resolve receiver in qualified expressions with no selector
In qualified expression like `foo().`, selector expression is null.
Because of that the whole expression was marked as an error FIR
expression, and `foo()` part was not resolved at all (including
arguments and everything else).

This commit fixes the problem by providing receiver's FIR expression
as an underlying expression for error FIR expression. That way
it will be seen by all resolve transformers and will be successfully
resolved.

^KTIJ-21484 Fixed
2022-04-12 10:55:12 +00:00
Ivan Kochurkin 81b1ed9ad4 [FIR] Fix false positive RETURN_TYPE_MISMATCH in intellij ultimate 2022-04-07 21:03:08 +03:00
Denis.Zharkov 550d24f8c6 FIR: Introduce ContextFunctionTypeParams type attribute 2022-04-06 16:05:26 +00:00
Ivan Kochurkin c6f52893fb [FIR] Fix inconsistent RETURN_TYPE_MISMATCH and TYPE_MISMATCH reporting on functions and properties
^KT-51203 Fixed
2022-04-05 15:50:43 +00:00
Mikhail Glukhikh d01e6b61a3 FIR: don't report PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED in exp.cl.
#KT-51761 Fixed
2022-04-01 16:15:53 +03:00
Mikhail Glukhikh aaebb7a30e FIR: don't create delegated constructor call in expect
#KT-51756 Fixed
2022-04-01 16:15:53 +03:00
Mikhail Glukhikh b327f5c731 Substitute type variables properly in ConeOverloadConflictResolver
#KT-46187 Fixed
2022-03-23 09:54:46 +00:00
Mikhail Glukhikh 70366c3bcb FIR: forbid java.lang.String deprecated constructors #KT-51364 Fixed 2022-03-21 13:58:13 +00:00
Mikhail Glukhikh c051edcbee FIR: add visibility filtering for qualifier resolve #KT-51621 Fixed 2022-03-15 13:21:03 +00:00
Mikhail Glukhikh 3251c474a2 FIR: add test for KT-51621 (qualifiers conflict case) 2022-03-15 13:21:02 +00:00
Mikhail Glukhikh 6b53ac8367 FIR: forbid top-level destructuring declarations #KT-50468 Fixed 2022-03-15 13:08:18 +00:00
Mikhail Glukhikh 6ecc97575d FIR: make deeper recursive type alias expansion check (see KT-37000) 2022-03-15 13:08:18 +00:00
Dmitriy Novozhilov ade2307345 [FIR] Fix exponential analysis of augmented array access calls
^KT-50861 Fixed
2022-03-11 15:36:05 +03:00
Mikhail Glukhikh ebed224f82 FE 1.0: use TYPE_VARIANCE_CONFLICT deprecation factory 2022-03-03 12:57:04 +00:00
Dmitry Petrov 8576265108 Enable KotlinFunInterfaceConstructorReference in LV 1.7 2022-03-02 13:12:08 +03: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
Mikhail Glukhikh 981f8b1871 FIR: implement resolve of unqualified enum references in when
See KT-16768
2022-02-22 22:13:06 +03:00
Jinseong Jeon bb766a5235 RAW FIR: flatten if chains 2022-02-15 11:48:53 +03:00
Dmitriy Novozhilov aadfc59d0f [FIR] Complete delegated constructor calls without proper constructed type
This is needed to definitely complete arguments of such calls
2022-02-07 13:36:38 +03:00
Dmitriy Novozhilov 52b72a7dac [FIR] Implement Int -> Long conversions for literals and operators over them
^KT-38895
^KT-50996 Fixed
^KT-51000 Fixed
^KT-51003 Fixed
^KT-51018 Fixed
2022-02-07 13:36:36 +03:00
Denis.Zharkov adb9dfb256 FIR: Rework processing AugmentedArraySetCall
Previously (few commits earlier), it contained two versions
of receiver (lhs) generated separately for each desugaring version
that looked a bit redundant.

Now, at FIR building stage we just don't create desugaring sub-trees,
instead they are being built during bodies transformation and that seems
to be much convenient there, since we don't need to reverse-engineer
get-set-operator version to check if containing calls are successful
(as we just built those calls and retain them)

Semantically, this changes may only change how data flow works
for such statements (see changed compatibilityResolveWithVarargAndOperatorCall.kt)

^KT-50861 Relates
2022-02-01 13:12:49 +03:00
Mikhail Glukhikh 05d65275bf FIR u/s scope: choose most specific intersection member for override check
Before this commit we took just first intersection member for this check.
However it's quite bad, because we were dependent on supertype order.
Choosing the most specific member looks more consistent here.

#KT-50969 Fixed
2022-01-31 21:59:18 +03:00
Mikhail Glukhikh 1137e61fc8 FIR: add test for KT-50969 2022-01-31 21:59:15 +03:00