Commit Graph

34888 Commits

Author SHA1 Message Date
Alexander Udalov 1cfb8f2aef Use OverridingUtil#overrides instead of CodegenUtil#doesOverride
This may be more correct in case of complex cross-module inheritance, where
overridability should be detected by structural equality of signatures instead
of referential equality of constructed descriptors (no test added because it's
not so easy to come up with an example)
2016-10-25 15:42:34 +03:00
Alexander Udalov 4e7542b07d Filter out non-builtin package fragments from module when needed
In subsequent commits, a JVM module will be able to have up to two package
fragments for a given package FQ name. For example, for package "kotlin" in
kotlin-runtime.jar there will be a LazyJavaPackageFragment with binary
(Kotlin+Java) dependencies, and a BuiltInsPackageFragment for built-ins
metadata (which is loaded from kotlin/kotlin.kotlin_builtins)
2016-10-25 15:42:33 +03:00
Alexander Udalov 9ce211fe87 Use FQ names instead of descriptor equality in RangeCodegenUtil
This is safer in cases when descriptors for the same declaration can come from
different package fragment providers
2016-10-25 15:42:33 +03:00
Alexander Udalov ccd480236a Add mock JDK and mock runtime to light class tests 2016-10-25 15:42:33 +03:00
Alexander Udalov 035d6156a7 Drop Cloneable in JS, synthesize it at compile-time on JVM
Use the same approach that is used for creating function type classes
(Function{0,1,...}) + add Cloneable to supertypes of Array and primitive arrays

 #KT-5537 Fixed
2016-10-25 15:42:33 +03:00
Alexander Udalov 0f4b10d37d Add JavaToKotlinClassMap#isJavaPlatformClass
Use it instead of mapPlatformClass where we only need to check emptiness
because mapPlatformClass requires built-ins and it's not always easy to come up
with the correct instance of built-ins.

In KotlinEvaluationBuilder, use the nullable function
findClassAcrossModuleDependencies instead of mapPlatformClass which uses the
throwing resolveClassByFqName. This is necessary because DefaultBuiltIns, which
are used there, are not always able to find classes mapped by a _Java_ to
Kotlin class map. (The correct solution would be not to use DefaultBuiltIns at
all, instead obtaining the correct instance of built-ins, which are almost
certainly going to be JvmBuiltIns, from the project configuration.)
2016-10-25 15:42:32 +03:00
Alexander Udalov 2f81d48f5e Use ClassId instead of FqName in JavaToKotlinClassMap
Extract mapJavaToKotlin which returns ClassId and needs no KotlinBuiltIns
instance
2016-10-25 15:42:32 +03:00
Alexander Udalov 0e9f29fdba Make ClassDescriptor#classId nullable
Local classes or anonymous objects do not have a class id. Use "!!" almost
everywhere to make assertion explicit
2016-10-25 15:42:32 +03:00
Alexander Udalov 17e54b6d2d Add ClassDescriptorFactory#getAllContributedClassesIfPossible
Currently a no-op, will be used soon to make Cloneable a synthesized class,
visible in scope's getContributedDescriptors()
2016-10-25 15:42:32 +03:00
Alexander Udalov c0147860bd Allow multiple ClassDescriptorFactory instances in deserialization 2016-10-25 15:42:32 +03:00
Nikolay Krasko cdabef51ed Add nullability to receiver type 2016-10-25 13:30:38 +03:00
Nikolay Krasko 22999fe67d Set hasValueArguments in KotlinAnnotationEntryStub to 'true' only if some arguments exist
Currently '()' is used for resolving ambiguity in parsing when annotating function types. This way a decompiled code
will need brackets, but compile code will have annotation without parameters. This commit will allow to make both stub-trees consistent.

Tested in ClsStubBuilderTestGenerated.testAnnotationsOnNullableTypes()
2016-10-25 13:30:37 +03:00
Nikolay Krasko a344ad0644 Fix absence of annotation for function type in cls stubs and ignore @ExtensionFunctionType 2016-10-25 13:30:35 +03:00
Nikolay Krasko d1dfcfaca1 Fix stub-psi mismatch exception on restoring annotation for nullable types
(cherry picked from commit 1aa37f11258dde289a9f7cb700294a038168fbdc)

Conflicts:
	compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt
	idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt
2016-10-25 13:22:53 +03:00
Mikhail Glukhikh e53940f4af KT-8442 related: correct handling of erroneous destructuring references, fixes EA-90434 2016-10-25 13:13:15 +03:00
Mikhail Glukhikh e7e56ab85c KT-8442 related: destructuring declarations aren't taken into account during light classes generation, fixes EA-81204 2016-10-25 13:13:11 +03:00
Denis Zharkov b7e8071a7d Do not use BasicInterpreter for bytecode analysis
The problem with BasicInterpreter is the following:
it creates BasicValue objects that should be replaced in favor of StrictBasicicValue

See commit message in 25c6ac1 for clarification

 #KT-14447 Fixed
2016-10-25 10:14:52 +03:00
Denis Zharkov e9efc9e892 Replace usages of BasicValue constants in master with StrictBasicValue 2016-10-25 10:14:52 +03:00
Denis Zharkov d279ded714 Add license and links to rewritten ASM classes 2016-10-25 10:14:52 +03:00
Denis Zharkov 3a197e8d7e Fix NPE caused by nullability checks optimizations
Mostly this commit replaces instances of original BasicValue from ASM
with ones of StrictBasicValue having strict equals implementation

Optimization issue was related to non-symmetric 'equals':
- NotNullBasicValue("java/lang/Object").equals(BasicValue("java/lang/Object")) == false
- BasicValue("java/lang/Object").equals(NotNullBasicValue("java/lang/Object")) == true

 #KT-14242 Fixed
