Commit Graph

585 Commits

Author SHA1 Message Date
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 046c82ab60 FIR: remove unused utility function 2019-06-24 18:51:13 +03:00
Simon Ogorodnik 0e60af95bf Optimization: make every FIR node extend FirPureAbstractElement 2019-06-24 18:51:12 +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 cafe92639b [FIR] Output total time & set passes in old FE performance test 2019-06-20 15:26:40 +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 ca401cb01d FIR2IR: support backing field symbols from FIR, fix test data 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 b3c21d6e14 Optimize FirClassSymbol.hashCode() 2019-06-19 22:54:14 +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 688c2cf74f Optimization: make FIR expression an abstract class
NB: this commit does significant fir:tree refactoring.
It provides some boost due to faster abstract class dispatching in JVM.
2019-06-19 22:52:44 +03:00
Mikhail Glukhikh dab6fe29b1 Optimization: make property 'FirExpression.resultType' inline 2019-06-19 22:52:20 +03:00
Mikhail Glukhikh f6f879302f Optimization: make FirFunctionCall an abstract class 2019-06-19 22:52:13 +03:00
Mikhail Glukhikh d85ad650d5 Optimization: make FirWrappedArgumentExpression an abstract class 2019-06-19 22:52:04 +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 2c5bd46a97 [FIR] Handle non-kotlin class results from findKotlinClassOrContent 2019-06-18 11:36:42 +03:00
Simon Ogorodnik 2f53bd24dd [FIR] Reorder providers to make builtins load first 2019-06-18 11:34:18 +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
Simon Ogorodnik 5a06027c53 [FIR] Avoid instanceof List in transformInplace 2019-06-18 11:14:54 +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
Denis Zharkov fdebb38706 Disable slow assertions in type checker everywhere except for tests 2019-06-17 10:29:23 +03:00
Vyacheslav Gerasimov 5a39c637c2 Build: Fix intellij dependency leak from ir tree module 2019-06-13 21:03:55 +03:00
Mikhail Zarechenskiy d9dca067f6 [NI] Propagate non-null info on supertypes for capturing from bounds
#KT-31941 Fixed
2019-06-13 00:57:51 +03:00