Commit Graph

1993 Commits

Author SHA1 Message Date
Ilya Gorbunov 0ebfba7a1a Test data: do not use exceptions from java.lang, as they are not available in JS 2016-08-17 12:40:50 +03:00
Michael Bogdanov e0d525b72a Support bound function reference inlining 2016-08-17 11:26:45 +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
Alexander Udalov f69cc01f8e Reflection: add KTypeProjection and KType.arguments
#KT-8998 In Progress
2016-08-08 17:54:11 +03:00
Alexander Udalov c1dd831e65 Reflection: add KType.classifier
#KT-8998 In Progress
2016-08-08 17:54:11 +03:00
Alexey Andreev 19cea48637 JS: add tests to show that #KT-12865 fixed as well 2016-08-05 16:32:27 +03:00
Dmitry Petrov a08e70879f KT-13161 java static methods call not working for typealias
Introduce special qualifier for type aliases with member scope
containing static class members only.
2016-07-28 17:38:36 +03:00
Denis Zharkov 915e36cb02 Add Map.getOrDefault method as PlatformDependent declaration with refined signature
- First parameter should have type of K instead of Any
- Special bridge should return second parameter if a key has wrong type
- Special bridge may throw an exception if defaultValue has wrong type

 #KT-13209 Fixed
2016-07-27 18:46:13 +03:00
Denis Zharkov f2cb86c3f6 Minor. Fix testData 2016-07-27 18:46:13 +03:00
Dmitry Petrov 26c8bc87fd KT-13241 Indices optimization leads to VerifyError with smart cast receiver
Use expected receiver type from the corresponding extension function.
2016-07-27 13:21:22 +03:00
Michael Bogdanov 9b9abb2e10 Fix for KT-13182: Regression: compiler internal error at inline
#KT-13182 Fixed
2016-07-26 16:16:37 +03:00
Michael Bogdanov 99cdc41ab6 Fix for KT-13133: Incorrect InnerClasses attribute value for anonymous object copied from an inline function
#KT-13133 Fixed
2016-07-26 16:16:36 +03:00
Alexander Udalov 91e486d020 Fix KCallable#name intrinsic for bound references
Do not skip generation of the left-hand side because it may produce side
effects

 #KT-12995 Fixed
2016-07-26 13:48:20 +03:00
Alexander Udalov 0ea885ce58 Move tests on KClass.java* to box/classLiteral/java
Also replace WITH_REFLECT to WITH_RUNTIME to test that these cases correctly
work without reflection in the classpath
2016-07-26 13:48:19 +03:00
Alexander Udalov 70e01fac18 Fix class literals of objects in super constructor calls
In an expression such as "Obj::class" where Obj is an object, it's fine to
consider Obj either an expression or a type and generate either
Obj.INSTANCE.getClass() or Obj.class correspondingly. However,
the former fails in the object's super constructor call because the INSTANCE
field is not yet initialized. Thus, we force generation of Obj.class in case
when Obj is an object.

Note that this has been reproduced in our project, see
KotlinMetadataVersionIndex
2016-07-26 13:47:34 +03:00
Alexander Udalov 495ed13fce Implement codegen for bound class reference expressions
- Inline the usage of ExpressionCodegen#generateClassLiteralReference into
  ClosureCodegen, simplify
- Support DoubleColonLHS.Expression in generateClassLiteralReference
- Substantially simplify KClass.java intrinsic by reusing
  generateClassLiteralReference

 #KT-13075 Fixed
 #KT-12995 In Progress
2016-07-26 13:47:33 +03:00
Denis Zharkov becb1f1f95 Make stack values for assignment-like operations lazy
As well as for other kinds of expressions

Within attached test they were generated twice in case of last expression of coroutine block,
because coroutine related codegen part is built upon assumption that all expressions should be generated lazily

Also add a test about unary postfix increment/decrement

 #KT-13156 Fixed
2016-07-25 13:56:43 +03:00
Alexander Udalov 0dd71cc0c0 Minor, add test on bound reference to enum entry member 2016-07-22 11:05:19 +03:00
Alexander Udalov 9ab8da2ef9 Fix type of reference to protected var
#KT-12982 Fixed
2016-07-22 11:05:19 +03:00
Michael Bogdanov 1d5924d236 'superConstructorCall' test folder moved under 'innerNested' 2016-07-21 19:10:42 +03:00
Michael Bogdanov 55382ba848 Removed obsolete code in 'lookupConstructorExpressionsInClosureIfPresent' method 2016-07-21 19:10:42 +03:00
Michael Bogdanov 5dca4dbc67 Fix for KT-11833: Error generating constructors of class null with kind IMPLEMENTATION on anonymous object inheriting from nested class of super class
#KT-11833 Fixed
2016-07-21 19:10:42 +03:00
Michael Bogdanov 6f41e3b462 Fix for KT-11634: UOE in ConstructorContext.getOuterExpression for super call in delegation
#KT-11634 Fixed
2016-07-20 16:50:49 +03:00
Denis Zharkov 3845ea863c Do not generate DefaultImpl method for MutableMap.remove(K;V)Z
#KT-13069 Fixed
2016-07-12 16:27:48 +03:00
Denis Zharkov 18c2d3070d Refine variables liveness analysis
Do not treat var as alive just because current instruction belongs to an item range
in local variables table, but the item has different sort of type

As liveness analysis is mostly used in coroutines spilling,
not applying this change may lead that to problems on Android (see tests)
2016-07-12 12:52:03 +03:00
Michael Bogdanov 23a0e19620 Fix for KT-13040: Invalid bytecode generated for extension lambda invocation with safe call
#KT-13040 Fixed
2016-07-09 14:55:49 +03:00
Michael Bogdanov 486aa5675f Fix for KT-12908: Variable initialization in loop causes VerifyError bad local variable type
#KT-12908 Fixed
2016-07-09 07:45:57 +03:00
Dmitry Petrov b0edec8449 KT-13023 Char operations throw ClassCastException for boxed Chars
Char is not a Number, so we can't use the same coercion strategy for Char members,
since it doesn't work for boxed Chars.
2016-07-08 10:26:04 +03:00