Commit Graph

729 Commits

Author SHA1 Message Date
Alexey Andreev 1dcb037aee KT-2752: remove diagnostic that reports about overridden method having several names from different sources. Generate proxies instead. Fix reporting name clash when two distinct fake overrides require same name. 2016-10-08 19:25:35 +03:00
Alexey Andreev c5087779e4 KT-2752: add diagnostics that reports about conflicting overridden declarations 2016-10-08 19:25:34 +03:00
Denis Zharkov e05e0ec921 Optimize method count for collection stubs
Do not generate stubs if they're already present in superclasses

 #KT-13698 In Progress
2016-10-07 11:59:15 +03:00
Denis Zharkov 900c442efd Write generic signature for autogenerated toArray
#KT-14195 Fixed
2016-10-07 11:59:15 +03:00
Denis Zharkov 3a100d4139 Improve exception message in collection stubs 2016-10-07 11:59:15 +03:00
Alexander Udalov 73652f309f Do not create synthesized equals/hashCode/toString in data classes in compatibility mode
To simplify migration from 1.0 to 1.1, do not allow data classes to
automatically implement abstract equals/hashCode/toString declared in
super-interfaces (KT-11306) if "-language-version 1.0" is specified
2016-10-04 10:24:41 +03:00
Dmitry Petrov 06101dba52 KT-13961 REDECLARATION not reported on private-in-file 'foo' vs public 'foo' in different file
Private-in-file declarations conflict with public overload-equivalent declarations
in other files in the same package.

Move functions for grouping possible redeclarations to OverloadResolver
(since they are used only there).

Refactor redeclarations / conflicting overloads reporting.
2016-10-03 11:50:29 +03:00
Vsevolod 1ac07340c9 KT-13931 generate IntRange#contains with respect to side-effects on argument loading, test added 2016-09-29 17:56:18 +03:00
Denis Zharkov bb1b8cca20 Fix AssertionError in CodegenUtil.getDelegates
Change getAllOverriddenDescriptors contracti, now it returns
original (not substituted) descriptors without any duplicates.

First of all it's necessary in CodegenUtil.getDelegates to avoid
duplicates (see assertion there), but also it's convenient for all
other usages of this method

 #KT-8154 Fixed
2016-09-28 11:40:35 +03:00
Denis Zharkov 217f033552 Prevent generation of delegations to interfaces private methods
#KT-13381 Fixed
 #KT-13996 Fixed
2016-09-23 14:51:14 +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
Denis Zharkov e75efc88ff Add support for desctructuring of lambda parameters in JVM backend
#KT-5828 In Progress
2016-09-19 20:22:57 +03:00
Alexander Udalov 22f8e7db3b Use independent context to type-check LHS of '::'
#KT-13110 Fixed
2016-09-15 16:45:48 +03:00
Alexey Andreev 5d34f5fb75 KT-13836: fix generation of FQN of secondary constructor when it's called via typealias. Fix #KT-13836 2016-09-14 12:40:01 +03:00
Alexander Udalov a10cf8a931 Support 'is/as FunctionN<...>' and 'invoke' for KFunction instances 2016-09-13 14:12:31 +03:00
Alexander Udalov dcc66a6400 Drop KFunctionFromReferenceImpl, make FunctionImpl an interface
23 invokes in KFunctionFromReferenceImpl (and consequently, in FunctionImpl)
were needed before 1576160390: a wrapped function
reference must have had the necessary invoke to be called as an instance of a
specific function type. After 1576160390, this is
not needed anymore because KFunctionFromReferenceImpl is now an internal
implementation detail of reflection, and no invoke is ever called on it.
2016-09-13 14:12:30 +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
Denis Zharkov 6845d0958a Refine AALOAD handling in OptimizationBasicInterpreter
See comment in test data for clarifications

 #KT-13289 Fixed
2016-09-12 10:26:06 +03:00
Alexey Andreev b91ed1e02a KT-13544: support typealiases in JS backend 2016-09-09 14:38:11 +03:00
Alexey Andreev 16af7d667f KT-12868: if a property initializer is a complex expression that emits additional statements, emit these statements directly before assignment to the property, not at the beginning of constructor 2016-09-09 13:54:03 +03:00
Dmitry Petrov f2b8569b4b KT-13735 NoSuchMethodError for generic typealias acces
Use underlying constructor descriptor for type alias constructor code generation.
2016-09-07 09:46:00 +03:00
Denis Zharkov cebe67d90c Fix default value generation after suspension point
Replace coercion from VOID with call 'pushDefaultValueOnStack'

It's necessary because coercion of VOID to java/lang/Object ends with Unit instance on stack
that makes variables spilling algorithm thinking that variable is Unit

 #KT-13409 Fixed
2016-09-01 15:03:31 +03:00
Denis Zharkov 1226d8fc2c Refine 'handleResult' calls generation within coroutines
Before this change everything works just fine for 'handleResult' methods
accepting non-Unit parameters

For other cases the same coercion-to-unit strategy is in plain lambdas:
- if last statement is not Unit type, execute it, pop from the stack, then put Unit instance
- for 'return@label' (no expression) just put Unit on the stack

 #KT-13531 Fixed
