Commit Graph

188 Commits

Author SHA1 Message Date
Dmitry Petrov 2a97fb17ba Fix source information mapping in PsiSourceManager
Add tests for source information mapping

KT-17108 source information corrupted on PSI -> IR transformation
2017-03-29 13:03:38 +03:00
Dmitry Petrov fc38479f48 References to enum entries should be always generated as GET_ENUM 2017-03-24 10:06:10 +03:00
Dmitry Petrov 64013171e8 KT-16905 Wrong IR for call to inner class constructor through typealias 2017-03-24 10:06:10 +03:00
Dmitry Petrov d05de88e3e KT-16904 Wrong IR when applying some operators to superclass properties in constructor
Use property accessors for assignment generation for inherited properties in constructor.
2017-03-24 10:06:10 +03:00
Igor Chevdar 10ea2883f7 Supported KProperty2 and KMutableProperty2 for delegated properties
Consider this code:
object Delegate {
    operator fun getValue(t: Any?, p: KProperty<*>): String {
        return ""
    }
}

class A {
    val String.ext by Delegate
}

then the type of <p> is KProperty2 (it has 2 receivers).

Test fix + review fixes
2017-03-15 12:20:57 +03:00
Dmitry Petrov d096f1d381 'while' and 'do-while' loop generator fixes.
Generate 'do-while' loop body as IrComposite, because variables declared
in loop body should be visible in loop condition.
Wrap 'do-while' loop in IrBlock so that variables declared in loop body
are not visible outside of the loop.

Generate 'while' and 'do-while' loops as expressions of type Unit.
2017-03-07 11:56:52 +03:00
Dmitry Petrov cb61c358ea Always generate primitive boolean constants as expressions of type 'kotlin.Boolean'. 2017-03-07 11:56:52 +03:00
Dmitry Petrov 1bbbc1ca1c KT-16684 hashCode doesn't check data class property value of generic type for null 2017-03-07 11:56:52 +03:00
Dmitry Petrov 6bc6c1b6cc KT-16671 Calls to members imported from objects should be desugared in PSI2IR 2017-03-07 11:56:52 +03:00
Dmitry Petrov 4ba8268a29 KT-16669 Exception in PSI2IR on type alias constructor in supertypes list 2017-03-07 11:56:52 +03:00
Dmitry Petrov e4683a1e9f KT-16666 IMPLICIT_INTEGER_COERCION expression should have non-nullable type 2017-03-07 11:56:52 +03:00
Dmitry Petrov 8c32719f3d Render 'type' for IrTypeOperatorCall expressions, update testData. 2017-03-07 11:56:52 +03:00
Dmitry Petrov 8e8f83656f KT-16618 IMPLICIT_INTEGER_COERCION isn't generated for global properties and default parameters 2017-03-07 11:56:52 +03:00
Dmitry Petrov 634d9834de Wrong receiver is generated for variable-as-function call on object.
Move 'generateExpressionForReferencedDescriptor' to CallGenerator,
use it in 'generateCall',
add PSI-free versions of some utility methods so that call elements can
be generated when we're already deep in ResolvedCall generation
and have forgotten about PSI.
2017-03-03 10:15:59 +03:00
Dmitry Petrov f636ab21f8 Use proper descriptor for (generic) property assignment.
Insert IMPLICIT_INTEGER_COERCION only if Int is coerced to an integer type.
2017-03-02 14:25:58 +03:00
Dmitry Petrov 97fbbc74e6 KT-16440 ClassConstructorDescriptorImpl has null returnType
Set constructor return type in FunctionDescriptorResolver#createConstructorDescriptor
(it seems to be the only place where ClassConstructorDescriptorImpl#initialize(...)
is called, but returnType is not set).
2017-03-02 14:25:58 +03:00
Dmitry Petrov 9baaf607a3 KT-16566 Support destructuring declarations for lambda parameter in psi2ir 2017-03-02 14:25:58 +03:00
Dmitry Petrov c226707a80 KT-16554 Local function with default arguments have no IR elements for them 2017-03-02 14:25:58 +03:00
Dmitry Petrov dd61a5b2c6 KT-16553 Underscore variable values shall not be evaluated
Do not generate 'componentN' calls for '_' in destructuring assignment.
2017-03-01 09:25:38 +03:00
Dmitry Petrov 63b16e14d8 KT-16536 Wrong IR generated for '++x'
Make psi2ir confirm to JVM BE behavior for prefix increment/decrement.
TODO reconsider after design decision (in 1.2?).
2017-03-01 09:25:38 +03:00
Dmitry Petrov 885f397cdd KT-16535 'provideDelegate' convention is not supported in IR
Implement provideDelegate convention support.
NB delegate type now depends on 'provideDelegate' convention resolution.
2017-03-01 09:25:38 +03:00
Dmitry Petrov e66c2621af KT-16436 Incorrect primitive constants handling
Expression '1.unaryMinus()' is resolved as Int::unaryMinus call with Int receiver.
However, this expression is implicitly coerced to a different integral type (Byte, Short, Long)
based on results of constant evaluation.

