Commit Graph

429 Commits

Author SHA1 Message Date
Simon Ogorodnik dfd0042a5b Do not create single element list if only one candidate 2019-07-08 16:59:50 +03:00
Mikhail Glukhikh f434248cb7 FIR property getter: take return type from property even if it's error 2019-07-08 16:59:45 +03:00
Mikhail Glukhikh d96c66adac FIR: partially implement invoke resolution 2019-07-08 16:59:37 +03:00
Mikhail Zarechenskiy 6eefea6715 Add tests for obsolete issues
#KT-32395 Obsolete (fixed in 42a5c488)
 #KT-32388 Obsolete (fixed in f3e4c9cd)
 #KT-32271 Obsolete (fixed in 60a0cf1)
2019-07-06 10:06:04 +03:00
Mikhail Zarechenskiy 515e666733 [NI] Fix exception on incomplete try/catch block
There was an inconsistency on creating PSI call and corresponding
 descriptor. See variable `catchBlocks` from visitor, it's created
 only if PSI elements are not null, but for descriptor parameters
 there wasn't such check

 #KT-32134 Fixed
 #EA-139748 Fixed
2019-07-01 12:59:37 +03:00
Alexander Udalov cf6ff8c6b3 Simplify implementation of TypeSystemCommonSuperTypesContext.typeDepth 2019-06-27 16:43:07 +02:00
Alexander Udalov 331f0291ce Minor, remove TypeSystemContext.isNotNullNothing
Use equivalent isNothing instead
2019-06-27 16:43:07 +02:00
Alexander Udalov c452934f5b Pull isNullableType and related extensions up into TypeSystemContext 2019-06-27 16:43:07 +02:00
Mikhail Zarechenskiy c77f18fbe6 [NI] Support callable references on qualified types with generics
#KT-32154 Fixed
2019-06-26 00:23:12 +03:00
Mikhail Zarechenskiy 60a0cf1fcc [NI] Fix exception: don't try to compute type depth on null type
#KT-32184 Fixed
2019-06-25 14:09:42 +03:00
Mikhail Zarechenskiy a26cf86af7 [NI] Fix exception: callable reference is used with an unresolved LHS
#KT-32187 Fixed
2019-06-25 14:09:38 +03:00
Mikhail Zarechenskiy bc0773b219 [NI] Capture receiver of invoke-based call
#KT-32133 Fixed
2019-06-25 14:09:34 +03:00
Nikolay Krasko beb1bc09d4 Update to 192.5118.30 2019-06-25 11:48:59 +03:00
Simon Ogorodnik 9d4fbf8cbd FIR: reuse scopeSession in call resolver & implicit typed ref resolution 2019-06-24 18:51:15 +03:00
Simon Ogorodnik bc7c822b74 FIR resolve: stop visiting receiver hierarchy during call completion 2019-06-24 18:51:14 +03:00
Mikhail Glukhikh d41c50d6cf FIR: support type inference for assignments, fix related lambda inference 2019-06-24 18:51:03 +03:00
Mikhail Glukhikh 48cea4b800 FIR: take expected type into account during inference
NB: this commit provokes some inference problems,
which are fixed by next commit about type inference for assignments
2019-06-24 18:42:52 +03:00
Mikhail Glukhikh 1e1f4d4472 ConeTypeContext: handle "recursive type alias" situation 2019-06-24 18:42:51 +03:00
Mikhail Glukhikh 152abbfb4c ConeTypeContext: handle star projection more correctly
See substitutionSupertypePolicy & testInnerTP in FIR smoke diagnostics
2019-06-24 18:42:29 +03:00
Mikhail Glukhikh ac730a693a FIR: don't count implicit built-in type as a kind of implicit type
Before this commit, implicit Unit type for function with body and
without type, implicit Boolean type for conditions etc. were 'implicit'
types and resolved types together.
Sometimes this could lead to hard-to-find issues in FIR resolve, because
'implicit' types are usually handled there as 'necessary to resolve'
which is wrong for such effectively-resolved types.
2019-06-24 10:13:26 +03:00
Mikhail Zarechenskiy f3e4c9cdb3 [NI] Don't avoid Nothing-like constraints if Nothing was in initial type
#KT-32081 Fixed
 #KT-32951 Fixed
