Commit Graph

259 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 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
Ilya Gorbunov 8892192e9c Generate openRange tests for compiler.
#KT-4665
2015-07-24 04:13:53 +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
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
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 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 cfadda8061 Fix codegen tests after types enhancement 2015-07-09 16:36:44 +03:00
Ilya Gorbunov f440d97e04 Remove unnecessary Char.toChar from tests. 2015-07-06 17:57:35 +03:00
Alexander Udalov ac0db5ce80 Fix incorrect TypeCastException message when casting null
#KT-5121 Fixed
2015-07-06 16:14:22 +03:00
Alexander Udalov cb03f0df5a Fix casts of Unit value to other types 2015-07-06 16:14:06 +03:00
Mikhail Glukhikh 848c2afdb4 "is" over enum entry is now an error + new tests + test fixes 2015-06-30 19:46:30 +03:00
dnpetrov c24e6b5698 Support 'break' and 'continue' in expressions
- generate fake jump instructions so that we can always analyze stack depths
- fix stack before break and continue by dropping excessive elements (e.g., *a*.foo(*b*, c?:continue))
- Analyzer rewritten in Kotlin, with more flexible control of CFG traversal

 #Fixed KT-3340
 #Fixed KT-4258
 #Fixed KT-7941
2015-06-25 17:40:55 +03:00
Mikhail Glukhikh 5fabb962ae Private constructors are now accessed via synthetic constructor with DEFAULT_CONSTRUCTOR_MARKER as an additional argument #KT-6299 Fixed
A set of tests provided. Some external tests fixed accordingly.
Companion object creation changed accordingly.
Derived classes now can use base class with the private constructor.
Refactoring of AccessorForFunctionDescriptor.
2015-06-24 12:30:11 +03:00
dnpetrov 36ae8790a1 KT-8011 Compiler crashes on attempt to create local class inside lambda
- use StackValue from upper-level context if local lookup fails

 #KT-8011 Fixed
2015-06-18 17:40:24 +03:00
Denis Zharkov e3c3af6aab Change MISSING_CONSTRUCTOR_KEYWORD severity to error
And adjust testData
2015-06-12 11:23:13 +03:00
Denis Zharkov 414d6b92f6 Adjust testData: don't use java.lang.Class in annotations 2015-06-12 09:55:13 +03:00
Denis Zharkov c9f79c2d05 Adjust testData: get rid of obsolete annotations 2015-06-12 09:23:31 +03:00
dnpetrov 50ea67ba13 KT-5524 Support [platformName] annotation for class members
@platformName is now supported for final non-overriding class member functions
(including property accessors).
Front-end provides diagnostics for inapplicable annotation cases.
Code generation updated:
- ignore kotlin.platform.platformName annotation for Java class methods;
- bridges generation generates proper JVM declarations in case of methods renamed with @platformName.
@platformName-related tests added.

#KT-5524 Fixed
2015-06-04 17:54:08 +03:00
Alexander Udalov 596d378962 Fix abstract method error: implement arity in function references 2015-06-01 19:23:09 +03:00
Alexander Udalov 28addcf8e7 Do not generate annotations of method parameters on its $default synthetic method
#KT-7892 Fixed
2015-06-01 19:23:08 +03:00
Dmitry Jemerov 1188e57597 rename @overloads annotation to @jvmOverloads 2015-05-27 12:23:08 +02:00
Alexander Udalov 6ae7ed1cc4 Add some new tests on functions and extension functions 2015-05-27 01:44:19 +03:00
Alexander Udalov 49004a8b8e Conform functions to extension functions and vice versa
#KT-5989 Fixed
2015-05-26 15:04:56 +03:00