Commit Graph

3885 Commits

Author SHA1 Message Date
Svetlana Isakova 89e16ecbcc Don't generate constraint if a type variable was substituted twice
to prevent infinite recursion
2015-07-10 15:05:06 +03:00
Svetlana Isakova 3b85ac90ba Check initial constraints in constraint system status 2015-07-10 15:05:06 +03:00
Svetlana Isakova db8085c399 Incorporation tests 2015-07-10 15:05:05 +03:00
Svetlana Isakova 179c5e3c3a Add a constraint for nested call
if there are no bounds on variables in this call return type
2015-07-10 15:05:04 +03:00
Svetlana Isakova 1463ff7258 Updated constraint system tests 2015-07-10 15:05:04 +03:00
Svetlana Isakova cf64687b02 More accurate error reporting
with type inference error for delegated properties
Add the constraints from completer if they don't lead to errors
except errors from upper bounds to improve diagnostics
2015-07-10 15:05:04 +03:00
Svetlana Isakova 9a5abf368f Constraint incorporation
In a constraint system a new bound is incorporated:
all new constrains that can be derived from it
(and from existing ones) are added
2015-07-10 15:05:04 +03:00
Svetlana Isakova 82acce4767 Separate input and result data in constraint system test
input file: *.constraints
 result file: *.bounds
2015-07-10 15:05:03 +03:00
Svetlana Isakova 0fdfb6b5db Render short names in constraint system tests 2015-07-10 15:05:02 +03:00
Svetlana Isakova 5717148bd4 Changed test data
Added an extra blank line to rendered constraint system
2015-07-10 15:05:02 +03:00
Svetlana Isakova 918087f475 Don't render constraint positions in tests
for constraint system, it's always SPECIAL anyway
2015-07-10 15:05:02 +03:00
Denis Zharkov 76648878e0 Ignore type parameters in value arguments while comparing SAM adapters
#KT-8388 Fixed
2015-07-10 08:46:27 +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 d350303951 Change HashMap in test to custom class
It's implementing kotlin.Map with flexible arguments that is necessary in this test.
2015-07-09 16:36:47 +03:00
Denis Zharkov 151231ef1a Adjust testData
Standard JDK collections purely implement kotlin.Mutable* with non-platform arguments
2015-07-09 16:36:47 +03:00
Denis Zharkov 8b49a1d660 Add PurelyImplements annotation
It's parameter is FQ-name of class (currently only from builtins) that added as supertype to annotated Java class.

Parameters of annotated class used as non-flexible arguments of added supertype, that helps to propagate more precise types when using in Kotlin.
Some standard JDK collections loaded as they annotated with PurelyImplements.

See tests for clarification.
Before: ArrayList<Int>.add(x: Int!) // possible to add null
After: ArrayList<Int>.add(x: Int)   // impossible to add null

 #KT-7628 Fixed
 #KT-7835 Fixed
2015-07-09 16:36:47 +03:00
Denis Zharkov 8120513465 Add some collections to mockJDK
It's neccessary to test they loaded as pure implementation of kotlin collections
2015-07-09 16:36:46 +03:00
Denis Zharkov da416f1caf Change traversal order for finding corresponding supertype from DFS to BFS
In most cases order doesn't matter as in supertype tree built from real code
types with same type constructors should be completely equal.

The only case when order does matter is when we artificially add more specific supertype closer to the root.

For example specific annotation adding non-platform supertype MutableMap<K, V> to ConcurrentHashMap
ConcurrentHashMap<K, V> extends ConcurrentMap<K!, V!> that extends java.util.Map<K!, V!> (mapped to kotlin.MutableMap<K!, V!>)

So we want in that case to use refined (more specific) version when checking subtypes:
ConcurrentHashMap<String, Int> should not be a subtype Map<String!, Int!> (and respectively Map<String?, Int?>)
It should be pure non-platform Map<String, Int> that can be found only with BFS
2015-07-09 16:36:46 +03:00
Denis Zharkov afcdd27d67 Add some marginal tests for types enhancement 2015-07-09 16:36:45 +03:00
Denis Zharkov 00e41fc238 Fix testData after types enhancement 2015-07-09 16:36:45 +03:00
Denis Zharkov cfadda8061 Fix codegen tests after types enhancement 2015-07-09 16:36:44 +03:00
Denis Zharkov 1b44f77054 Minor. trait -> interface in testData 2015-07-09 16:36:44 +03:00
Denis Zharkov d4e5479f0f Update testData for nullability warnings
They become errors after type enhancement
2015-07-09 16:36:44 +03:00
Andrey Breslav 4e17500e1c Test data for LoadJava tests fixed 2015-07-09 16:36:43 +03:00
Denis Zharkov 0173cb1c17 Diagnostics test data fixed 2015-07-09 16:36:43 +03:00
Denis Zharkov c01c59d562 Use doSubstitute when enhacing types of Java method
Before this commit old type parameters were inserted into new descriptor,
and that broke a simple contract: desc.child.getContainingDeclaration() == desc.

