Commit Graph

6615 Commits

Author SHA1 Message Date
Alexander Udalov 9882e86ecb Don't render contents of enum entry classes in .txt tests, regenerate tests
They are irrelevant because cannot be accessed from the outside anyway
2015-08-28 21:11:06 +03:00
Alexander Udalov 89f3cfc704 Support parameter names for Java 8 classes in reflection
Also support specifying additional options to javac in codegen tests, which was
needed to compile Java sources with the "-parameters" option
2015-08-28 21:11:01 +03:00
Denis Zharkov e8f91e596c Adjust test data after fixes about generic nullability 2015-08-28 18:50:26 +03:00
Alexander Udalov 8d9618348d Move .java and .kotlin extension properties to kotlin.jvm
Delete the old ones in package kotlin.reflect.jvm because otherwise the code
using those functions will become red in a lot less meaningful way (overload
resolution ambiguity) than if they're deleted (unresolved import)

Based on the work originally done by @dnpetrov

 #KT-8380 Fixed
2015-08-27 08:19:50 +03:00
Dmitry Jemerov 4743a69d76 rename platformName annotation to jvmName 2015-08-25 15:40:46 +02:00
Alexander Udalov 7dcb690254 Additional tests on reflection calls 2015-08-24 01:29:58 +03:00
Alexander Udalov ccb58d8601 Minor, add some tests on get/set/name/instanceof for properties w/o reflection 2015-08-24 01:29:58 +03:00
Alexander Udalov 9095fa2844 Make PropertyMetadataImpl a data class
To allow property delegates to use property metadata as a key in the hash map,
and to improve debugging experience
2015-08-24 01:29:57 +03:00
Dmitry Jemerov 341f09afd3 rename platformStatic to jvmStatic 2015-08-21 16:59:05 +02:00
Valentin Kipyatkov 468919f5d9 Fixed codegen crash on use of protected synthetic extension property 2015-08-12 18:17:09 +03:00
Dmitry Petrov b59bf6227f unqualified super: should be able to invoke methods of Any without extra hassle
when Any is an implicit immediate superclass
2015-08-12 12:14:14 +03:00
Mikhail Glukhikh b2653ad1e9 Deprecated enum syntax removed: most compiler tests 2015-08-10 16:24:12 +03:00
Alexander Udalov d3e39812cb Support mapping of KType to j.l.reflect.Type 2015-08-07 00:55:35 +03:00
Alexander Udalov 49b689f883 Do not allow to assign null to a non-null property via reflection
This was already working for accessor-based properties because the assertions
were already generated into corresponding accessors, but for fields we must
manually check the value against null
2015-08-07 00:55:33 +03:00
Alexander Udalov 3091f2af3b Report argument number mismatch nicely on wrong 'call()' invocation
The default Java reflection message in such case is not very helpful: "wrong
number of arguments"
2015-08-07 00:55:32 +03:00
Alexander Udalov 9c522b4d49 Refactor property calls in reflection, fix some corner cases
- compute a FunctionCaller instance for getter and setter so that "call" only
  delegates to that FunctionCaller's "call", in the same way it's done in
  KFunctionImpl
- use RuntimeTypeMapper.mapPropertySignature to get the exact origin and
  signature of a property and its accessors. This makes unwrapFakeOverride call
  unnecessary and also fixes some cases like private Java fields
- temporarily drop custom range checks, will be re-added soon
2015-08-07 00:55:30 +03:00
Alexander Udalov a91729e041 Fix isAccessible for property accessors 2015-08-07 00:55:30 +03:00
Mikhail Glukhikh 5b31560808 x?.y is now nullable even if y is Unit + three tests + codegen test fix + source code fix #KT-7936 Fixed #KT-8347 Fixed 2015-08-05 12:26:01 +03:00
Valentin Kipyatkov 9150c53832 Fixed codegen for non-public SAM-adapters 2015-08-04 18:05:57 +03:00
Alexander Udalov 6878453d44 Support KClass.objectInstance for objects and companion objects 2015-08-03 23:33:21 +03:00
Alexander Udalov 2eb5201575 Introduce KAnnotatedElement and val annotations: List<Annotation> 2015-08-03 23:32:23 +03:00
Alexander Udalov d1e67805fc Fix supertypes for reflected Java classes, always include j.l.Object
equals/hashCode/toString had not appeared in Java classes' "members" because of
this
2015-08-03 23:06:15 +03:00
Alexander Udalov af9ae46f9a Minor, fix test on KParameter.index 2015-08-03 23:06:14 +03:00
Mikhail Glukhikh 4bd48c4796 Regular modifier checker implemented (initial version). A set of tests fixed accordingly.
Most of modifier diagnostic is expressed by REDUNDANT_MODIFIER, INCOMPATIBLE_MODIFIERS, REPEATED_MODIFIER, WRONG_MODIFIER_TARGET, WRONG_MODIFIER_PARENT.
A set of modifier diagnostics is not in use now (but not deleted yet).
2015-08-03 19:41:50 +03:00
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