Commit Graph

3081 Commits

Author SHA1 Message Date
Denis Zharkov fc5217f7fc Fix signature clash problems caused by special built-ins
Do not treat members with already changed signature as a reason
to create a hidden copy

See tests for clarification:
- There are `charAt` method in B that has different name in Kotlin - `get`,
  i.e. relevant descriptor has initialSignatureDescriptor != null
- When collecting methods from supertypes, `charAt` from A is also get
  transformed to `get`
- So it has effectively the same signature as B.get (already declared)
- If by an accident B.get had been declared with Kotlin signature
  we would have add A.charAt (after transformation) with special flag:
  HiddenToOvercomeSignatureClash (hides it from resolution)
- But here B.charAt was artificially changed to `get`, so no signature clash
  actually happened

 #KT-13730 Fixed
2016-09-09 16:33:32 +03:00
Denis Zharkov aee2509bf2 Minor. Replace lambdas with callable references in LazyJavaClassMemberScope 2016-09-09 16:33:32 +03:00
Denis Zharkov a29faf3f2d Minor. Rename MemberIndex -> DeclaredMemberIndex
Also replace super-calls with explicit calls to declaredMemberIndex().getMethods
2016-09-09 10:27:35 +03:00
Denis Zharkov a30cb4ead6 Minor. Drop unused getNonDeclaredTypeAliasNames
Also cleanup type aliases related code in DeserializedMemberScope
2016-09-09 10:27:35 +03:00
Denis Zharkov 44f5df00fe Do not return nested/local classes as a part of package fragment
#KT-13757 Fixed
2016-09-09 10:27:35 +03:00
Denis Zharkov 4bf61db9f9 Optimize class names computation in Java package for CLI
Use known class names' set if it exists
2016-09-09 10:27:35 +03:00
Denis Zharkov 5a2851308f Optimize computation of member names in Java scopes
Effectively all custom logic was moved from MemberIndex to JavaScope classes,
and as member names are being cached there, so it prevents repeating supertypes
traversal (see getAllMemberNames extension)
2016-09-09 10:27:35 +03:00
Denis Zharkov cc0f2e87d4 Optimize java scope members computation for non-existing names
Do not use memoized function if member with given name is not contained in the scope

There are a lot of queries with names of non-existent functions, that leads to many
effectively redundant Map nodes in MemoizedFunction and also cause
additional computation that is worth to compute at once
2016-09-09 10:27:35 +03:00
Denis Zharkov e428ea8dd5 Minor. Refine return type Collection -> Set 2016-09-09 10:27:35 +03:00
Denis Zharkov 02d7cf9614 Minor. Rename get*Names -> compute*Names
To indicate that repeating calls to them may require additional computations

Also change second parameter to be nullable, this will be necessary in the next commits
2016-09-09 10:27:35 +03:00
Denis Zharkov 81682f0497 Optimize JvmBuiltinsSettings.getFunctionsNames 2016-09-09 10:27:35 +03:00
Denis Zharkov 2fb5b0e248 Simplify allDesciptors computation
Do not split descriptors into declared/non-declared groups

It should not be important as order of non-declared members' appearance
does not affect stub building, deserialization and other order-sensitive
stuff
2016-09-09 10:27:35 +03:00
Denis Zharkov f0ba09ae40 Optimize deserialized scope members computation for non-existing names
Do not use memoized function if member with given name is not contained in the scope

There are a lot of queries with names of non-existent functions, that
leads to many effectively redundant Map nodes in MemoizedFunction and also cause
additional computation that is worth to compute at once

Also drop unused 'location' parameter
2016-09-09 10:27:35 +03:00
Denis Zharkov b1edb01dd4 Introduce getFunctionNames and getVariableNames into MemberScope
Also provide some basic implementation

The main purpose of these methods is optimization.
Most of the member scopes store mapping from names to descriptors
MemoizedFunction<Name, Collection<Descriptor>>

While there are 10 functions in class in average, there are a lot of
queries with names of non-existent functions, that leads to many
effectively redundant Map nodes in MemoizedFunction and also cause
additional computation that is worth to compute at once
2016-09-09 10:27:35 +03:00
Denis Zharkov 8ee5f3de8f Minor. Use ArrayList instead of LinkedHashSet
Looks like there's no duplicates anyway
2016-09-09 10:27:35 +03:00
Denis Zharkov e89c53d49f Minor. Extract common pattern in DeserializedMemberScope 2016-09-09 10:27:35 +03:00
Denis Zharkov f50d0b63f0 Minor. Simplify type aliases computation
computeNonDeclaredTypeAliases is always empty
2016-09-09 10:27:35 +03:00
Denis Zharkov 2251e3b1e9 Minor. Replace explicit lazy calculation call with delegation convention 2016-09-09 10:27:35 +03:00
Denis Zharkov a0a0d9b554 Get rid of DeserializedMemberScope.ProtoKey class
Only 'name' property matters, 'isExtension' is only needed for sorting
when computing all descriptors (can be replaced with additional sort)
2016-09-09 10:27:35 +03:00
Denis Zharkov 257417bc4a Minor. Lower type aliase declarations priority
There are several reasons for doing this:
- See org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberScope.computeDescriptors,
  classifiers are being deserialized in the last turn, so it's necessary to preserve consistent order