Introduce IMPLICIT_INTEGER_COERCION type operator to handle such cases.

TODO: should we use it for simple constant expressions like '1' and '-1'?
2017-03-01 09:25:38 +03:00
Dmitry Petrov d0134f2c64 KT-16437 Incorrect type inference for some when coerced to Unit
If the result of 'when' is not used in an expression,
this 'when' expression has type 'Unit' despite of whatever FE has inferred.
2017-03-01 09:25:38 +03:00
Dmitry Petrov e2e57e5b6d KT-16439 Generated methods of data classes have no expression for default arguments
Provide default argument expressions for generated 'copy' declaration.
2017-03-01 09:25:38 +03:00
Dmitry Petrov 0f1f354ba6 KT-16486 Strange IR for delegated members
Delegated implementations should refer to delegate field:
  $this: GET_FIELD <delegate_field> ...
    receiver: <this_for_containing_class>
2017-03-01 09:25:38 +03:00
Dmitry Petrov de14d4abc8 KT-15748 Type alias constructor return type should have a corresponding abbreviation 2017-01-27 15:16:04 +03:00
Dmitry Petrov ee9a174c1f KT-7897 Do not require to call enum constructor for each entry if all parameters have default values
Do not report an error on enum entry without initializer if all parameters have default values
(error is still reported if there is no such constructor, or if the constructor call is ambiguous).

Record resolved call on KtEnumEntry.

NB is the enum entry has a corresponding subclass, we still have to generate the "default" constructor call,
because FE doesn't know about the platform-specific representation of that class and its constructors.

See also KT-14097, KT-15900
2017-01-24 16:59:47 +03:00
Ilya Gorbunov dcd7f3eb57 Fix test data after introducing overloads #KT-15630 2017-01-11 14:33:17 +03:00
Svyatoslav Scherbina 4c3fb9a21f psi2ir: improve backing field usage generation
Also update corresponding tests data.
2017-01-11 14:54:10 +07:00
Dmitry Petrov d9271b54fb Fix IR generation: temporary variable in 'hashCode()' for data class should be 'var' 2016-12-23 10:44:14 +03:00
Dmitry Petrov 33ed98a0d3 Update typing rules for class literal expressions.
C::class : KClass<C>
expr: T => expr::class : KClass<out T>

NB: this means Obj::class : KClass<out Obj> for object Obj.
2016-12-19 10:41:49 +03:00
Mikhail Zarechenskiy 62ac91a121 Add operator 'rem' to builtIns
Also deprecate operator 'mod'
2016-12-14 15:29:00 +03:00
Dmitry Petrov 4c47d77a9f Report error on non-top-level type aliases (unsupported in 1.1).
Get rid of nested type aliases in project.
2016-11-21 10:25:51 +03:00
Dmitry Petrov 4fc135709e Inner classes lowering: remap old constructor parameters. 2016-10-21 10:05:41 +03:00
Dmitry Petrov 7dce1f438f Inner classes lowering. 2016-10-19 19:13:40 +03:00
Michael Bogdanov 20c4f47253 Properly lower ImplicitClassReceiver 2016-10-18 09:10:19 +03:00
Dmitry Petrov fb5298237a Shared variables lowering. 2016-10-18 09:10:16 +03:00
Dmitry Petrov fedfd3de16 Suggest names for captured receivers. 2016-10-18 09:10:15 +03:00
Michael Bogdanov b72d7557d1 KClassJavaProperty support 2016-10-18 09:10:13 +03:00
Dmitry Petrov 5ee2f87c4a Closure conversion: simple tests work. 2016-10-18 09:10:12 +03:00
Michael Bogdanov e543972dad Properly calculate safe call receivers 2016-10-18 09:10:05 +03:00
Dmitry Petrov a51efaacc9 Introduce IrGetValue as a replacement for IrThisReference / IrGetExtensionReceiver / IrGetVariable. 2016-10-18 09:09:59 +03:00
Dmitry Petrov 608d6a37d2 Some enum-related fixes
(NB: testEnumClass3 doesn't work yet, effective modality required for enum class)
2016-10-18 09:09:57 +03:00
Dmitry Petrov f423369327 Objects (singletons) lowering. 2016-10-18 09:09:56 +03:00
Dmitry Petrov fc754e533d Enum classes lowering. 2016-10-18 09:09:55 +03:00
Michael Bogdanov f30027b4de Generate ir-accessors for interface properties 2016-10-18 09:09:53 +03:00
Dmitry Petrov 7950235df3 Lowering for constructors & initializers. 2016-10-18 09:09:52 +03:00
Mikhail Glukhikh 07eae1d206 IR to CFG: type operator unrolling 2016-10-18 09:09:50 +03:00
Mikhail Glukhikh ea13386d0b IR to CFG: member access unrolling 2016-10-18 09:09:50 +03:00
Mikhail Glukhikh 5a04c72e75 Break / continue implementation, test with break / continue, related changes in loop & loop tests 2016-10-18 09:09:49 +03:00