Commit Graph

253 Commits

Author SHA1 Message Date
Svyatoslav Scherbina 7a2d761a7d Add minor improvements to psi2ir and IR utilities:
* Generate missing IR parameter declarations in external stubs
* Use origin = FAKE_OVERRIDE in external IR stubs for fake overrides
* Set .parent in external IR stubs
* Set .parent in IR generated by some utility methods
2018-03-02 15:41:48 +03:00
Dmitry Petrov 13a7270129 Generate type parameter declarations for property accessors
This requires "scoped" type parameter symbols, because in the ugly world
of descriptors property accessors have no type parameters of their own.
2018-03-02 14:35:35 +03:00
Dmitry Petrov ae7f60a96e Update IR testData after rebase on master 2018-02-28 10:35:13 +03:00
Dmitry Petrov b206bf199f Add type operand symbol for type operator expression 2018-02-28 10:35:13 +03:00
Dmitry Petrov e89047d2cc Generate super classes and overridden functions in proper scope
Such references require proper scope so that local symbols are bound.
Example:

```
fun <T> outer() {
    abstract class ALocal<S : T> {
        abstract fun bar()
    }

    class Local<S : T> : ALocal<S>() {
        override fun bar() {}
    }
}
```

Here local classes have type parameters with upper bounds depending on
function type parameters, and members overriding members in other local
classes.
2018-02-28 10:35:13 +03:00
Dmitry Petrov 02f01efaac Update testData 2018-02-28 10:35:13 +03:00
Dmitry Petrov e5295d0f78 Generate references to overridden declarations as a separate pass
NB currently it relies on overriddenDescriptors in a FunctionDescriptor,
thus maybe incorrect for transformed declarations.
2018-02-28 10:35:13 +03:00
Dmitry Petrov 8fbdf52d34 Chars are not promoted to Int on comparisons 2018-02-27 10:09:17 +03:00
Dmitry Petrov 4bb6c61a5a Don't generate enum entry initializers for 'expect enum class' 2018-02-27 10:08:12 +03:00
Dmitry Petrov 36128ba66f Don't generate primary constructor body for expect classes 2018-02-13 10:09:28 +03:00
Dmitry Petrov 5a85bf36a5 Check for type parameter supertypes in primitive numeric comparisons 2018-02-09 14:41:54 +03:00
Dmitry Petrov 5678b3d52a Handle nullable case in '==' with smart cast using safe call 2018-02-07 14:30:59 +03:00
Dmitry Petrov 00325ae539 Handle equality checks for 'when' and data classes 2018-02-07 14:30:59 +03:00
Dmitry Petrov 4776535205 Implement IR primitives for number comparisons in JVM BE 2018-02-07 14:30:59 +03:00
Dmitry Petrov bf18186045 More precise implicit cast generation
If an expression 'x' has a definitely non-null type 'T1',
and is used in position with an expected type 'T2',
cast 'x' to 'T2!!' (most common non-null type T*: T* <: T2).
2018-02-07 14:30:59 +03:00
Dmitry Petrov 9137e68d4e Implement special desugaring for numeric comparisons in PSI2IR
This introduces the following IR built-in functions required for proper
implementation of the number comparisons:

- ieee754Equals(T, T): Boolean,
    for each T in {Float?, Double?}

- less(T, T): Boolean
  lessOrEqual(T, T): Boolean
  greater(T, T): Boolean
  greaterOrEqual(T, T): Boolean
    for each T in {Int, Long, Float, Double}
2018-02-07 14:30:59 +03:00
Dmitry Petrov 6cb68531ae Minor: add missing "'" 2018-01-17 12:31:07 +03:00
Dmitry Petrov bba8168150 Add test for extension properties declaration in IR 2018-01-17 12:31:07 +03:00
Dmitry Petrov fdd000c94f Update testData to new format 2018-01-17 12:31:07 +03:00
Kirill Rakhman 8bc020f31b Fix modifier order in generated overriden functions
Fixes #KT-21600
2018-01-16 15:42:02 +01:00
Ilya Gorbunov 7efaa7cabc Allow delegating val properties to out-projected MutableMap
Change generic signature of MutableMap.getValue, use 'out @Exact V' and `V1: V` types instead of single `in V`.
Fix affected IR generation tests.

#KT-18789 Fixed
2017-12-07 20:26:53 +03:00
Dmitry Petrov c2b9803933 Generate source information for synthesized data class members
For now, bind such elements to data class declaration.

 #KT-20443 Fixed
2017-10-31 17:34:32 +03:00
Mikhail Zarechenskiy dc83e5ca3a Fix test which is correctly work in old inference 2017-08-07 18:01:17 +03:00
Mikhail Zarechenskiy 3fb865e07c Move test for NI to diagnostic tests and add "todo" 2017-08-07 18:01:16 +03:00
Dmitry Petrov c0d6eff97c [NI] Select variable with proper non-trivial constraint first 2017-08-07 18:01:05 +03:00
Dmitry Petrov 4963580f90 [NI] Take into account return without expression in lambdas 2017-08-07 18:00:47 +03:00
Dmitry Petrov a687dea898 Introduce special IrDeclarationOrigin's for for-loop variables
FOR_LOOP_ITERATOR
 - temporary variable for for-loop iterator

