Commit Graph

28427 Commits

Author SHA1 Message Date
Denis Zharkov c4bc2c9ba6 J2K Renderer: convert and make contravariant 2015-12-01 08:21:02 +03:00
Denis Zharkov 5a5889e3f3 J2K Renderer: .java -> .kt 2015-12-01 08:21:01 +03:00
Denis Zharkov 303c756302 Refine generic signature for fields
- For vals use the same semantics as for return types
- For vars use the same semantics as for value parameters
2015-12-01 08:21:01 +03:00
Denis Zharkov 64e0af48ed Minor. Change default for needPrimitiveBoxing 2015-12-01 08:21:01 +03:00
Denis Zharkov ddb67d6c9c Support JvmSuppressWildcards and JvmWildcard annotations
#KT-9898 Fixed
2015-12-01 08:21:00 +03:00
Denis Zharkov 6292833a69 Refine generic signature for Map.get/remove
Before this change generic signature wasn't written because of wrong
assumption about it absence in all cases where we replace generic parameter
with Object
2015-12-01 08:21:00 +03:00
Denis Zharkov 20cbceb56d Add temporary hack for wildcards in Collections
By default we would render 'MutableCollection<String>.addAll(Collection<String>)' as
'(LCollection<String>;)' (without wildcard) because String is final and
effectively it's the same as '(LCollection<? extends String>;)'.

But that's wrong signature in a sense that java.util.Collection has different
signature: '(LCollection<? extends E>)'.

Actually the problem is much wider than collections,
it concerns any Java code that uses Kotlin classes with covariant
parameters without '? extends E' wildcards.

Temporary solution is just to hardcode/enumerate builtin methods
with special signature.
2015-12-01 08:20:59 +03:00
Denis Zharkov 0255be7deb Minor. Pass callableDescriptor into writeParameter 2015-12-01 08:20:59 +03:00
Denis Zharkov 406e31f54a Change default rules for declaration-site wildcards
Mostly this commit is about skipping wildcards that are redundant in some sense.
The motivation is that they looks `long` in Java code.

There are basically two important parts: return types and value parameters.

1. For return types default behaviour is skipping all declaration-site wildcards.
The intuition behind this rule is simple: return types are basically used in subtype position
(as an argument for another call), and here everything works well in case of 'out'-variance.
For example we have 'Out<Out<T>>>' as subtype both for 'Out<Out<T>>>' and 'Out<? extends Out<? extends T>>>',
so values of such type is more flexible in contrast to `Out<? extends Out<? extends T>>>` that could be used only
for the second case.

But we have choosen to treat `in`-variance in a different way: argument itself
should be rendered without wildcard while nested arguments are rendered by the rules
described further (see second part).

For example: 'In<Out<OpenClass>>' will have generic signature 'In<Out<? extends OpenClass>>'.
If we omit all wildcards here, then value of type 'In<Out<OpenClass>>'
will be impossible to use as argument for function expecting 'In<? super Out<? extends Derived>>'
where Derived <: OpenClass (you can check it manually :]).

And this exception should not be very inconvinient because in-variance is rather rare.

2. For value parameters we decided to skip wildcards if it doesn't make obtained signature weaker
in a sense of set of acceptable arguments.

More precisely:
    a. We write wildcard for 'Out<T>' iff T ``can have subtypes ignoring nullability''
    b. We write wildcard for 'In<T>' iff T is not equal to it's class upper bound (ignoring nullability again)

Definition of ``can have subtypes ignoring nullability'' is straightforward and you can see it in commit.

 #KT-9801 Fixed
 #KT-9890 Fixed
2015-12-01 08:20:59 +03:00
Denis Zharkov 1731cb8b40 Make jvmSignature optional in WriteSignatureTest 2015-12-01 08:20:58 +03:00
Denis Zharkov 917420f332 Convert TypeMappingMode from enum to plain class with constant instances 2015-12-01 08:20:58 +03:00
Denis Zharkov faf1e17888 Introduce TypeMappingMode.toGenericArgumentMode 2015-12-01 08:20:57 +03:00
Denis Zharkov ef2bc28463 Minor. Rename TypeMappingMode entries 2015-12-01 08:20:57 +03:00
Denis Zharkov d22aaf9d52 Introduce writeDeclarationSiteProjections option into TypeMappingMode 2015-12-01 08:20:57 +03:00
Denis Zharkov d8297cd6f1 Extract, rename and konvert TypeMappingMode 2015-12-01 08:20:56 +03:00
Denis Zharkov 6cf7cd5c07 Minor. Rename VALUE -> DEFAULT 2015-12-01 08:20:56 +03:00
Denis Zharkov 8a748703c8 Simplify type mapping for builtin types 2015-12-01 08:20:55 +03:00
Ilya Gorbunov e5dd719eec Fix warning about incompatible types. 2015-12-01 01:35:19 +03:00
Ilya Gorbunov 0ffce06356 Hide toMap with keySelector
#KT-6657
2015-12-01 01:18:46 +03:00
Ilya Gorbunov ea60ab74a7 Replace deprecated toMap usages with toMapBy 2015-12-01 01:18:44 +03:00
Ilya Gorbunov f107559a3c Docs: proper pluralization of 'entry' 2015-12-01 01:18:21 +03:00
Ilya Gorbunov 6ca647aecd Minor: cleanup asSequence() documentation. 2015-12-01 01:18:19 +03:00
Ilya Gorbunov f596d9ac23 Provide asIterable also for CharSequences, Maps and Iterables.
KT-10152 Fixed
2015-12-01 01:18:18 +03:00
Andrey Breslav 45db5db7e8 Forbid prefixes and suffixes for numeric literals 2015-11-30 19:36:33 +03:00
Andrey Breslav 8544a5ab5f Remove "This" keyword 2015-11-30 19:36:33 +03:00
Andrey Breslav aca355acdc '...' reserved as a token
KT-9708 Ambiguous syntax for Double ranges: `.1...2` (triple dot)

 #KT-9708 Fixed
