Commit Graph

479 Commits

Author SHA1 Message Date
Dmitry Petrov b3ce2eea39 Add LanguageVersionSettings to KotlinTypeMapper
KotlinTypeMapper clients should use proper LanguageVersionSettings when
possible.
2018-11-21 12:01:41 +03:00
Denis Zharkov 580d03be5f Support JvmWildcard/JvmSuppressWildcard in ultra-light classes
The idea is reusing logic from KotlinTypeMapper for that
2018-11-19 14:40:51 +03:00
Denis Zharkov ce3b489fa9 Avoid using CheckSignatureAdapter in ultra-light classes 2018-11-19 14:40:51 +03:00
Denis Zharkov 037ad2923c Minor. Rename parameter in KtUltraLightClass::asJavaMethod 2018-11-19 14:40:51 +03:00
Denis Zharkov e15e82e1a9 Refactor KotlinType::asPsiType for ultra-light classes
- Extract HOF that UltraLightSupport::mapType that allows to call
arbitrary functions of type mapper
- Use it for computing return type of functions
- "declaration: KtDeclaration" parameter became unused since it was only
used for return types
2018-11-19 14:40:51 +03:00
Denis Zharkov d74c12323f Fix ambiguity when KtUltraLightClass contains overrides
#KT-27987 Fixed
2018-11-08 15:25:41 +03:00
Denis Zharkov 234776820b Use KotlinLightReferenceListBuilder for type parameters bounds
It doesn't run resolve() on freshly added reference, thus the latter is
not failing in recursive case like T : Enum<T>
2018-11-08 15:25:41 +03:00
Denis Zharkov a4cc67d0a0 Refine isInlineOnly check in KtUltraLightClass 2018-11-08 15:25:41 +03:00
Denis Zharkov 34f9a1e70e Do not build no-arg constructor overload for inner KtUltraLightClass 2018-11-08 15:25:41 +03:00
Denis Zharkov 8999a21764 Refine visibility computation for lateinit's field in KtUltraLightClass 2018-11-08 15:25:41 +03:00
Denis Zharkov 6fc8c98aea Avoid calling PsiType::resolve while adding supertype references
Otherwise, e.g. in case of inner classes it may lead to
StackOverflowError:
- Someone tries to resolve supertypes
- We're starting building extends/implements lists
- Then calling resolve on the type references leads that some logic
in Java resolution again is trying to resolve supertype of the same
class (only in case of inner ones)

Probably, it could be fixed on the side of Java resolve
but at the same time it's clear that calling `resolve` while building
extends list it's really somewhat not very cool

The exception is following:
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration$_extendsList$2.invoke(KtLightClassForSourceDeclaration.kt:77)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration$_extendsList$2.invoke(KtLightClassForSourceDeclaration.kt:73)
	at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration.get_extendsList(KtLightClassForSourceDeclaration.kt)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration.getExtendsList(KtLightClassForSourceDeclaration.kt:320)
	at com.intellij.psi.impl.PsiClassImplUtil.getExtendsListTypes(PsiClassImplUtil.java:1017)
	at com.intellij.psi.impl.light.AbstractLightClass.getExtendsListTypes(AbstractLightClass.java:137)
	at com.intellij.psi.impl.ScopedClassHierarchy.getSuperTypes(ScopedClassHierarchy.java:95)
	at com.intellij.psi.impl.ScopedClassHierarchy.visitType(ScopedClassHierarchy.java:80)
	at com.intellij.psi.impl.ScopedClassHierarchy.getSuperClassSubstitutor(ScopedClassHierarchy.java:115)
	at com.intellij.psi.impl.JavaClassSupersImpl.getSuperSubstitutorWithCaching(JavaClassSupersImpl.java:111)
	at com.intellij.psi.impl.JavaClassSupersImpl.getSuperClassSubstitutor(JavaClassSupersImpl.java:71)
	at com.intellij.psi.util.TypeConversionUtil.getMaybeSuperClassSubstitutor(TypeConversionUtil.java:1089)
	at com.intellij.psi.util.TypeConversionUtil.getClassSubstitutor(TypeConversionUtil.java:1055)
	at com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl.advancedResolveImpl(ClsJavaCodeReferenceElementImpl.java:143)
	at com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl.access$000(ClsJavaCodeReferenceElementImpl.java:43)
	at com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl$Resolver.resolve(ClsJavaCodeReferenceElementImpl.java:121)
	at com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl$Resolver.resolve(ClsJavaCodeReferenceElementImpl.java:115)
	at com.intellij.psi.impl.source.resolve.ResolveCache.lambda$resolveWithCaching$1(ResolveCache.java:203)
	at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:99)
	at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:202)
	at com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl.multiResolve(ClsJavaCodeReferenceElementImpl.java:223)
	at com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl.advancedResolve(ClsJavaCodeReferenceElementImpl.java:213)
	at com.intellij.psi.impl.source.PsiClassReferenceType.resolveGenerics(PsiClassReferenceType.java:191)
	at com.intellij.psi.impl.source.PsiClassReferenceType.resolve(PsiClassReferenceType.java:138)
	at org.jetbrains.kotlin.asJava.classes.LightReferenceListBuilder.addReference(LightReferenceListBuilder.java:53)
	at org.jetbrains.kotlin.asJava.classes.KtUltraLightClass.createExtendsList(ultraLightPsi.kt:91)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration$_extendsList$2.invoke(KtLightClassForSourceDeclaration.kt:77)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration$_extendsList$2.invoke(KtLightClassForSourceDeclaration.kt:73)
	at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration.get_extendsList(KtLightClassForSourceDeclaration.kt)
	at org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration.getExtendsList(KtLightClassForSourceDeclaration.kt:320)
	at com.intellij.psi.impl.PsiClassImplUtil.getExtendsListTypes(PsiClassImplUtil.java:1017)
	at com.intellij.psi.impl.light.AbstractLightClass.getExtendsListTypes(AbstractLightClass.java:137)
	a