2016-10-25 10:14:52 +03:00
Valentin Kipyatkov 18f10860df KT-14336 for to stdlib to takeWhile: propose conversion into takeWhile if break is located in else branch
#KT-14336 Fixed
2016-10-24 18:32:05 +03:00
Valentin Kipyatkov 5c8db294df Fixed index variable case 2016-10-24 18:32:05 +03:00
Valentin Kipyatkov e5fcfae969 KT-13998 Loop to call chain converter produces 'none' instead of 'all'
#KT-13998 Fixed
2016-10-24 18:32:04 +03:00
Valentin Kipyatkov 89099b93b1 Split or glue together checks for not null and is instance + more intelligent use of filter vs filterTo
#KT-14284 Fixed
 #KT-14286 Fixed
 #KT-14287 Fixed
 #KT-14303 Fixed
2016-10-24 18:32:04 +03:00
Valentin Kipyatkov 53220b980e More correct checking of forEach requiring asSequence() 2016-10-24 18:32:04 +03:00
Valentin Kipyatkov a87ca8432e KT-14341 for to stdlib to forEach: if the loop variable is not used in the last/innerest statement the conversion is not proposed
#KT-14341 Fixed
2016-10-24 18:32:03 +03:00
Valentin Kipyatkov 5ca7688b7c Correct handling of explicit variable type 2016-10-24 18:32:03 +03:00
Valentin Kipyatkov 9326dfa048 Honor errors in code before when checking smart casts 2016-10-24 18:32:03 +03:00
Valentin Kipyatkov eae23b548f KT-14294 for to stdlib to firstOrNull/lastOrNull: intention is absent if there is additional var before for loop
#KT-14294 Fixed
2016-10-24 18:32:03 +03:00
Valentin Kipyatkov a89ef54578 KT-14210 for loop to stdlib: max/min is not recognized if there is additional if
#KT-14210 Fixed
2016-10-24 18:32:02 +03:00
Valentin Kipyatkov 35ed689b9f any() and other find operations to work with checks for not null and is instance 2016-10-24 18:32:02 +03:00
Valentin Kipyatkov 49ef880f3a Moved matcher 2016-10-24 18:32:02 +03:00
Valentin Kipyatkov b28d016709 count() to merge with filterNotNull and filterIsInstance + changed test for KT-14191 to use sum() 2016-10-24 18:32:02 +03:00
Valentin Kipyatkov afd25548a2 KT-14209 for loop to stdlib: sum is not recognized if before was check for type
#KT-14209 Fixed
2016-10-24 18:32:01 +03:00
Valentin Kipyatkov f5d4b1dc8d KT-14191 FormattingModelInconsistencyException Exception on applying intention Replace with count()
#KT-14191 Fixed
2016-10-24 18:32:01 +03:00
Denis Zharkov 10861e57ff Fix NDFDE for single underscore named property in primary constructor
NDFDE = NoDescriptorForDeclarationException

See the comment in change
2016-10-24 18:00:02 +03:00
Denis Zharkov 09dc207052 Add SingleUnderscoreForParameterName language feature 2016-10-24 18:00:02 +03:00
Denis Zharkov 1f0293eb42 Check modifiers applicability on destructured lambda parameters
#KT-14502 Fixed
2016-10-24 18:00:02 +03:00
Nikolay Krasko 8865c0be34 Step into functions with local variable on first line under "Skip simple getters" (KT-14488)
(cherry picked from commit 9423d65)

 #KT-14488 Fixed
2016-10-24 16:28:17 +03:00
Alexander Udalov 3f5d3e5dbc Fix errors and indent in built-ins sources 2016-10-24 15:30:40 +03:00
Alexander Udalov 2076a31094 Improve Collection/Array/String detection logic in intentions
Use static methods from KotlinBuiltIns and check all supertypes, support cases
of Collection, Map and CharSequence
2016-10-24 15:30:39 +03:00
Alexander Udalov a5a422fc4d Use TypeConstructor equality instead of ClassDescriptor in CollectionStubMethodGenerator
Equals/hashCode are meaningful for TypeConstructor instances (see
AbstractClassTypeConstructor.java) in contrast to ClassDescriptor where
equality is referential
2016-10-24 15:30:39 +03:00
Alexander Udalov 08398178e0 Make class descriptors in JvmRuntimeTypes lazy
The main reason currently is to avoid eager construction of
defaultContinuationSupertype long before it's needed, which could fail without
built-ins in the classpath
2016-10-24 15:30:39 +03:00
Alexander Udalov e1aaccaec1 J2K JvmRuntimeTypes: prettify 2016-10-24 15:30:39 +03:00
Alexander Udalov 32b672490f J2K JvmRuntimeTypes: convert 2016-10-24 15:30:39 +03:00
Alexander Udalov 9e4ffd9225 J2K JvmRuntimeTypes: rename .java -> .kt 2016-10-24 15:30:38 +03:00
Alexander Udalov d9f248ccf4 Minor refactoring in JvmDependenciesIndexImpl
Make SearchResult a sealed class, inline local function & trivial utility
2016-10-24 15:30:38 +03:00
Alexander Udalov 76523cc175 Split JvmDependenciesIndex to several files, move to 'index' package 2016-10-24 15:30:38 +03:00
Alexander Udalov cdf6567375 Drop TypeConstructor.getAnnotations(), uninherit TypeConstructor from Annotated
The method was unused on TypeConstructor instances, and almost all
implementations returned EMPTY anyway
2016-10-24 15:30:38 +03:00
Alexander Udalov 6b6ddf5f75 Import classes from kotlin.coroutines by default, add to default imports in JS 2016-10-24 15:30:38 +03:00