2015-11-30 19:36:33 +03:00
Alexander Udalov 877129340f Revert "Rename Extension annotation to ExtensionFunctionType"
This reverts commit 460dad135c.

The old compiler will not see the new runtime correctly. Postponing this until
1.0
2015-11-30 19:24:58 +03:00
Alexander Udalov 745809c666 Rename TestlibTest -> StdlibTest 2015-11-30 19:19:20 +03:00
Mikhail Glukhikh fe04cc513b Original type is taken into account when intersecting possible types in resolve #KT-10232 Fixed 2015-11-30 19:09:44 +03:00
Alexander Udalov db2521ee67 Rework TestlibTest, use JUnit console runner instead of manual suite
The problem with the manually created suite was that it was created in setUp()
and so a lot of the hard work (compilation, test case lookup) was happening in
setUp(). If any exception is thrown in setUp(), tearDown() is not called,
leaving the application (~9000+ subsequent tests) in the inconsistent state.

Support JUnit 4 tests via JUnit4TestAdapter. Previously only a small number of
test classes were actually run because this test was looking only for JUnit 3
testcases.

Delete FilesTest#relativePath because it was testing a deprecated function
and was failing if run from the project root
2015-11-30 18:58:00 +03:00
Natalia Ukhorskaya 74b6f70c80 JDIEval: do not disable collection when invoke method using reflection 2015-11-30 18:46:40 +03:00
Michael Bogdanov df1641ff9b Fix for KT-10047: java.lang.VerifyError: Bad return type
#KT-10047 Fixed
2015-11-30 18:44:13 +03:00
Pavel V. Talanov 54addb4b1e Script run configuration: Set working directory to a directory containing script file by default 2015-11-30 18:21:06 +03:00
Pavel V. Talanov 5a55ee332e FileBasedDeclarationProviderFactory: stable order of files
Fixes DiagnosticsTestGenerated#testScriptAndClassConflict
2015-11-30 18:21:06 +03:00
Pavel V. Talanov 4a1c3f02fd Add basic tests for KotlinStandaloneScriptRunConfiguration 2015-11-30 18:21:05 +03:00
Pavel V. Talanov 7577a375ae Minor: use script name generating code to generate names for script run configurations 2015-11-30 18:21:04 +03:00
Pavel V. Talanov d6c7029c77 Compiler, Scripts: strip stacktrace when reporting exception on script execution 2015-11-30 18:21:04 +03:00
Pavel V. Talanov 567f946cb0 K2JVMCompiler: Do not report perf in script mode 2015-11-30 18:21:03 +03:00
Pavel V. Talanov 34793e63c7 Allow to run kts files as scripts from ide
Introduce KotlinStandaloneScriptRunConfiguration: configuration, type, producer, settings editor
2015-11-30 18:21:03 +03:00
Pavel V. Talanov 337701670c Refactor script registering in frontend and jvm backend 2015-11-30 18:21:02 +03:00
Pavel V. Talanov 6520e9aed6 Refactor: AnalyzerScriptParameter -> ScriptParameter 2015-11-30 18:21:02 +03:00
Pavel V. Talanov 0d10f0fcf9 Minor: Remove direct usages of ScriptNameUtil 2015-11-30 18:21:01 +03:00
Pavel V. Talanov 7956ebe46c Move script related stuff into a separate package 2015-11-30 18:21:00 +03:00
Pavel V. Talanov 89081d487f J2K KotlinScriptDefinition and simplify 2015-11-30 18:21:00 +03:00
Alexey Sedunov 15b7eca665 Move: Detect extension declaration by PSI instead of descriptor as extension descriptor maybe wrapper for Java method
#KT-10203 Fixed
2015-11-30 16:27:23 +03:00
Michael Bogdanov 1bf521c645 Don't generate accessors for @JvmField properties in primary constructor 2015-11-30 16:24:05 +03:00
Mikhail Glukhikh de37cb8f40 Generic types may not extend kotlin.Throwable #KT-9816 Fixed 2015-11-30 15:24:32 +03:00
Mikhail Glukhikh c6be69a483 No more reified types for catch parameter #KT-9742 Fixed 2015-11-30 15:24:24 +03:00
Dmitry Petrov f0e467e474 Rewrite mixed multiple- and single-condition 'when' properly.
#KT-10229 Fixed
2015-11-30 14:43:03 +03:00
Ilya Gorbunov f7a780f32c Extension contains for ranges: rename parameter item to value. 2015-11-30 14:12:11 +03:00