Commit Graph

4941 Commits

Author SHA1 Message Date
Dmitry Petrov 9bf0211152 KT-8408 Prohibit Array<T>::class for non-reified T 2015-07-30 12:18:29 +03:00
Alexander Udalov a0cc313156 Support class reference expression for reified type parameters
Also make KClass::java an intrinsic property.

Based on the work by @dnpetrov

 #KT-6976 Fixed
2015-07-30 12:18:28 +03:00
Alexander Udalov 628bb774fd Support class reference expressions without kotlin-reflect.jar in classpath
Currently not much you can do with them, but in the future '.java' extension
property will allow to get the Class instance from it.

Also introduce codegen tests with stdlib but without reflection in the
classpath.

Based on the work by @dnpetrov
2015-07-30 12:18:28 +03:00
Alexander Udalov a93484b457 Fix callable reference to member of generic class 2015-07-29 23:44:19 +03:00
Alexander Udalov ef4a5e78ed Catch IllegalAccessException in KFunction.call
Rename IllegalPropertyAccessException -> IllegalCallableAccessException
2015-07-29 21:36:51 +03:00
Alexander Udalov 262099c899 Fix KFunction.javaMethod for property accessors 2015-07-29 21:36:50 +03:00
Alexander Udalov 9c4ba711b8 Rename and implement KProperty.accessible -> KCallable.isAccessible 2015-07-29 21:36:49 +03:00
Alexander Udalov 8f0885ca03 Rename KClass.properties and extensionProperties: prepend 'member'
To better emphasize the fact that all returned properties require an instance
of the class they are declared in. Another issue was that
'Some::class.extensionProperties' was sometimes incorrectly perceived as
"get all extension properties available on the class Some"
2015-07-29 21:36:47 +03:00
Alexander Udalov 7fc499df46 Support KClass.primaryConstructor 2015-07-29 21:36:46 +03:00
Alexander Udalov e079b8f425 Support KCallable.call
#KT-2187 Fixed
2015-07-29 21:36:42 +03:00
Alexander Udalov 936bede8b1 Support mapping between Kotlin functions and JVM methods/constructors 2015-07-29 21:36:41 +03:00
Alexander Udalov 93656c93c1 Support KPackage.members, functions and properties 2015-07-29 21:36:40 +03:00
Alexander Udalov 6ab1c6bfb3 Add KParameter.type, KType, KType.isMarkedNullable 2015-07-29 21:36:38 +03:00
Alexander Udalov 81ef1c19d8 Support KClass.constructors in reflection 2015-07-29 21:36:37 +03:00
Alexander Udalov da5cffdb60 Support KClass.functions and declaredFunctions 2015-07-29 21:36:36 +03:00
Alexander Udalov 50dbda1e1a Introduce KClass.members, make properties/extensionProperties extensions
To avoid significant growth of KClass and KPackage interfaces
2015-07-29 21:36:36 +03:00
Alexander Udalov 2492977274 Additional tests on reflection for Java methods 2015-07-29 21:36:35 +03:00
Alexander Udalov 5962b79126 Support introspection of parameter names and indices in reflection 2015-07-29 21:36:34 +03:00
Alexander Udalov 87c70aa2ae Make Class<*>.kotlinPackage nullable 2015-07-29 21:36:33 +03:00
Dmitry Petrov a64f1a86c0 Fix KT-8608: Compiler crashes with assertion Restore stack is unavailable
- fix SAVE_STACK_BEFORE_TRY insertion:
  TRYCATCHBLOCK LA, LB, LC
  LA
    NOP
    try_body
  LB
    ...
  LC
    handler_body
should be transformed into:
  LA
    {SAVE_STACK_BEFORE_TRY}
  LA' // new TCB start label
    NOP
    try_body
  LB
    ...
  LC
    handler_body
with all TCBs start labels remapped

- properly wrap exceptions from MandatoryMethodTransformer

 #KT-8608 Fixed
2015-07-27 10:40:14 +03:00
Ilya Gorbunov 8892192e9c Generate openRange tests for compiler.
#KT-4665
2015-07-24 04:13:53 +03:00
Pavel V. Talanov 4e0d2bc23c CompileTimeConstantUtils: use getConstant instead of evaluate
Hacky way to avoid passing builtins into this code
2015-07-21 20:52:43 +03:00
Dmitry Petrov 6437a4bdc6 Support overload ambiguity resolution for callable references by expected type.
Resolve callable references taking into account expected callable types.

This affects call resolution procedure (resolve 'foo' in for 'foo(::bar)') similar to the approach used for function literals:

* During "shape arguments" phase of call resolution, callable references are resolved in independent context without expected type. If the callable reference is ambiguous, its shape type is a function placeholder type without parameter types and return type information. Otherwise, it is a reflection type for the resolved function or property. Upper-level call is resolved without taking into account ambiguous callable references.

* During "complete call" phase of call resolution, resolve callable reference arguments to actual descriptors (if possible), and update constraint system for the given call accordingly.

 #KT-6982 Fixed
 #KT-5780 Fixed
2015-07-21 18:33:15 +03:00
Denis Zharkov 3ec00114c0 Check type of elvis with expected type info
#KT-6713
2015-07-21 15:16:06 +03:00
Valentin Kipyatkov 1c52f8a524 Fixed synthetic properties for method inherited from two bases 2015-07-21 08:32:51 +03:00
Valentin Kipyatkov 612c009f6b Synthetic properties: correct behaviour for method hierarchies 2015-07-21 08:32:51 +03:00
Valentin Kipyatkov 08754b9fc0 Support for synthetic extensions in codegen 2015-07-16 13:49:13 +03:00
Pavel V. Talanov c313887641 Split CompileTimeConstant into two entities
1. ConstantValue
	* just holds some value and its type
	* implementations for concrete constants