2019-06-21 11:52:39 +03:00
Mikhail Glukhikh 4b2175c8f8 FIR: do not resolve constructors / initializers in implicit type mode 2019-06-20 23:43:04 +03:00
Denis Zharkov bf0781d790 FIR: Implement fast path for classes subtyping 2019-06-20 15:42:42 +03:00
Mikhail Glukhikh c8003518a5 FIR: set super type reference properly 2019-06-20 15:26:40 +03:00
Mikhail Glukhikh 65d14ff097 FIR: do not try to calculate annotation call type
Annotation type is used instead
2019-06-20 15:26:40 +03:00
Mikhail Glukhikh 54078c4e9c FIR resolve: support inferring property type from getter 2019-06-20 15:26:39 +03:00
Mikhail Glukhikh 16ead49967 FIR: implement backing field references via 'field' synthetic variable 2019-06-20 15:26:39 +03:00
Mikhail Glukhikh 11620d848b FIR resolve: set property accessor return type to initializer type 2019-06-20 15:26:39 +03:00
Mikhail Glukhikh 7e2828c276 FIR: provide error type for property/variable without initializer 2019-06-20 15:26:39 +03:00
Simon Ogorodnik 2995e9fcac FIR deserializer optimization: avoid calling findKotlinClass twice
This commit influences enum entries deserialization.
In particular, now we don't deserialize enum entry members,
but deserialize its supertype correctly (see test data changes).
2019-06-19 23:04:41 +03:00
Mikhail Glukhikh f4fefa042d Optimization: directly call transformChildren on FirExpression
This is done instead of calling super transformer function,
which does the same after several redirections to other functions.
2019-06-19 22:53:24 +03:00
Mikhail Glukhikh dab6fe29b1 Optimization: make property 'FirExpression.resultType' inline 2019-06-19 22:52:20 +03:00
Mikhail Glukhikh b71de954ff Forbid manipulations with FirWrappedArgumentExpression type reference
The type of this expression is bound to the type of wrapped expression,
so it's better not to change it directly.
2019-06-19 22:51:26 +03:00
Mikhail Glukhikh b7da2f2ad8 FIR resolve: check early receivers on kotlin.* only
To provide more stable behaviour, the check introduced in the previous
commit is now applied only to extensions from kotlin.* package.
2019-06-19 22:48:52 +03:00
Mikhail Glukhikh 374b59dee3 FIR resolve: add early explicit receiver type check
Before this commit, explicit extension receiver type check was performed
during found candidates analysis (together with arguments type check etc.)
Now we do it just after candidate is found, and filter the candidate
out if explicit receiver type is inappropriate.

This commit slightly changes resolve semantics,
replacing WRONG_RECEIVER with UNRESOLVED_REFERENCE in certain situations.
However, it provides significant performance boost.
2019-06-19 22:45:15 +03:00
Mikhail Zarechenskiy 796cdea50e [NI] Require all proper constraints for Exact return type
Consider call `foo(bar())` where bar() returns some type variable `T`;
 We had a contract that call `bar` can be completed without completion
 of foo (type variables can be inferred from the current context) if `T`
 has at least one proper lower constraint (ProperType <: T).
 Indeed, new constraints can be added only as upper ones, so there is
 no need to grow constraint system.

 Unfortunately, we have Exact annotation that is used on return type of
 elvis. Now, consider the following situation:
 ```
 fun foo(a: Any) {}
 fun bar(e: T): @Exact T

 foo(bar("str"))
 ```

 Here, because of Exact annotation, constraint with `Any`-type will be
 added as an equal one => our prerequisite that there will be no new
 lower constraints is false. `bar("str")` is inferred to Any in OI,
 this seems conceptually wrong, but it's another topic of discussion.

 In NI we can't just grow constraint system to use outer call because
 of another important use-case:
 ```
 fun <T> generic(i: Inv<T>) {}

 fun test(a: Inv<*>?, b: Inv<*>) {
     generic(a ?: b)
 }
 ```

 Common constraint system for these two calls can't be solved
 (fundamentally) for this example, only if (a ?: b) and generic(result)
 are computed separately.

 So, to mitigate initial issue, we'll grow constraint system only if
 there is at least one non-proper constraint.

 #KT-31969 Fixed
2019-06-19 11:07:31 +03:00
Mikhail Zarechenskiy ca997de6a7 [NI] Test data to understand changes in the next commit
##KT-31969 In Progress
2019-06-19 10:47:05 +03:00
Mikhail Zarechenskiy 7df13c986e [NI] Coerce to Unit expression in last block with explicit Unit
#KT-32037 Fixed
2019-06-18 19:38:02 +03:00
Denis Zharkov 9d02fe564c FIR: Avoid calling ClassId::asString from ConeTypeContext 2019-06-18 17:20:23 +03:00
Denis Zharkov f7d0be980b FIR: Optimize ConeTypeContext::isIntegerLiteralType
See ConeTypeContext::isIntegerLiteralTypeConstructor
2019-06-18 11:55:15 +03:00
Denis Zharkov 3c8ed21e59 Optimize ConstraintInjector::isMyTypeVariable
Do not look into the map for constructors that are not
type variables
2019-06-18 11:55:15 +03:00
Denis Zharkov 115ab38423 FIR: Optimize ConeTypeContext::captureFromArguments 2019-06-18 11:55:15 +03:00
Simon Ogorodnik 03c3469a14 [FIR] Enhance caches in providers 2019-06-18 11:33:11 +03:00
Simon Ogorodnik f88fafea9d [FIR] Use proper collections for override scope 2019-06-18 11:14:58 +03:00
Simon Ogorodnik 321e948eca [FIR] Improve typing to get rid of cast 2019-06-18 11:14:57 +03:00
Simon Ogorodnik 95409b35ca [FIR] Use abstract classes for FIR scopes 2019-06-18 11:14:56 +03:00
Simon Ogorodnik 810fa9c171 [FIR] Make session & symbolProvider abstract classes 2019-06-18 11:14:55 +03:00
Mikhail Zarechenskiy 7749afb13e [NI] Fix exception for type check callable reference against error type
#KT-32029 Fixed
 #EA-145311 Fixed
2019-06-17 19:18:04 +03:00
Mikhail Zarechenskiy 8fe632f52b [NI] Record DFI for callable reference arguments
#KT-31941 Fixed
2019-06-17 19:18:04 +03:00
Vyacheslav Gerasimov 5a39c637c2 Build: Fix intellij dependency leak from ir tree module 2019-06-13 21:03:55 +03:00