2018-11-08 15:25:41 +03:00
Denis Zharkov 34e8ce6a48 Fix data race in LightReferenceListBuilder
Effectively this is a cherry-pick of
https://github.com/JetBrains/intellij-community/commit/75032008695977f171540b5f0e055b77aa682c0c
2018-11-08 15:25:41 +03:00
Denis Zharkov 94d9fd8b72 Add our own version of LightReferenceListBuilder
There are some issues with one from the platform that may be backported
at some moment, but now it's faster to have our own implementation
2018-11-08 15:25:41 +03:00
Denis Zharkov 875e9d2a36 Fix KtUltraLightMethod::getParameterList
There's already a correct override in KtLightMethodImpl
Otherwise the tests is failing because clsDelegate.parameterList
has a wrong parent
2018-11-08 15:25:41 +03:00
Denis Zharkov 5f45ab1e2b Support forcing usage of ultra-light classes in tests 2018-11-08 15:25:41 +03:00
Denis Zharkov 03e937ddfa Minor. Reformat KtLightClassForSourceDeclaration.kt 2018-11-08 15:25:41 +03:00
Mikhael Bogdanov d2a205c72d Update synthetic parameter processing logic according to ASM 7 changes
#KT-27774 Fixed
2018-11-07 15:42:57 +01:00
peter e93a90bc09 fix some cases of "Cls delegate shouldn't be loaded for not too complex ultra-light classes" 2018-10-26 20:41:56 +02:00
Alexander Udalov cfffd21fa9 Fix KtLightAnnotationsValues.kt for 173
See 17076cd05e
2018-10-26 20:17:52 +02:00
peter cd1560e0b4 provide correct context for method return type
to fix generics in

class A<E> {
   fun foo(): E = null!!
}

public class B {
   public static void main(String[] args) {
       A<String> a = new A<>();
       a.foo().length(); // Unresolved length, because it thinks that `a.foo()` returns E
   }
}
2018-10-26 18:42:41 +02:00
peter ebc998d710 add ultra-light classes/members that work without backend in simple cases 2018-10-25 18:22:33 +02:00
Alexander Udalov 17076cd05e Support class literal values in light annotations correctly
Map Kotlin built-in classes (e.g. Throwable) to corresponding Java
classes, do not map Unit to void, support arrays of primitives and
arrays of wrapper types
2018-10-25 16:27:23 +02:00
Alexander Podkhalyuzin 85ba637796 Light classes should reuse language versions settings during generation
#KT-26732 Fixed
2018-09-12 16:02:07 +03:00
Alexander Udalov fc87043cb3 Merge use-site targeted annotations into corresponding Annotations
Add PropertyDescriptor.backingField/delegateField to store annotations
on the field directly in an otherwise almost empty descriptor instance,
instead of storing them with use-sites in the corresponding property
descriptor. Instead of AnnotationWithTarget, create AnnotationDescriptor
instances in AnnotationSplitter. Change DescriptorRenderer to render
annotations on "related" declarations when needed, with the explicit
use-site target if applicable.

Most changes in diagnostic test data are related to the fact that
annotations which are known to have an incompatible use-site to the
declaration they're applied at (such as `@param:`-annotation on a
function), are now not loaded at all. It's fine because the code is
erroneous, so it doesn't really matter how do we load annotations with
invalid targets (some of this logic is also changed freely in subsequent
commits). Some changes are also explained by the fact that for example
an annotation on the property which is only applicable to FIELD is now
rendered with an explicit use-site target `@field:`, regardless of
whether it did have that use-site target syntactically or not.

