Commit Graph

1411 Commits

Author SHA1 Message Date
Stanislav Erokhin e86d2f00ff Rename isImpl to isActual in descriptors 2017-09-15 18:25:49 +03:00
Stanislav Erokhin c8ee424f67 Rename isHeader to isExpect in descriptors 2017-09-15 18:25:41 +03:00
Denis Zharkov 2ca220d442 Ignore built-in type qualifier defaults when Jsr305State=IGNORE 2017-09-14 18:05:32 +03:00
Alexander Udalov 2bb437b219 Do not load JvmPackageName-annotated parts on Kotlin < 1.2 2017-09-13 22:59:03 +03:00
Alexander Udalov 70ae1596fb Support JvmPackageName annotation in binary format
The main changes are in jvm_package_table.proto and ModuleMapping.kt.
With JvmPackageName, package parts can now have a JVM package name that
differs from their Kotlin name. So, in addition to the old package parts
which were stored as short names + short name of multifile facade (we
can't change this because of compatibility with old compilers), we now
store separately those package parts, which have a different JVM package
name. The format is optimized to avoid storing any package name more
than once as a string.

Another notable change is in KotlinCliJavaFileManagerImpl, where we now
load .kotlin_module files when determining whether or not a package
exists. Before this change, no PsiPackage (and thus, no JavaPackage and
eventually, no LazyJavaPackageFragment) was created unless there was at
least one file in the corresponding directory. Now we also create
packages if they are "mapped" to other JVM packages, i.e. if all package
parts in them have been annotated with JvmPackageName.

Most of the other changes are refactorings to allow internal names of
package parts/multifile classes where previously there were only short
names.
2017-09-13 22:59:03 +03:00
Denis Zharkov 4e4bf31016 Fix loading JSR-305 nicknames for @CheckForNull annotation
For sake of working without jsr305.jar in the classpath `resolveTypeQualifierAnnotation`
may return javax.annotation.CheckForNull (although the latter is nickname itself)

 #KT-19985 Fixed
2017-08-31 15:13:26 +03:00
Denis Zharkov ed79891ee6 Fix type mapping for parameter of Collection<Int>::remove override
In the case the single parameter of override has `Integer` type instead
of `int` type (while in common case it would be just `int`)

See the comment inside forceSingleValueParameterBoxing for clarification

 #KT-19892 Fixed
2017-08-31 12:38:08 +03:00
Pavel V. Talanov 6424b6760f Remove StorageComponentContainerContributor::onContainerComposed
Rename addDeclarations -> registerModuleComponents
Use it to provide SamWithReceiverResolver extensions instead

Post construction on container composition can be achieved
    but manually inserting injections where it seems appropriate
    is bug prone
This fixes a bug where SamWithReceiverPlugin extension was not registered
    for some containers in IDE which led to incorrect highlighting in IDE
Add IDE test for applying SamWithReceiver plugin

 #KT-18062 Fixed
2017-08-18 19:11:25 +03:00
Yan Zhulanow 6f180416b1 Pass SamConversionResolver explicitly cause it should be call site module-local 2017-08-18 19:11:21 +03:00
Yan Zhulanow 57d209f599 Kapt: Do not use awkward ('$' -> '/') logic for KAPT3 class builder mode
So (for the most often reproduction case) #KT-19433 Fixed

Before this commit, internal names for nested classes were written as test/Foo/Bar (comparing to test/Foo$Bar in the normal mode), as getting qualified names from such internal names was trivial. But, because of IC, we needed to write class files to the disk, so our decompiler could find such "broken" classes and read it in a wrong way.
2017-08-15 17:48:51 +03:00
e5l 5501cdf049 Add warnings for jsr305 nullable annotations
#KT-19115 Fixed
2017-08-15 11:01:08 +03:00
Denis Zharkov ce37ab81ba Fix types enhancement for properties' getters overrides in Java
Prior to the 1.1.4, nullability related annotations were stored
in types that became hard to maintain at some moment and
we got rid of it (see 57b7b91444)

But enhancement for properties overrides stopped working
because there were effectively no annotations in the
resulting descriptor

 #KT-19409 Fixed

 #KT-19409 Fixed
2017-08-11 10:19:55 +07:00
Denis Zharkov 9962fc88ca Minor. Move type qualifiers computation to their first usage 2017-08-11 10:19:55 +07:00
Denis Zharkov 8948023a26 Add built-in support for ParametersAre(Non)nullByDefault annotation
#KT-19419 In Progress
2017-08-11 10:18:41 +07:00
Denis Zharkov 964f60d0a4 Resolve qualifier nicknames to default annotations without JSR305 jar
#KT-19419 In Progress
2017-08-11 10:18:41 +07:00
Denis Zharkov f8f0c0b6d7 Load enum/array annotation arguments for not found classes
It's necessary to load type qualifier related annotations
without JSR305 annotations being in the classpath

 #KT-19419 In Progress
2017-08-11 10:18:41 +07:00
Valentin Kipyatkov 9361cd895c Support for import aliases in code completion
#KT-8848 Fixed
2017-08-08 22:06:04 +03:00
Mikhail Glukhikh c5a81691fb Partial code cleanup: can be private and some others applied 2017-08-01 17:08:56 +03:00
Alexander Udalov 541b9dab52 Introduce optimized BuiltInAnnotationDescriptor for built-in annotations
It's built on a FQ name and avoids resolution of the annotation class
descriptor as much as possible
2017-07-20 13:26:13 +03:00
Alexander Udalov f39106f75c Do not use parameter descriptors in AnnotationDescriptorImpl 2017-07-20 13:26:13 +03:00
Alexander Udalov eb205f620c Do not use parameter descriptors in most annotation implementations
Except AnnotationDescriptorImpl, which is refactored in the subsequent
commit.

Note that we no longer check the presence of parameters with the
corresponding names in the annotation class in
LazyJavaAnnotationDescriptor, this is why test data changed
2017-07-20 13:25:39 +03:00
Alexander Udalov cc7ed2ba54 Change map key type in AnnotationDescriptor.getAllValueArguments
Turns out, only the parameter's name is needed at all usages of this
method. Such a map is both easier to use (no need to call
ValueParameterDescriptor.getName) and easier to construct (no need to
resolve annotation class, its constructor, its parameters). In this
commit, only usages have changed but the implementations are still using
the old logic, this is going to be refactored in subsequent commits
2017-07-20 13:25:39 +03:00
Alexander Udalov 41ea0e8ef8 Introduce AnnotationDescriptor.fqName
Could be used instead of ".annotationClass.fqName" to avoid the unneeded
resolution of the annotation class descriptor
2017-07-20 13:25:38 +03:00
Alexander Udalov 1d64b61a8f J2K AnnotationDescriptor, refactor implementations 2017-07-20 13:25:38 +03:00
Alexander Udalov 9ee4b39e1b Provide default implementation for Annotations.findExternalAnnotation 2017-07-20 13:25:38 +03:00
Alexander Udalov c197db9c69 Remove some unnecessary lazy computations in LazyJavaClassDescriptor 2017-07-20 13:25:38 +03:00
Denis Zharkov 90e894b171 Use known jvm binary class for package part if possible 2017-07-20 10:53:09 +03:00
Denis Zharkov 99a10d8d63 Minor. Rename compactIfPossible -> compact
As ArrayList can always be compacted
2017-07-20 10:53:09 +03:00
Denis Zharkov f8a12a0ec3 Optimize JavaTypeResolver by avoiding using some language features
It's quite a hot point and using local functions with default
parameters seem to affect negatively to overall performance
(at least some of compiler benchmark have shown it)
2017-07-20 10:53:09 +03:00
Denis Zharkov 4385ce8828 Reduce memory footprint for basic case of flexible types
The case is when we have a simple type constructor
(not array nor collection) and type is not raw:
A<T1, >..A<T1>?

Actually these types are almost equal besides of nullability,
but we create and resolve two different simple types,
they have different arguments' lists, etc.

The idea is to add NullableSimpleType subclass with delegate
to another simple type

It should help a lot both with common cases and with corner ones:
flexibles types in spark for Function22 having exponential size
because of its flexibility

 #KT-14375 Fixed
 #KT-14323 Fixed
2017-07-20 10:53:09 +03:00
Alexander Udalov 616d575fb6 Support reflection for local delegated properties
#KT-15222 Fixed
2017-07-14 15:13:12 +03:00
Mikhail Zarechenskiy 14890890b1 Minor, get rid of unchecked cast 2017-07-12 14:37:27 +03:00
Alexander Udalov 127cd1295e Disable JSR-305 annotations by default, introduce CLI argument
No package annotations are going to be loaded, and
TypeQualifierDefault/TypeQualifierNickname are no longer recognized by
default. Use the CLI argument "-Xload-jsr305-annotations" to enable this
behavior back

 #KT-10942
2017-07-07 22:08:50 +03:00
Denis Zharkov 5453f3067c Load @NonNull(when=UNKNOWN) annotated type as a flexible one 2017-07-03 17:55:37 +03:00
Denis Zharkov 55b585f3d0 Replace JavaTypeAttributes interface with simple data class 2017-07-03 17:55:37 +03:00
Denis Zharkov 939bacc810 Minor. Drop unused parameters in LazyJavaScope 2017-07-03 17:55:37 +03:00
Denis Zharkov e26c210d69 Support TypeQualifierDefault from JSR 305 for nullability qualifiers
#KT-10942 Fixed
2017-07-03 17:55:37 +03:00
Denis Zharkov a95d3e601b Fix container for extension receiver types from Java
No tests are added since there are some already
(e.g. TypeEnhancement.testOverriddenExtensions)
2017-07-03 17:55:37 +03:00
Denis Zharkov 57b7b91444 Do not add container annotaions to type artificially
It was only used for type-related nullability/mutability
annotations and it was necessary to remove them
in the descriptor renderer (duplicating their fqnames there).
At the same time they're only needed for types enhancement
where they can be simply restored from type owners' descriptors

The testData changes are more or less correct: this kind of annotations
is bound both to types themselves and their use because of their targets
2017-07-03 17:55:37 +03:00
Denis Zharkov f877c82029 Simplify computeIndexedQualifiersForOverride() declaration
Do not pass properties of the to its own methods
2017-07-03 17:55:37 +03:00
Denis Zharkov 8812844d43 Move type qualifiers calculation into SignatureParts
It helps not to pass signature parts content to them
2017-07-03 17:55:37 +03:00
Denis Zharkov 92f9194112 Support TypeQualifierNickname for nullability annotations
#KT-10942 In Progress
2017-07-03 17:55:37 +03:00
Denis Zharkov f2a55d590c Move type qualifiers extraction to SignatureEnhancement
These methods will depend on other components soon
2017-07-03 17:55:37 +03:00
Denis Zharkov b3caa1da34 Introduce SignatureEnhancement component
It will depend on the AnnotationTypeQualifierResolver later
2017-07-03 17:55:37 +03:00
Denis Zharkov 21d1d16e74 Drop RawBound class and relevant property from JavaTypeAttributes
The main motivation behind this change is code simplification:
raw bounds can be simply replaced with common flexible bounds
2017-07-03 17:55:37 +03:00
Denis Zharkov cbe62f076d Drop JavaTypeAttributes::isMarkedNotNull property
The only cases this code runs are annotation parameters
and supertypes that are already not-nullable by default
2017-07-03 17:55:37 +03:00
Denis Zharkov fc9810182e Get rid of JavaTypeAttributes::allowFlexible property
It's only false now in case of annotation parameters
2017-07-03 17:55:37 +03:00
Denis Zharkov 507eccc4ec Replace another allowFlexible=false with isNotNullable
Having field initilized doesn't make it inflexible in a sense
of mutability
2017-07-03 17:55:37 +03:00
Denis Zharkov a0268d23bb Get rid of trivial allowFlexible replacing
As the type is anyway replaced with not-nullable version
explicitly, the only thing that changes is what type is loaded
for String[][].class:
- before it would be Array<Array<String?>?>
- now it's Array<(out) Array<(out) String!>!>

It's both a minor change and new behaviour can be considered
as correct
2017-07-03 17:55:37 +03:00
Denis Zharkov 58442e7b8b Drop TypeUsage::MEMBER_SIGNATURE_CONTRAVARIANT
It's only used for value parameters, but they're always resolved
with flexible types now
2017-07-03 17:55:37 +03:00