Commit Graph

94 Commits

Author SHA1 Message Date
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
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
Alexander Udalov 4d2fbf1801 Fix reflection for local delegated properties inside interface
#KT-19690
2017-08-17 15:35:11 +02:00
Dmitry Petrov 756f7d6e9c [NI] Fix tests (was a type checker bug, see KT-18380) 2017-08-07 18:00:38 +03:00
Alexander Udalov 2611c7de7e Restore anonymous classes for local delegate metadatas in inline functions
The problem is that now that the local delegated property metadata is in
the $$delegatedProperties array of the containing class, the access to
it from code calling an inline function with a local delegated property
is illegal.

Currently it seems to be a lot of work to support this rather rare case
properly (see the comment in ExpressionCodegen.getVariableMetadataValue)
so we postpone it and return the old behavior of using the anonymous
KProperty subclass for metadata
2017-07-14 15:13:12 +03:00
Alexander Udalov 616d575fb6 Support reflection for local delegated properties
#KT-15222 Fixed
2017-07-14 15:13:12 +03:00
Alexander Udalov 233b63469a Fix IllegalAccessException on private annotation in reflection
#KT-14094 Fixed
2017-06-21 15:43:00 +03:00
Alexander Udalov 6388c1885c Fix KCallable.call for protected members from base class
Class.getMethod does not return protected methods from super class, so
we invoke getDeclaredMethod on each super class manually instead

 #KT-18480 Fixed
2017-06-21 15:42:59 +03:00
Alexander Udalov 8ef3531c48 Add kotlin.Any to KClass.superclasses if it's absent
#KT-18476 Fixed
2017-06-20 14:39:48 +03:00
Alexander Udalov 90f2ea87a6 Fix exception on callBy of callable with more than 32 parameters
The previous condition that checked if we'd skipped any optional
parameters didn't work when number of parameters > 32 because the number
of bit masks in that case was more than one

 #KT-18404 Fixed
2017-06-20 14:39:47 +03:00
Mikhail Zarechenskiy a0d7b703f4 Align generic signature for inner classes to work as in Java
#KT-10397 Fixed

According to JVMS (p. 4.3.4) inner classes should be separated with `$` in generic signature.

Note that in Java, inner types separated with `.` after first parameterized type, and now we preserve the same behaviour. See tests for clarification.
2017-04-27 15:47:28 +03:00
Alexander Udalov dc3aa26e3f Ignore getMembersOfStandardJavaClasses light analysis test
See #KT-16616
2017-03-22 14:33:57 +03:00
Mikhael Bogdanov 496a21254b Black box update 2017-03-20 18:46:01 +01:00
Ilya Matveev 29e5ad5abe Mute tests with '::class' in native backend 2017-03-10 19:59:37 +03:00
Ilya Matveev a5e4e0284e Mute some box tests for native backend
This patch mutes the following test categories:
   * Tests with java dependencies (System class,
     java stdlib, jvm-oriented annotations etc).
   * Coroutines tests.
   * Reflection tests.
   * Tests with an inheritance from the standard
     collections.
2017-03-10 19:59:37 +03:00
Denis Zharkov 52d11eb22b Minor. Revert workarounds for problem on KClass from annotation
See KT-9453 for clarification
2017-03-10 13:49:07 +03:00
Alexey Andreev ef38761dc2 JS: unmute now passing tests and mute test that passed by accident. 2017-03-07 10:46:09 +03:00
Denis Zharkov 6fb83c2ba3 Force wrapping java classes from annotation methods into KClasses
Before this change such wrapping happened only during coercion,
i.e. when a call-site expected a KClass instance.

But when call-site expects Any, for example, no wrapping happened,
and raw j.l.Class instance was left on stack.

The solution is to put wrapping code closer to generation of annotation's
method call itself to guarantee that necessary wrapping will happen.

 #KT-9453 Fixed
2017-03-02 15:19:09 +03:00
Alexander Udalov 7147008e21 Fix functionFromStdlib.kt by making the member accessible
#KT-16263 Open
2017-02-09 14:56:27 +03:00
Alexander Udalov ccbfa2e81d Fix Member.getKPackage and temporarily revert functionFromStdlib.kt 2017-02-08 20:02:49 +03:00
Alexander Udalov 6d16ea0a3a Fix reflection on top level declarations from other modules
The main problem here is that moduleName that is being passed to KPackageImpl
is useless: as can be seen in
ClosureCodegen.generateCallableReferenceDeclarationContainer, the name of the
current module is always written to the class file for a callable reference,
not the name of the module of the referenced declaration. This resulted in
reflection not loading the correct .kotlin_module file and subsequently not
finding the required file facade for a top-level function.

The commit does not fix the issue with the incorrect module name written in the
back-end, but workarounds it. It turns out, reflection can figure out the name
of the module of the referenced declaration itself by parsing the header from
the given java.lang.Class object for a single-file/multi-file package facade
and extract the package_module_name protobuf extension. Similar code was
already there in Member.getKPackage() in ReflectJvmMapping.kt but it did not
support multi-file classes, of which there are a lot in the standard library;
this is now supported

 #KT-12630 Fixed
 #KT-14731 Fixed