2016-09-01 15:03:31 +03:00
Michael Bogdanov 7325baa06a Fix for KT-13374: CompilationException: Inline function call with anonymous object implementing an interface by delegation
#KT-13374 Fixed
2016-08-16 10:47:01 +03:00
Alexander Udalov bd88b0941d Fix incorrect unsupported error on synthetic extension call on LHS of ::
#KT-13271 Fixed
2016-08-15 19:41:47 +03:00
Alexander Udalov 5b1ee13db8 Make KClasses for primitives equal to KClasses for wrapper types
Both primitive int and wrapper type java.lang.Integer are represented by the
single type kotlin.Int in Kotlin, so inequality between the corresponding
KClasses was confusing here. To keep the old behavior, one may call 'k1.java ==
k2.java' instead of `k1 == k2`

 #KT-13462 Fixed
2016-08-15 19:41:47 +03:00
Alexander Udalov 3efa738bc0 Fix NPE on .companionObjectInstance for built-in classes
#KT-13370 Fixed
2016-08-15 19:41:47 +03:00
Denis Zharkov 1df9724c0c Refine stack frames markup calculation
It fixes VerifyError with coroutines on Dalvik happening because of
variables spilling before/after suspension point

BasicInterpreter from ASM does not distinct 'int' types from other
int-like types like 'byte' or 'boolean', neither do HotSpot and JVM spec.
But it seems like Dalvik does not follow it, and spilling
boolean value into an 'int' field fails with VerifyError on Android 4,
so it's necessary to distinct int types for variables spilling

 #KT-13289 Fixed
2016-08-09 16:36:52 +03:00
Alexander Udalov 7f142253bf Reflection: simplify KTypeProjection 2016-08-08 17:54:11 +03:00
Alexander Udalov a7f4037206 Reflection: change order of arguments of inner generic type
As in KClassifier.createType and everywhere in the compiler, specify arguments
for the innermost type first. This is more convenient to use because generally
the construction/introspection of such type starts from the innermost class
anyway (i.e. something like generateSequence can be used, without the need to
call .reverse() in the end)
2016-08-08 17:54:11 +03:00
Alexander Udalov 89d69bc7eb Reflection: add KClass.createInstance 2016-08-08 17:54:11 +03:00
Alexander Udalov 0525b1e6c1 Reflection: add KClass.declaredMembers 2016-08-08 17:54:11 +03:00
Alexander Udalov 30b7334e48 Reflection: add utilities to filter parameters by kind and name 2016-08-08 17:54:11 +03:00
Alexander Udalov d78988a12a Reflection: add KVisibility, KClass.visibility, KCallable.visibility 2016-08-08 17:54:11 +03:00
Alexander Udalov 7e317f7a7c Reflection: add API for declaration modifiers
#KT-10447 Fixed
2016-08-08 17:54:11 +03:00
Alexander Udalov ada81923dc Reflection: add KClass.isInstance, KClass.cast, KClass.safeCast
#KT-11284 Fixed
2016-08-08 17:54:11 +03:00
Alexander Udalov 3702f4a7a7 Reflection: add KClass.{isSubclassOf,isSuperclassOf}, KType.{isSubtypeOf,isSupertypeOf}
The behavior in primitives.kt is likely to be reconsidered

 #KT-8998 Fixed
2016-08-08 17:54:11 +03:00
Alexander Udalov 4cd252d9d5 Reflection: add KClass.{supertypes,superclasses,allSupertypes,allSuperclasses}
Some things are not implemented yet for allSupertypes, such as KType->Type
mapping of types and generic substitution of built-in types
2016-08-08 17:54:11 +03:00
Alexander Udalov 486ea62c72 Reflection: add KType.withNullability 2016-08-08 17:54:11 +03:00
Alexander Udalov f958483e56 Reflection: deprecate KClass.defaultType
Its semantics were unclear and its javaType was implemented incorrectly (it
should have returned ParameterizedType with star projections for generic type)
2016-08-08 17:54:11 +03:00
Alexander Udalov 6b79782951 Reflection: add KClassifier.starProjectedType
#KT-8998 In Progress
2016-08-08 17:54:11 +03:00
Alexander Udalov 1edf3c7809 Reflection: add KClassifier.createType
#KT-8998 In Progress
2016-08-08 17:54:11 +03:00
Alexander Udalov 153e837a84 Reflection: add KType.jvmErasure
#KT-8998 In Progress
2016-08-08 17:54:11 +03:00
Alexander Udalov e760b5ed53 Reflection: add KTypeParameter.toString
The test covers different type parameters with and without bounds, in case we
decide to also output upper bounds in toString
2016-08-08 17:54:11 +03:00
Alexander Udalov 170ea4dead Reflection: add KVariance, KTypeParameter.{variance,upperBounds,equals,hashCode} 2016-08-08 17:54:11 +03:00
Alexander Udalov 127e7ab5b7 Reflection: add KClass.typeParameters, KCallable.typeParameters
Inheritance from KCallable is removed in kt9078.kt because it was irrelevant to
the test and because it gets in the way of modification of KCallable
2016-08-08 17:54:11 +03:00