Commit Graph

2973 Commits

Author SHA1 Message Date
Alexander Udalov c6263ac8e6 Support isInitialized intrinsic for lateinit properties
See https://github.com/Kotlin/KEEP/pull/73

 #KT-9327 Fixed
2017-09-13 22:49:26 +03:00
Anton Bannykh 2249675e59 JS: throw exception when accessing uninitialized lateinit property (KT-14964) 2017-09-13 20:16:01 +03:00
Anton Bannykh 49bc9249a1 JS: add support for the ::foo syntax (callable reference with empty LHS) 2017-09-13 20:12:48 +03:00
Anton Bannykh 22dc36a596 JS: enable translation of primitive arrays to TypedArray's by default (KT-17137) 2017-09-13 18:45:19 +03:00
Alexander Udalov 296638a7c4 Minor, fix test after 60c735f2fd 2017-09-13 18:13:39 +03:00
Alexander Udalov 60c735f2fd Do not use deprecated kotlin.reflect API 2017-09-12 15:08:21 +03:00
Alexander Udalov 593d6b7a95 Minor, do not use ".java.kotlin" on KClass instances 2017-09-12 15:02:25 +03:00
Dmitry Petrov 6b6d1e80f8 Fix enum entry reference from enum entry initialization context
Enum entries are "special" kind of singletons that should be
referenced as a captured 'this' instance inside during entry
initialization, because corresponding static fields in enum class
are not initialized yet.

 #KT-7257 Fixed
2017-09-12 11:00:24 +03:00
Alexey Andreev 37fa45dc34 Add mechanism for type coercion in JS
Use it for char boxing/unboxing and unit materialization.
Possible to use for other purposes, for example, to add type checks
to dynamics.

See KT-18793, KT-17915, KT-19081, KT-18216, KT-12970, KT-17014,
KT-13932, KT-13930
2017-09-11 14:34:34 +03:00
Dmitry Petrov 66ece54b25 Fix initialization of inner class instances in enum entries
In an inner class of the enum entry class, enum entry reference should
be generated as an outer 'this', not as a enum entry access, because
enum entry itself may be not initialized yet.
2017-09-11 09:42:18 +03:00
Alexander Udalov 2877314313 Support "::foo" as a short-hand for "this::foo"
#KT-15667 Fixed
2017-09-08 10:59:44 +03:00
Mikhael Bogdanov 2fa4c28e0f Properly reorder arguments in anonymous object super class constructor
#KT-18356 Fixed
2017-09-07 15:18:05 +02:00
Dmitry Petrov 8c5d18c1f2 Tests for boxing optimization on KClass are JVM-specific 2017-09-06 14:20:05 +03:00
Dmitry Petrov 61faa068d4 Do not optimize == for KClasses in redundant boxing elimination
For primitive wrappers such as java.lang.Integer,
  jlc = java.lang.Integer.class
  jlt = java.lang.Integer.TYPE
  !(ljc.equals(ljt))
However, in Kotlin corresponding KClass instances are equal.

 #KT-17748 Fixed Target versions 1.1.50
 #KT-17879 Fixed Target versions 1.1.50
2017-09-06 09:54:36 +03:00
Dmitry Petrov 21cdf9dd5b Add cast to expected type in call-based in-expression generation
#KT-20106 Fixed
2017-09-05 15:32:53 +03:00
Mikhail Zarechenskiy e7449a3584 Fix referencing inner class constructor on an outer class instance
#KT-12796 Fixed
2017-09-05 14:41:44 +03:00
Dmitry Petrov 5d44e095c8 Nullability assertions for extension receiver
In Kotlin 1.1 and before, there were no nullability assertions on
extension receivers, because receiver is resolved with NO_EXPECTED_TYPE.
So, if an expression of platform type is passed as an extension receiver
to a non-private function, it would fail with IllegalArgumentException.
However, if the function is private, then we generated no parameter
assertions under assumption that such function can be called from Kotlin
only, and all arguments are checked on the call site. Thus 'null' could
propagate indefinitely.

In Kotlin 1.2, we do the following:
- Generate nullability assertions for expression receivers.
NB nullability assertions are stored for ReceiverValue instances, not
for expressions: given expression can act as receiver in different
calls, each with an expected receiver type of its own.
- Generate nullability assertions for extension receivers of private
operator functions.
NB it still can throw NPE for some particular "optimized" cases, but at
least those nulls would not propagate indefinitely.

This behavior is disabled by an "advanced" command-line option
'-Xno-receiver-assertions'.
2017-09-01 09:49:21 +03:00
Denis Zharkov ed79891ee6 Fix type mapping for parameter of Collection<Int>::remove override
In the case the single parameter of override has `Integer` type instead
of `int` type (while in common case it would be just `int`)

See the comment inside forceSingleValueParameterBoxing for clarification

 #KT-19892 Fixed
2017-08-31 12:38:08 +03:00
Denis Zharkov 80a90572d6 Fix target for annotations/metadata on open suspend functions
Get rid of rewriting of vars in FunctionCodegen::generateMethod,
just extracted generateMethodBody instead

 #KT-19814 Fixed