2017-02-08 19:23:18 +03:00
Alexander Udalov cfe159181d Deprecate kotlin.reflect.findAnnotation with ERROR 2017-02-08 13:05:27 +03:00
Alexander Udalov b784680fe2 Fix NPE on equals/hashCode for callable references without kotlin-reflect
#KT-11316 Fixed
 #KT-15847 Fixed
2017-02-03 19:35:16 +03:00
Alexey Andreev dcb8b7b92c JS: fix inlining of callable references 2017-01-24 20:09:30 +03:00
Anton Bannykh 07bb7ef4d3 JS: extension lambdas translated same as local lambdas (KT-13312 fixed) 2017-01-23 20:09:36 +03:00
Alexander Udalov ebd577e52a Introduce KProperty{1,2}.getExtensionDelegate
These two functions are supposed to fix an inconvenience in the design of
KProperty{1,2}.getDelegate for extension properties, where you have to pass an
instance of the extension receiver which is going to be completely ignored

 #KT-8384 Fixed
2017-01-23 12:25:36 +03:00
Alexander Udalov 78f2515e95 Introduce KProperty{0,1,2}.getDelegate
#KT-8384 In Progress
2017-01-23 12:25:35 +03:00
Alexander Udalov 32d2faf3d1 Fix KAnnotatedElement.findAnnotation when no annotation is found
#KT-15540 Fixed
2017-01-10 12:23:26 +03:00
Ilya Gorbunov 0a840d0174 Migrate 1.1 reflection API usages in tests. 2016-12-29 06:51:01 +03:00
Mikhael Bogdanov f1c1fcf0fc Fix for KT-11969: ProGuard issue with private interface methods
#KT-11969 Fixed
2016-12-27 14:07:37 +01:00
Ilya Gorbunov 85232ffa07 Drop deprecated pre-1.0 API. Remove remaining usages in tests. 2016-12-26 19:07:20 +03:00
Alexander Udalov 49de52e7ef Fix kotlinFunction for inline reified methods in reflection
Inline functions with reified type parameters are generated as private (see
AsmUtil.specialCaseVisibility), so we should treat them as "declared" in
reflection to look them up via getDeclaredMethod, not getMethod

 #KT-14721 Fixed
2016-12-16 13:12:41 +03:00
Stanislav Erokhin d7566d84d0 Fixed testdata. 2016-12-16 02:01:12 +03:00
Alexander Udalov c811c1bea5 Reflection: add KAnnotatedElement.findAnnotation
#KT-12250 Fixed
2016-12-07 21:45:24 +03:00
Denis Zharkov 1f98accad2 Support new suspend convention in JVM backend partially
Stack-unwinding does not work yet

 #KT-14924 In Progress
2016-11-29 14:14:50 +03:00
Dmitry Petrov 3d2696c81b KT-13440 Bound callable references in reflection 2016-11-25 16:11:18 +03:00
Ilya Gorbunov 0899a0fdda Make some tests JVM only 2016-11-21 18:20:33 +03:00
Alexey Andreev b5358122e2 JS: unmute shared box tests 2016-11-16 19:50:10 +03:00
Alexander Udalov eedad9194e Drop KParameter.isNoinline, KParameter.isCrossinline
There seems to be no valuable use cases for them at the moment
2016-11-15 11:01:17 +03:00
Alexander Udalov 7e82d139cf Drop KFunction.isTailrec
The fate of this modifier seems unclear, and there doesn't seem to be any
valuable use cases for it in reflection
2016-11-15 11:01:16 +03:00
Zalim Bashorov 596f3364c6 Automatically mute failed tests 2016-11-09 21:41:12 +03:00
Alexander Udalov 035d6156a7 Drop Cloneable in JS, synthesize it at compile-time on JVM
Use the same approach that is used for creating function type classes
(Function{0,1,...}) + add Cloneable to supertypes of Array and primitive arrays

 #KT-5537 Fixed
2016-10-25 15:42:33 +03:00
Alexander Udalov 621c6691d0 Support equals, hashCode, toString for annotations instantiated with reflection
#KT-13106 Fixed
2016-09-20 21:36:30 +03:00
Alexander Udalov 525937252d Support Java annotation constructors in reflection
#KT-13106 In Progress
2016-09-20 21:36:30 +03:00
Alexander Udalov aeba124bdb Support Kotlin annotation constructors in reflection
#KT-13106 In Progress
2016-09-20 21:36:29 +03:00
Alexander Udalov fb18e4bf4c Sort parameters of Java annotation constructors by name for stability 2016-09-20 21:36:29 +03:00
Alexander Udalov a10cf8a931 Support 'is/as FunctionN<...>' and 'invoke' for KFunction instances 2016-09-13 14:12:31 +03:00
Alexander Udalov fc043c6e66 Drop KPropertyNFromReferenceImpl classes
The only place where their get/set methods were used was in
KPropertyNImpl.Getter.invoke, and it's fine if that results in a reflective
call instead (KPropertyN#getter is not available without kotlin-reflect.jar
anyway). The test data has been changed because a package local Java field is
not accessible via reflection
2016-09-13 14:12:29 +03:00
Alexander Udalov 90eafe0d71 Fix reflective access on overridden generic property reference
Generation of callable reference's signature in codegen should use the same
mechanism for obtaining the signature as the runtime in RuntimeTypeMapper,
namely DescriptorUtils.unwrapFakeOverride(...).original

 #KT-13700 Fixed
2016-09-12 10:39:21 +03:00