Basically, after this change there's no point in calling
Annotations.getUseSiteTargetedAnnotations/getAllAnnotations anymore
because it's easier and more intuitive to just use Annotations of the
corresponding descriptor -- the backing / delegate field (introduced in
this commit) or the extension receiver / setter parameter (related
behavior was fixed in previous commits). Usages of
use-site-target-related methods will be refactored out in subsequent
commits
2018-09-06 19:13:11 +03:00
Alexander Udalov 896cf61443 Move JVM-specific annotation FQ names and utils to frontend.java 2018-08-27 23:37:06 +02:00
Nicolay Mitropolsky 9db2b6ffba KtLightPsiJavaCodeReferenceElement reference getting made lazy (KT-26036, EA-125884)
Collecting references from contributors could be expensive and even recursive (EA-125884)
2018-08-13 19:26:07 +03:00
Nicolay Mitropolsky 2ba2d360c2 KtLightPsiJavaCodeReferenceElement delegate made nullable (KT-26036, EA-124029) 2018-08-13 19:26:06 +03:00
Nicolay Mitropolsky 3c71761cf3 lightAnnotations: check element validity before resolving call 2018-07-13 15:46:44 +03:00
Nicolay Mitropolsky cedc6821c3 lightAnnotations: proper parents for KtLightAnnotationsValues 2018-07-13 15:45:30 +03:00
Nicolay Mitropolsky be611cd154 LightAnnotations don't try to get kotlinOrigin if not building from sources 2018-07-11 09:37:28 +03:00
Nicolay Mitropolsky eaa58c3ec2 KtLightParameter should have a KtLightModifierList anyway
otherwise we wouldn't get proper annotations for `equals` in data-classes
2018-07-11 09:37:28 +03:00
Alexander Udalov 959c2f4843 Get rid of split packages in descriptors, descriptors.jvm, deserialization
Also move some other files to related packages and reformat moved files
2018-07-06 14:08:35 +02:00
Nicolay Mitropolsky 5d9807ac36 Uast: converting Unit to void on type mapping (KT-25249) 2018-07-04 16:16:22 +03:00
Nicolay Mitropolsky 01e9dd5085 don't use project scope to resolve java.lang.String (#KT-25024) 2018-06-22 20:28:55 +03:00
Pavel V. Talanov 5063a4ce3d JavaElementFinder: revert to using ContainerUtil.quicksort
Fix comparator contract violated exception
Scopes inherited from LibraryScopeBase violate the comparator contract
2018-06-19 13:40:23 +02:00
Pavel V. Talanov 2d7df21b0f JavaElementFinder: fix classes not being sorted as intended
This is tested by `whole project` inspection tests

 #KT-24704 Fixed
2018-06-14 10:51:13 +02:00
Yan Zhulanow ab5614eaac Minor: Replace a number of trivial Guava usages with constructor calls and kotlin-stdlib function calls 2018-06-08 19:37:47 +03:00
Alexey Sedunov 862dc76ed9 Rename: Fix processing of overriding methods with mangled names
#KT-24460 Fixed
2018-06-08 14:34:22 +03:00
Pavel V. Talanov d18846201a JavaElementFinder: avoid returning fake light class in findClass*
findClass* are supposed to return a single visible class
    from given scope with given fqname
After sorting FakeFileForLightClass would sometimes be first in the list
    leading to exceptions like KT-24704

  #KT-24704 Fixed
2018-06-06 20:45:41 +02:00
Pavel V. Talanov 86e52f45b1 J2K JavaElementFinder: prettify code 2018-06-06 20:45:41 +02:00
Pavel V. Talanov 6cea843461 J2K JavaElementFinder: autoconvert and fix compilation errors 2018-06-06 20:45:41 +02:00
Pavel V. Talanov 00b1e9281b J2K JavaElementFinder: rename file 2018-06-06 20:45:41 +02:00
Nicolay Mitropolsky 0fb879dfc2 lightAnnotations: KtLightPsiClassObjectAccessExpression added
as implementation of `PsiClassObjectAccessExpression` for class literals in annotations
2018-06-05 18:00:15 +03:00
Nicolay Mitropolsky da5ef06abf KtLightNullabilityAnnotation evaluated from sources 2018-05-28 17:06:35 +03:00
Nicolay Mitropolsky eea66bea73 Making LightAnnotation work without clsDelegate (KT-20924, KT-22883) 2018-05-28 17:06:35 +03:00
Mikhael Bogdanov f826a253e3 Generate @JvmDefault for property accessors in LIGHT_CLASS MODE 2018-05-23 13:55:38 +02:00
Nikolay Krasko 062a212b61 Don't build light classes for local classes with parse errors (KT-24323, EA-107235)
Also use checks for building light classes in `getLightClassDataHolder`.
2018-05-16 12:55:09 +03:00
Vyacheslav Gerasimov 8c88ac69df Cleanup .181 bunch files 2018-04-27 18:25:21 +03:00
Vyacheslav Gerasimov bc403ce744 Switch to 181 platform 2018-04-27 18:25:17 +03:00
Nikolay Krasko ecd2db3b48 Remove bunch files that are equal to base files 2018-04-16 15:55:53 +03:00