We use `doSubstitute` here because it does exactly what we need:
1. creates full copy of descriptor
2. copies method's type parameters (with new containing declaration) and properly substitute to them in value parameters, return type and etc.

But we had to customize `doSubstitute`: add some parameters like `newReturnType`

NOTE: Strange testData change.
(Mutable)List<in T!>! after substitution becomes MutableList<in T!>..List<*>?.

But it's not wrong because List<in T> behaves exactly as List<*>, and the same happens when substituing Java class scope:
public class A<E> {
    <T> void foo(List<? super T> x) {}
}

Kotlin:
A.foo(), type of first value parameter --- (Mutable)List<in T!>
A<String>().foo(), type of first value parameter --- MutableList<in T!>..List<*>?
2015-07-09 16:36:42 +03:00
Andrey Breslav c6b91b0f81 Java type annotations supported in LazyJavaTypeResolver 2015-07-09 16:32:25 +03:00
Andrey Breslav 694af022c8 Type Enhancement for Java fields and constructors supported as well 2015-07-09 16:32:25 +03:00
Andrey Breslav 8c78739983 Proper enhancement for type parameters 2015-07-09 16:32:25 +03:00
Andrey Breslav 04aee291b9 Proper treatment of return types 2015-07-09 16:32:25 +03:00
Denis Zharkov a6a099b0f5 Fix flexible type rendering
Do not append "!" if bounds have same nullability
2015-07-09 16:32:24 +03:00
Andrey Breslav 4d6ab824c8 Adding Java descriptors to the test data for nullability warnings 2015-07-09 16:32:23 +03:00
Yan Zhulanow 3bcdee2a20 publicField & field in companion object 2015-07-07 16:35:23 +03:00
Yan Zhulanow 74f44dddb0 Add tests for publicField 2015-07-07 16:35:23 +03:00
Dmitry Petrov 4e42cc6b81 Save/restore stack in try-expressions (and statements).
Parse TryCatchBlockNode's in generated bytecode, infer stack save/restore points.
Save stack to local variables before 'try'.
Restore stack after the beginning of try-block, catch-block, and default handler.
Integrate before/after inline markers rewriting (otherwise it'll break our stacks).

 #KT-3309 Fixed
2015-07-07 12:16:29 +03:00
Ilya Gorbunov f440d97e04 Remove unnecessary Char.toChar from tests. 2015-07-06 17:57:35 +03:00
Ilya Gorbunov 456bab40d1 Ensure value of correct return type is on stack after intrinsic Char +/- Int and Char - Char binary operations. 2015-07-06 17:57:33 +03:00
Ilya Gorbunov 222d4002ac Add char binary operations to JVM codegen tests. 2015-07-06 17:57:25 +03:00
Alexander Udalov feb4dd7b8f Drop 'OBJECT$' field deprecated in M11 2015-07-06 16:19:54 +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
Ilya Gorbunov 1605027b19 Change return type of Char plus Int and Char minus Int binary operations.
JS: Remove unnecessary intrinsic binary operation patterns, adjust intrinsics for binary operations with char.
2015-07-04 04:47:00 +03:00
Ilya Gorbunov 39b27751df Drop deprecated char operations: correct test data. 2015-07-04 04:46:23 +03:00
Nikolay Krasko ff9c251438 Filter out overridden candidates before looking for most specific
This filtering will remove signature duplicates that prevent findMaximallySpecific() from finding best candidate.
2015-07-03 20:59:48 +03:00
Mikhail Glukhikh bae9a7d7f8 Types are no more rendered for annotation arguments + a swarm of tests corrected accordingly 2015-07-01 16:12:32 +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
Mikhail Glukhikh e1d3b296e9 Exhaustive when over enum may now use "is" instead of comparison + a pair of tests 2015-06-30 19:46:28 +03:00
Ilya Gorbunov 0e896ea1bb Drop streams and iterators: correct test data. 2015-06-29 17:06:49 +03:00
Alexey Sedunov 5ac1fbf59b Descriptor Renderer: Add parentheses around receiver type if it's non-nullable function type
#KT-8188 Fixed
2015-06-27 13:58:00 +03:00
Mikhail Glukhikh 4d895a4c31 Sealed classes: extra java against kotlin tests, together with an implementation of Java diagnostics inside these tests 2015-06-25 19:07:26 +03:00