- Their priority should be close to classes
2016-09-09 10:27:35 +03:00
Valentin Kipyatkov efac7a11b3 Do not include "operator" and "infix" into completion item text for override 2016-09-07 18:10:11 +03:00
Denis Zharkov 6a22d75dd7 Drop TypeAliasDeserializer
Currently it's only used for local type aliases, while code in
'deserializeTypeAlias' works properly only for nested or top-level type
aliases.

Also it seems that serialization of types based on local type aliases
doesn't work now anyway (see KT-13692)
2016-09-05 17:54:36 +03:00
Denis Zharkov 86c1dbe7b5 Fix decompilation of types based on local classifiers
If deserializing a type with arguments based on a local class for
decompiler, then just return Any type (without arguments).

Previously Any constructor was used with serialized arguments, that lead
to exception

Note that in case of deserialization for compiler nothing changes about
local-classes-based types (LocalClassifierResolverImpl is just inlined)

 #KT-13408 Fixed
2016-09-05 17:54:36 +03:00
Alexander Udalov dc689ff514 Fix concurrent access issues in CallableReference implementations
Because of multiple reads from the same non-volatile variable, NPE was possible
to achieve in a multi-threaded application
2016-09-05 16:44:54 +03:00
Alexander Udalov 8fb5858dae Fix occasional NPE from reflection initialization
This could happen when a .jar containing Kotlin stdlib and reflection classes
was launched with 'java -jar'
2016-09-05 16:44:54 +03:00
Alexander Udalov 9da1840523 Minor, rename ConsPStack$1 -> ConsPStack$Itr
To somewhat improve stack traces (see
http://stackoverflow.com/questions/34214290/kotlin-massive-amounts-of-conspstack-how-can-i-avoid/34214718#34214718)
2016-09-05 16:44:54 +03:00
Alexander Udalov f4a1aa640e Optimize KClass creation from Class instance
Don't create unnecessary iterator every time in HashPMap.get (see
https://github.com/hrldcpr/pcollections/pull/41). Also fix a warning and remove
misleading comment
2016-09-05 16:44:54 +03:00
Alexander Udalov d0d1824e7d Optimize argument array creation in reflection call 2016-09-05 16:44:54 +03:00
Dmitry Petrov e0cdad30e4 KT-13181 Unresolved reference when referencing a type alias from a different module
Add corresponding resolution code.
2016-09-02 10:18:23 +03:00
Stanislav Erokhin 8d2d5ea211 Minor refactoring in NewKotlinTypeChecker 2016-09-01 18:00:18 +03:00
Stanislav Erokhin ea2d95fa79 Minor. Change predicate type from KotlinType to UnwrappedType. 2016-09-01 18:00:17 +03:00
Alexey Sedunov c244baf087 Misc: Improve IDE rendering of type aliases 2016-08-31 11:28:02 +03:00
Alexander Udalov 26156b137f Micro optimizations to type rendering in DescriptorRendererImpl
Do not create StringBuilder instances when the resulting String will be
appended to some other StringBuilder anyway. This, and a couple of micro
FqNameUnsafe-related optimizations, helps reduce memory traffic in Kotlin
reflection when rendering is involved (toString() is called on reflective
objects)
2016-08-26 15:17:02 +03:00
Stanislav Erokhin b695f5edd9 Refactoring. Some simplifications in OverloadingConflictResolver. 2016-08-24 11:10:34 +03:00
Ilya Gorbunov cf898ae357 Exclude exceptions from java.lang package for which type aliases exist in kotlin package.
Add relevant note to the type aliases.
2016-08-17 12:40:50 +03:00
Ilya Gorbunov 0d7819e011 Move exceptions to kotlin package in JS library, introduce type aliases for exceptions in kotlin package in JVM runtime.
#KT-18 Fixed
2016-08-17 12:40:50 +03:00
Ilya Gorbunov afe1b7eab1 Allow to exclude specific types from packages imported by default. 2016-08-17 12:40:50 +03:00
Valentin Kipyatkov 12b1a99a6a Initial implementation of loop-to-call-chain intention 2016-08-16 17:37:55 +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 18887f8bec Rename CompanionObjectMapping.hasMappingToObject -> isMappedIntrinsicCompanionObject 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
Alexander Udalov 611899e9d3 Minor, make CompanionObjectMapping a singleton 2016-08-15 19:41:47 +03:00
Mikhail Glukhikh 6cf90cfc4e Fix for SOE in VarianceChecker #KT-13401 Fixed 2016-08-11 13:04:58 +03:00
Alexey Sedunov 1b546d18ff Override/Implement Members: Do not expand type aliases in the generated members. Retain abbreviated types during flexible type approximation
#KT-13244 Fixed
2016-08-10 11:45:36 +03:00
Alexey Sedunov 59a714ca5c Presentation: Render function signature in RefactoringDescriptionLocation
#KT-12943 Fixed
2016-08-10 11:45:29 +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