FOR_LOOP_VARIABLE
 - `x` in `for (x in xs)`

FOR_LOOP_IMPLICIT_VARIABLE
 - temporary variable for for-loop with destructuring, e.g.:
   for ((x, y) in xys)
   =>
   for (tmp in xys) {
     val (x, y) = tmp
   }
2017-07-13 10:59:51 +03:00
Dmitry Petrov ae71833a12 Use original descriptors for functions when generating stubs
Descriptors for builtin class members on JVM are substituted.
2017-06-27 13:00:10 +03:00
Denis Zharkov bc564af2fc Regenerate mockJDK using openJDK 7 2017-06-24 17:26:01 +03:00
Dmitry Petrov 2b3043bf9f Fix CFG problem for 'when' in Konan
If type of 'when' expression is 'Nothing', it should be kept that way
even if the expression itself is implicitly coerced to Unit.
2017-06-22 10:21:54 +03:00
Dmitry Petrov fd1866b838 Do not check argumentMapping.isError()
Argument matching status can be considered an "error" in resolve,
even though it is not a compilation error and doesn't prevent code
from being generated.
Actually, we should only check if the argument matching status is
ArgumentMatch.

 #KT-18294 Fixed
2017-06-06 10:19:18 +03:00
Dmitry Petrov 978661c53d Do not generate default parameter values for synthetic functions
This causes a subtle issue with 'copy' function for data class,
which has parameters with source elements corresponding to
the data class primary constructor parameters: default value expression
for such parameters is generated second time (to be overwritten later),
which creates duplicate bindings if such expression included any
(possibly anonymous) declarations, such as lambdas or anonymous objects.

 #KT-18208 Fixed
2017-06-02 10:57:45 +03:00
Dmitry Petrov 30182c38ce Fix toString and hashCode for array members of data classes
Generate them as special intrinsics that would be mapped to proper
platform-specific calls by BEs.

 #KT-16945 Fixed
2017-05-26 09:32:29 +03:00
Dmitry Petrov 1420926a9b Generate receivers for callable references in the same way as for calls
Properly handle callable members imported from objects
and other related corner cases.

 #KT-18084 Fixed
2017-05-26 09:32:29 +03:00
Dmitry Petrov bd5b984da9 Return type of local delegated property setter should be Unit
#KT-17950 Fixed
2017-05-22 11:47:09 +03:00
Dmitry Petrov 1dbd6453e0 Add more stub generator tests for external dependencies 2017-05-19 14:49:34 +03:00
Dmitry Petrov a2db4dc0d5 Fix incremental compilation problems related to type alias constructors
1. Determine source element for descriptors with NO_SOURCE recursively.

2. Always provide type abbreviation for type alias constructor
return type.

 #KT-15495 Fixed
2017-05-18 10:55:16 +03:00
Dmitry Petrov f5fde2c24f Dump absent type arguments 2017-05-05 09:59:30 +03:00
Dmitry Petrov ddb2b7508b Generate property initializer within property scope 2017-05-05 09:59:30 +03:00
Dmitry Petrov 8e84862afa Generate do-while condition within loop body scope 2017-05-05 09:59:30 +03:00
Dmitry Petrov fdb4de355c Use original descriptors to create symbols for callable references 2017-05-05 09:59:30 +03:00
Dmitry Petrov c2601c947f Postpone call arguments generation in compound assignment expressions
Otherwise RHS is generated twice, causing ISE in symbol binding
2017-05-05 09:59:30 +03:00
Dmitry Petrov d5feb2d6f4 Deep copy fixes + sanitize file names for module dumps 2017-05-04 13:51:17 +03:00
Dmitry Petrov 1eb693b8ee Transform variable-as-function calls for extension functions
In the following code example
  fun test(f: Any.() -> Unit) = 42.f()
front-end resolves variable-as-function call for 'f' as 'invoke'
with signature 'Function1<Any, Unit>#Any.() -> Unit'.
However, Function1<Any, Unit> has a single 'invoke' method
with signature 'Function1<Any, Unit>#(Any) -> Unit'.
This didn't cause any problems with loosely typed JVM and JS back-ends.
However, in IR with symbols this means a reference to non-existing
declaration.
2017-05-04 09:33:03 +03:00
Dmitry Petrov 0203ba4dff Use stable order when generating stubs for scope members 2017-05-04 09:33:03 +03:00
Dmitry Petrov 17706d0fb6 Generate parameter declarations for synthetic members of enum classes 2017-05-04 09:33:03 +03:00
Dmitry Petrov c4346f95ff Minor: fix testData format local delegated properties with 'suspend' 2017-05-04 09:33:03 +03:00
Dmitry Petrov 8b32d54a62 Minor: fix testData format for IR source range tests 2017-05-04 09:33:03 +03:00
Dmitry Petrov 78a601af87 Generate parameter declarations for fake overrides 2017-05-04 09:33:03 +03:00
Dmitry Petrov fa4dc26814 Put 'thisReceiver' declaration in class
Interfaces also have 'thisReceiver'
2017-05-04 09:33:03 +03:00