2017-08-31 12:27:28 +03:00
Dmitry Petrov c8d25c587a Do not use reflection it local/top-level lateinit tests 2017-08-31 11:28:08 +03:00
Dmitry Petrov bbf9bf91fc Check language feature support for local and top-level lateinit vars 2017-08-31 11:28:08 +03:00
Dmitry Petrov 01cce59c35 Make sure lateinit top-level properties work in JVM BE 2017-08-31 11:28:08 +03:00
Dmitry Petrov d0b0fdd732 Ignore lateinit local vars tests in JS and Native 2017-08-31 11:28:08 +03:00
Dmitry Petrov c5b9d500bc Support lateinit local vars in JVM BE 2017-08-31 11:28:08 +03:00
Denis Zharkov aef5911c7e Obtain original suspend function view for inline codegen
It's necessary for generic inline suspend as a codegen
for it uses binding slice SUSPEND_FUNCTION_TO_JVM_VIEW
to generate fake continuation parameter, so all the
descriptors that are used for body generation must be
obtained from the SUSPEND_FUNCTION_TO_JVM_VIEW

 #KT-19528 Fixed
2017-08-30 16:19:43 +03:00
Stanislav Erokhin 2ceb8cef36 [NI] Use same ResolvedCall when run completion
It is necessary, because some clients store this ResolvedCall to other
places, for example for get call it stored to INDEXED_LVALUE_GET
2017-08-25 03:38:49 +03:00
Mikhail Zarechenskiy f31c48017b [NI] Don't process lambda until expected type will be fixed 2017-08-25 02:47:46 +03:00
Mikhail Zarechenskiy 3f8a685ace [NI] Make return type of !! operator definitely not-null 2017-08-24 13:50:11 +03:00
Mikhail Zarechenskiy d18a14b717 [NI] Eliminate special intersection type from result type 2017-08-24 13:50:10 +03:00
Mikhail Zarechenskiy 9f2bf066b9 [NI] Transform anonymous types of expected type for delegation 2017-08-24 13:50:09 +03:00
Mikhael Bogdanov 1a05df204e Properly check expression nullability on attempt to apply == optimizations
#Fix KT-19767
2017-08-24 09:51:55 +02:00
Mikhail Zarechenskiy c45f86a2fc [NI] Resolve function literals in block as lambda expression 2017-08-23 15:53:52 +03:00
Mikhail Zarechenskiy 08964006de [NI] Avoid type capturing for types that can contain type variables 2017-08-23 15:53:51 +03:00
Stanislav Erokhin 9f71de5f66 Add test for lambda as last expression in lambda 2017-08-23 15:53:45 +03:00
Stanislav Erokhin 74e07b6580 Add regression test for no resolution recursion 2017-08-23 15:53:44 +03:00
Alexander Udalov 4d2fbf1801 Fix reflection for local delegated properties inside interface
#KT-19690
2017-08-17 15:35:11 +02:00
Mikhael Bogdanov 97d46e76f5 Use 'DefaultImpls' as owner for interface local delegated properties
#KT-19690 Fixed
2017-08-17 15:35:10 +02:00
Mikhael Bogdanov 6ca06265cf Rename and disable test on JS 2017-08-10 16:16:28 +02:00
Mikhael Bogdanov 3fd6dd3572 Add test for quoted class name 2017-08-10 12:10:25 +02:00
Denis Zharkov ff0736f09e Fix exception after combination of while (true) + stack-spilling
FixStack transformation divides on phases:
- Fixing stack before break/continue
- Fixing stack for inline markers/try-catch blocks

After the first stage all ALWAYS_TRUE markers are replaced
with simple GOTO's and if we're skipping break/continue edges
we won't reach the code after while (true) statement.

At the same time it's fine to not to skip them in the second phase
as the stack for them is already corrected in the first phase

 #KT-19475 Fixed
2017-08-08 18:52:21 +07:00
Denis Zharkov 45d5f6a950 Add test for obsolete issue
#KT-19467 Obsolete
2017-08-08 18:52:21 +07:00
Mikhail Zarechenskiy e7cd615450 [NI] Introduce type depth in CS calculator to avoid SOE 2017-08-07 18:01:13 +03:00
Mikhail Zarechenskiy cf75afba66 [NI] Fix type intersection for equal types 2017-08-07 18:01:12 +03:00
Mikhail Zarechenskiy 0d464f06d1 [NI] Consider CS as nullable if one of the types isn't subtype of Any
Note that this isn't fully correct, consider the following situation:

S : T, T : Any?
=> CS(S, T) = T, but for now it will be T?, which is reliable but not so specific as just T
2017-08-07 18:01:09 +03:00
Mikhail Zarechenskiy 39349abd39 [NI] Preserve name of parameters for functional types 2017-08-07 18:01:07 +03:00
Stanislav Erokhin d58c6e245f Minor. rename type parameters for debug purposes. 2017-08-07 18:00:43 +03:00
Dmitry Petrov 756f7d6e9c [NI] Fix tests (was a type checker bug, see KT-18380) 2017-08-07 18:00:38 +03:00
Dmitry Petrov 6facdcb7ea Minor: lambda arguments formatting 2017-08-07 18:00:20 +03:00
Dmitry Petrov f637ebe9ff Minor: formatting for lambda arguments 2017-08-07 18:00:14 +03:00
Dmitry Petrov 2ed5a5e368 'when' should use intrinsics for '=='
#KT-19029 Fixed Target versions 1.1.5
 #KT-18818 Fixed Target versions 1.1.5
2017-08-07 10:31:02 +03:00