Commit Graph

23880 Commits

Author SHA1 Message Date
Alexey Sedunov e8f5a2db7c Minor: Fix compilation-breaking nullability issues 2015-07-09 20:34:55 +03:00
Alexey Sedunov 058829aa55 J2K: JetChangeSignatureDialog 2015-07-09 17:56:54 +03:00
Alexey Sedunov 8b2be72434 J2K: JetChangeSignatureDialog (rename to .kt) 2015-07-09 17:56:53 +03:00
Alexey Sedunov 0bf7bb3987 J2K: JetChangeSignatureHandler 2015-07-09 17:56:52 +03:00
Alexey Sedunov 74570333c0 J2K: JetChangeSignatureHandler (rename to .kt) 2015-07-09 17:56:50 +03:00
Alexey Sedunov 0afea7acac J2K: JetUsageInfo 2015-07-09 17:56:49 +03:00
Alexey Sedunov 51eb989d57 J2K: JetChangeSignatureProcessor 2015-07-09 17:56:47 +03:00
Alexey Sedunov 9dd6dea85f Change Signature: Move UI-related classes to separate package 2015-07-09 17:56:46 +03:00
Alexey Sedunov 0169963a27 Change Signature: Process internal usages of function parameters when
performing Java refactoring
2015-07-09 17:56:44 +03:00
Denis Zharkov 5c60a1bdb8 Make project compilable after PurelyImplements annotation introduction 2015-07-09 16:36:48 +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 0a19fb7df2 Make project compilable after types enhancement 2015-07-09 16:36:46 +03:00
Denis Zharkov 4479c215d4 Change return type for iterator method of asList impls for *Array
These objects implement AbstractList that extending MutableCollection.
After type propagation `iterator` of AbstractList become MutableIterator, so it cannot be overriden with immutable Iterator
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 5ea0c14d4a Expand the AbstractJvmRuntimeDescriptorLoaderTest hack
Remove type related annotations from java source as they have CLASS retention policy
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 befe025d21 Fix intentions testData: types rendering changed
Some more FQ names appeared.
The reason is that earlier such types were Lazy and their `toString` method return short version.
But after type enhancement they are represented with JetTypeImpl
2015-07-09 16:36:45 +03:00
Denis Zharkov f0833d626a Fix intentions tests after types enhancement
Types became more accurate
2015-07-09 16:36:44 +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 e13f34a8a0 Minor. Use getOrElse from stdlib 2015-07-09 16:36:43 +03:00
Denis Zharkov fd43799c6e Use original descriptor when working with errors in KotlinSignature
Otherwise enhanced version are treated differently
2015-07-09 16:36:43 +03:00
Denis Zharkov a551f21e9f Use original descriptor when trying to obtain source
Also refine `getOriginal` of `DeclarationDescriptorWithSource` for comfortable use
2015-07-09 16:36:42 +03:00
Denis Zharkov 0375e45936 Change reporting policy for NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS
If lower bound of flexible is nullable treat it like Kotlin nullable type
Anyway appropriate errors are reported outside JavaNullabilityWarningsChecker
2015-07-09 16:36:42 +03:00
Denis Zharkov 1469a0aa6f Make computation of indexed JavaTypeQualifiers eager 2015-07-09 16:36:42 +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
Denis Zharkov f6c4ec1533 Move creation of enhanced ValueParameterDescriptor to JavaCallableMemberDescriptor
It's needed because new parameter owner is not created while enhacing types
(It was containing declaration of old value parameter that is wrong)

Also simplified SignatureParts' logic: `replaceType` is always an identity function
2015-07-09 16:32:25 +03:00
Denis Zharkov 4710168c5a Minor. Specify visibility for some declarations in typeEnhacement 2015-07-09 16:32:25 +03:00
Denis Zharkov c769748cb0 Move type enhacement parts to separate package in runtime
It's needed to enhace types when loading descriptors via reflection.
Also get rid of `enhanceSignatures` method in ExternalSignatureResolver as enhancement does not use external signature at all
2015-07-09 16:32:25 +03:00
Andrey Breslav c6b91b0f81 Java type annotations supported in LazyJavaTypeResolver 2015-07-09 16:32:25 +03:00
Andrey Breslav eaae88133c Minor FilteredAnnotations moved out of Java-specific code 2015-07-09 16:32:25 +03:00
Andrey Breslav 31f4ff749c Type annotations supported in Java elements
Reflection-related implementations are pending
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
Andrey Breslav a8b5698145 Proper enhancement for SAM adapters 2015-07-09 16:32:25 +03:00
Andrey Breslav 9644eeb047 Propagating annotations into type arguments 2015-07-09 16:32:24 +03:00
Andrey Breslav 4248654f5f Signature enhancement: most basic version implemented 2015-07-09 16:32:24 +03:00
Andrey Breslav 61da419c4a Spec: account for problematic cases (some unsolved yet) 2015-07-09 16:32:24 +03:00
Andrey Breslav f376b2ba70 Stub infrastructure for enhancing platform signatures 2015-07-09 16:32:24 +03:00
Andrey Breslav 991f0fcf2e Type enhancement and qualifier extraction 2015-07-09 16:32:24 +03:00
Andrey Breslav e095162c19 Minor. Dictionary 2015-07-09 16:32:24 +03:00