Commit Graph

17 Commits

Author SHA1 Message Date
Alexander Udalov
ced1edcf98 Prohibit callable references to object members
To be able to make them more useful in the future, i.e. bound to the object
instance
2015-10-14 20:45:56 +03:00
Mikhail Glukhikh
f8a356747e Stdlib rename: 'name' and 'ordinal' are now properties in Enum, same name functions are deprecated 2015-10-14 20:40:13 +03:00
Denis Zharkov
f0e3fd617d Adjust testData to CharSequence.length transformation 2015-10-14 20:39:35 +03:00
Pavel V. Talanov
508b401603 Codegen: fix callable reference to member imported from object 2015-10-06 16:31:22 +03:00
Alexander Udalov
661f4efc68 Forbid callable references to members and extensions with empty LHS
This syntax is reserved to be likely used in the future as a shorthand for
"this::foo" where the resulting expression doesn't take the receiver as a
parameter but has "this" already bound to it
2015-10-03 04:37:04 +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
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
596d378962 Fix abstract method error: implement arity in function references 2015-06-01 19:23:09 +03: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
Dmitry Jemerov
4bdf598bfe compiler testdata: s/trait/interface 2015-05-12 19:43:17 +02:00
Stanislav Erokhin
b152211096 Added init keyword to testdata 2015-04-07 13:08:51 +03:00
Alexander Udalov
cd0551078c Support static method references
#KT-5123 Fixed
2014-09-26 18:48:43 +04:00
Svetlana Isakova
9d366cb896 Prohibit local objects and enum classes
#KT-5402 Fixed
  #KT-4838 Fixed

Resolve type of object inside local object as special, not supertype('Any').
Changed visibility of constructor of anonymous object to 'internal' to be able to resolve the following:
fun box(): String {
    var foo = object {
        val bar = object {
            val baz = "ok"
        }
    }
    return foo.bar.baz
}
The containing declaration of property initializers is constructor, so 'baz' was invisible inside private constructor.
2014-09-01 12:32:52 +04:00
Alexander Udalov
8f7c0f0b65 Introduce KFunctionImpl, KMemberFunctionImpl, KExtensionFunctionImpl
Old 23*3 classes will be dropped, since they have no value.

Simplify JvmFunctionImplTypes significantly because of that
2014-05-19 19:50:59 +04:00
Alexander Udalov
5488a8402f Move and rename KFunctionImpl classes
Move from package "kotlin.reflect" to "kotlin.reflect.jvm.internal". They are
internal detail of the compiler and should not be used directly (especially now
that "kotlin.reflect" is in default import paths).

Also rename "KFunctionImplN" to "KFunctionNImpl", because this name makes more
sense
2014-05-19 19:50:58 +04:00
Alexander Udalov
c7a7f31e82 Introduce module 'reflection', move KFunctionN to it
Metadata for KFunction classes is now longer serialized along with built-in
classes. This effectively means that it's no longer possible to find KFunction
classes via dependency on built-ins. There should be a kotlin-runtime library
in the specified classpath for reflection types to be resolvable.

A lot of tests were moved and changed, because tests on callable references
require stdlib in classpath from now on
2014-05-19 19:50:57 +04:00