Commit Graph

1379 Commits

Author SHA1 Message Date
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
Denis Zharkov 6cd6608281 Drop TypeUsage::MEMBER_SIGNATURE_COVARIANT
It's only used for choosing mutability of a collection class, but
using annotations while loading is redundant since there is
a separate phase of type enhancement where they're taken
into account (for flexible types)

For inflexible type it doesn't matter since they appear only in
special cases like annotation methods (where collection classes can't be met)
2017-07-03 17:55:37 +03:00
Denis Zharkov 5ca3459a0f Minor. Merge TypeUsage::MEMBER_SIGNATURE_INVARIANT and COMMON
Their usages are effectively the same
2017-07-03 17:55:37 +03:00
Denis Zharkov 69e70575f9 Drop some of the TypeUsage enum entries
The only sensible usage of them was in the `isNullable` method
But you can check that UPPER_BOUND/SUPERTYPE_ARGUMENT are always
flexible and TYPE_ARGUMENT is not only in case of annotation
methods/parameters
2017-07-03 17:55:37 +03:00
Denis Zharkov 5c8f2a8ae8 Add resolution for JSR 305 type qualifier nicknames
#KT-10942 In Progress
2017-07-03 17:55:37 +03:00
Denis Zharkov 79e14f88e4 Support package level annotations in Java
#KT-10942 In Progress
2017-07-03 17:55:37 +03:00
Denis Zharkov b7ead75947 Minor. Move BinaryJavaModifierListOwner -> MapBasedJavaAnnotationOwner 2017-07-03 17:55:04 +03:00
Alexander Udalov 37982e4bb1 Move SAM-related descriptor classes to module frontend.java
Also move SyntheticMemberDescriptor to module resolution
2017-06-30 21:02:18 +03:00
Alexander Udalov 9717745b83 Minor, remove implementation overridden in all subclasses 2017-06-30 21:02:18 +03:00
Alexander Udalov 778a6758a5 Do not add inner class names to functions in Java static scope
Previously it was needed for SAM adapters, but they can no longer be
found in this scope
2017-06-30 21:02:18 +03:00
Mikhail Glukhikh 840847e47c Code cleanup: several inspections applied 2017-06-29 16:25:57 +03:00
Denis Zharkov cb95986c36 Report error on calls to obsolete inline suspend functions
They do not contain markers for suspend calls in them

See the changes introduced for fixing KT-16603
2017-06-28 10:24:27 +03:00
Alexander Udalov e42b151561 Support primitive array annotation arguments in ConstantValueFactory
This has no visible consequences at the moment, but will help once we
need to load such argument from some annotation in the compiler in the
future
2017-06-27 14:53:39 +03:00
Alexander Udalov 59b932a815 Optimize away unneeded FqName computation in KotlinBuiltIns
Before computing the FqName, check the simple class name first. This
code was responsible for about 20% of FqNameUnsafe instances created
during compilation of "core" modules
2017-06-27 14:53:39 +03:00
Alexander Udalov fb60f4ad8f Do not load annotations of each function in JvmBuiltInsSettings.isFunctionAvailable
This fixes the exception in the case described in KT-14094 because we no
longer try to load annotations on functions which cannot be annotated
with @PlatformDependent. (However, the underlying problem in KT-14094 is
not fixed by this, and is still reproducible on explicit call to
KCallable.annotations.)

 #KT-14094 In Progress
2017-06-21 15:43:00 +03:00
Alexander Udalov aed5b934f8 Introduce KotlinBuiltIns.isUnderKotlinPackage
Semantics is the same as in the former
FunctionDescriptor.hasSubpackageOfKotlin, but it doesn't compute the FQ
name of the descriptor
2017-06-21 15:42:57 +03:00
Mikhail Zarechenskiy 011231f2ab Collect sam adapters for constructors in synthetic scope
Also place computation of synthetic constructors under one function
2017-06-16 16:44:52 +03:00
Mikhail Zarechenskiy 0adc8d9bfa Minor: remove val 2017-06-16 16:44:51 +03:00
Alexander Udalov cbaa676c3d Move some declarations between 'descriptors' and 'deserialization'
- Move the following from 'deserialization' to 'descriptors':
  NotFoundClasses.kt
  AdditionalClassPartsProvider.kt
  ClassDescriptorFactory.kt
  PlatformDependentDeclarationFilter.kt
  findClassInModule.kt
- Move the following form 'descriptors' to 'deserialization':
  BuiltInSerializerProtocol.kt
  builtInsPackageFragmentProvider.kt
- Extract a marker interface from BuiltInsPackageFragment and move its
  implementation to 'deserialization'
- Change the type of parameters in PlatformDependentDeclarationFilter
  and AdditionalClassPartsProvider to ClassDescriptor

This will help in getting rid of the circular dependency of
'descriptors' <-> 'deserialization'
2017-06-06 14:29:18 +03:00
Alexander Udalov bfb3b38ebc Do not try to load Java classes from incorrect packages
#KT-11474 Fixed
2017-05-18 13:30:06 +03:00
Denis Zharkov 63c5d85cf4 Optimize memory footprint for generated protobuf code
The problem was that an overload of CodedOutputStream.newInstance
without size uses 4000 as a default value, thus allocating
a 4k-sized byte array.
At the same time the array remained effectively unused
in the most cases since it only used for storing data
for unknown fields.

Because such arrays are being created for each read of
protobuf message, during compilation of IntelliJ project
it was producing 25% of redundant memory traffic.

Of course these arrays were all in the young gen, but still
they have some effect on GC
2017-05-17 14:34:11 +03:00
Pavel V. Talanov 798c80ed07 Use wrappers around java.util.* to emulate kotlin.collection.* behaviour
Backend: If kotlin class extends kotlin.collection.List
    write it as it's super interface (light class mode only)
IDE: Provide wrapper classes to java resolve
    that try to emulate backend behaviour

For example if kotlin class implements kotlin.collections.Map,
    we provide a superinterface that has abstract 'getEntries' method
    and 'entrySet' method that is considered default.
In reality all those methods are generated in the class itself.

In IDE supporting this case without hacks is not feasible performance-wise
    since kotlin.collection.* may not be an immediate supertype and we need
    to compute all supertypes just to calculate own methods of the class
2017-05-16 22:01:03 +03:00
Pavel V. Talanov 1a04960ff0 J2K class map: expose classes having mutable/readonly kotlin equivalents
Refactor JavaToKotlinClassMap a little bit
2017-05-16 22:00:59 +03:00
Pavel V. Talanov 40561dabed J2K JavaToKotlinClassMap 2017-05-16 22:00:58 +03:00
Mikhail Zarechenskiy 7541a3754d Move SAM constructors to synthetic scope 2017-05-05 21:30:35 +03:00
Mikhail Zarechenskiy 95ede7fb67 Move SAM adapters from static scope to synthetic one 2017-05-05 21:30:10 +03:00
Pavel V. Talanov 55a0e138fc Refactor: extract AnnotationDescriptor.annotationClass utility 2017-05-02 15:40:20 +03:00
Alexander Udalov 38ea9986ab Make KotlinType.isError extension instead of member 2017-04-26 18:10:49 +03:00
Alexey Tsvetkov 50085722d1 Fix internal visibility check for deserialized typealiases
#KT-15495 fixed
2017-04-25 16:27:23 +03:00
Denis Zharkov 62a55b7b00 Fix false-positive resolution ambiguity when using akka
com.typesafe.akka:akka-cluster-sharding_2.12:2.5
akka.cluster.sharding.ClusterSharding  has the following methods:

    public static ClusterSharding get(ActorSystem var0) {
        return ClusterSharding$.MODULE$.get(var0);
    }

    public static Extension get(ActorSystem var0) {
        return ClusterSharding$.MODULE$.get(var0);
    }

NB: ClusterSharding  <: Extension
None of these methods is synthetic or something, but javac allows
calls like ClusterSharding.get(null)  and they get resolved
to the first method returning ClusterSharding

It seems that both javac and IntelliJ resolution algorithms filter out
such clashing declarations choosing the one that has the most
specific return type, the same idea is applied in the change

 #KT-17560 Fixed
2017-04-24 17:54:01 +03:00
Denis Zharkov 513655239d Introduce initializer-related properties into JavaField
It's much more convenient to use and implement these
properties instead of manual "pattern matching" in the
JavaPropertyInitializerEvaluatorImpl
2017-04-21 12:56:30 +03:00
Denis Zharkov 506d7ab3d2 Replace JavaClass.innerClasses with innerClassNames
Also add a findInnerClass method that can find an inner class
by its name

This change helps to avoid loading all the inner class files
eagerly (that may be rather slow), while all the names are available
in InnerClass attribute
2017-04-21 12:48:31 +03:00
Denis Zharkov 5936424659 Replace JavaClassifierType.canonicalText with classifierQualifiedName
The reason is that canonicalText requires some additional
computations to be done when reading class files, while
in fact we only need a class name of the type
2017-04-21 12:48:31 +03:00