2. CompileTimeConstant
	* is only produced by ConstantExpressionEvaluator
	* has additional flags (canBeUsedInAnnotation etc)
	* has two implementations TypedCompileTimeConstant containing a constant value
		and IntegerValueConstant which does not have exact type
	* can be converted to ConstantValue

Adjustt usages to use ConstantValue if flags are not needed
Add tests for some uncovered cases
2015-07-16 02:28:05 +03:00
Denis Zharkov d19cb747be Emit not-null assertions for enhanced types 2015-07-15 10:01:14 +03:00
Mikhail Glukhikh 0d2a81f098 Annotation target checking in front-end, a set of tests for different annotation targets, existing test fixes
No checks for erroneous annotations. Additional checks for identifiers.
2015-07-14 16:25:04 +03:00
Mikhail Glukhikh 609d696202 Annotations have now retention of "RUNTIME" by default. Java retention is generated as given by kotlin annotation. Annotation rendering changed.
Annotation arguments with default values are rendered as ... if renderDefaultAnnotationArguments is true.
Tests: java retention does not taken into account by Descriptor comparator.
Java retentinon changed to kotlin retention in some tests + one new test with java retention added.
More accurate tests for intentions in byte code (visibility controlled).
2015-07-14 16:25:01 +03:00
Ilya Gorbunov 4ad6a8e301 Ensure type of a stack value is coerced to the expected return type after the binary operation instruction with the different return type. 2015-07-13 17:27:37 +03:00
Alexander Udalov 4de2c5a5c8 Don't generate default no-args constructor for enums
#KT-8438 Fixed
2015-07-13 11:59:35 +03:00
Alexander Udalov 290983687d Fix generation of bridges for lambdas
#KT-8447 Fixed
2015-07-10 20:10:16 +03:00
Dmitry Petrov d540ff8890 KT-8206 java.lang.NoSuchFieldError: $kotlinClass for deprecated::class
Instantiate class literals for annotation classes as foreign.
2015-07-10 20:10:15 +03:00
Alexander Udalov 16b5b95556 Test equals/hashCode/toString for function references 2015-07-10 20:10:14 +03:00
Alexander Udalov 3b2be6212d Add some tests on Java property references 2015-07-10 20:10:13 +03:00
Alexander Udalov 4f1247f03f Support property getters/setters in reflection 2015-07-10 20:10:10 +03:00
Alexander Udalov 048a9b686e Generate separate anonymous class for each property reference
Each property reference obtained by the '::' operator now causes back-end to
generate an anonymous subclass of the corresponding KProperty class, with the
customized behavior. This fixes a number of issues:

- get/set/name of property references now works without kotlin-reflect.jar in
  the classpath
- get/set/name methods are now overridden with statically-generated property
  access instead of the default KPropertyImpl's behavior of using Java
  reflection, which should be a lot faster
- references to private/protected properties now work without the need to set
  'accessible' flag, because corresponding synthetic accessors are generated at
  compile-time near the target property

 #KT-6870 Fixed
 #KT-6873 Fixed
 #KT-7033 Fixed
2015-07-10 20:10:09 +03:00
Alexander Udalov 30794060a9 Simplify property hierarchy in reflection
Leave only 3*2 = 6 classes: KProperty0, KProperty1, KProperty2 and their
mutable analogs, depending on the number of receivers a property takes
2015-07-10 20:10:09 +03:00
Alexander Udalov c3b97e0668 Simplify function hierarchy in reflection
Get rid of all classes except kotlin.reflect.KFunction, which will be used to
represent all kinds of simple functions.

Lots of changes to test data are related to the fact that KFunction is not an
extension function (as opposed to KMemberFunction and KExtensionFunction who
were) and so a member or an extension function reference now requires all
arguments be passed to it in the parentheses, including receivers. This is
probably temporary until we support calling any function both as a free
function and as an extension. In JS, functions and extension functions are not
interchangeable, so tests on this behavior are removed until this is supported
2015-07-10 20:10:08 +03:00
Alexander Udalov 3549e1e035 Add KFunction.name, support reflection for function references
#KT-7694 Fixed
2015-07-10 20:10:07 +03:00
Alexander Udalov bc168c0cba Support KClass.jvmName = java.lang.Class.getName() 2015-07-10 20:10:07 +03:00
Alexander Udalov 236214305f Support KClass.qualifiedName for non-local classes 2015-07-10 20:10:06 +03:00
Svetlana Isakova 086e69e132 Added tests for obsolete tasks 2015-07-10 15:05:07 +03:00
Denis Zharkov a218c1359f Adjust testData: JDK collections behave like non-platform in backend
Some of that changes looks like regression and should be fixed soon
2015-07-09 16:36:48 +03:00
Denis Zharkov 00e41fc238 Fix testData after types enhancement 2015-07-09 16:36:45 +03:00
Denis Zharkov cfadda8061 Fix codegen tests after types enhancement 2015-07-09 16:36:44 +03:00
Yan Zhulanow 74f44dddb0 Add tests for publicField 2015-07-07 16:35:23 +03:00
Dmitry Petrov 4e42cc6b81 Save/restore stack in try-expressions (and statements).
Parse TryCatchBlockNode's in generated bytecode, infer stack save/restore points.
Save stack to local variables before 'try'.
Restore stack after the beginning of try-block, catch-block, and default handler.
Integrate before/after inline markers rewriting (otherwise it'll break our stacks).

 #KT-3309 Fixed
2015-07-07 12:16:29 +03:00