Commit Graph

46 Commits

Author SHA1 Message Date
Denis Zharkov
23d2b87a52 Ignore redundant projections for declaration-site variance 2016-01-14 19:20:00 +03:00
Denis Zharkov
154657a374 Fix wildcards for invariant arguments
See test with Java, we want preserve the invariant that if return type and
value parameter types are same in Kotlin, than we can use such return-value
as argument for that parameter
2015-12-15 16:18:31 +03:00
Zalim Bashorov
1e0b133e19 Find Nothing only in own arguments of generic type to make type raw and generate ''?" for contravariant position instead of use raw type 2015-12-07 19:25:59 +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
ddb67d6c9c Support JvmSuppressWildcards and JvmWildcard annotations
#KT-9898 Fixed
2015-12-01 08:21:00 +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
8cb85759c7 Fix written generic signature in case of inner types 2015-11-13 14:59:03 +03:00
Denis Zharkov
9c8ad9e442 Fix AbstractWriteSignatureTest
It didn't check anything in tests with class signatures
2015-11-13 14:47:29 +03:00
Dmitry Petrov
e7fb7483c5 Drop package facades: update compiler tests. 2015-10-19 16:03:16 +03:00
Zalim Bashorov
9acf3e40de Generic type with Nothing in arguments compiles to raw type 2015-10-16 15:30:41 +03:00
Dmitry Petrov
a47eaa2cb5 Change part class naming scheme
update tests depending on part class naming
2015-09-07 16:28:42 +03:00
dnpetrov
a2b2eba1a1 Extended version of AbstractWriteSignatureTest:
- support multiple expectations in file
- support field signature expectations
- report failures in a more usable format
2015-06-17 13:45:08 +03:00
Denis Zharkov
2df6fcb785 Drop some tests using java.lang.Class in annotation
We are going to drop such cases anyway, but they're annoying when reverting commits
2015-06-12 09:55:02 +03:00
Dmitry Jemerov
4bdf598bfe compiler testdata: s/trait/interface 2015-05-12 19:43:17 +02:00
Denis Zharkov
2a03994ecb JVM: Write signature for annotation parameter 2015-04-16 10:40:20 +03:00
Alexander Udalov
8af6ca5279 Delete kotlin.jvm.internal.KObject
It was supposed to be used in reflection but the benefits do not outweigh the
cost of KT-6951

 #KT-3223 Fixed
 #KT-6951 Fixed
2015-03-12 23:15:38 +03:00
Andrey Breslav
da639039bd KT-6698 Bad class file when using a star-projection on a Java's recursive generic parameter
#KT-6698 Fixed
2015-02-02 19:52:00 +03:00
Alexander Udalov
226bfe65f0 Don't make traits and annotations inherit from KObject
#KT-5609 Fixed
2014-08-13 17:19:56 +04:00
Alexander Udalov
f7b6457139 Replace "jet" package name with "kotlin" in testData 2014-03-02 19:55:26 +04:00
Alexander Udalov
0da92e22a2 Move jet.JetObject -> kotlin.jvm.internal.KObject
Don't use JetObject as a marker class in KotlinRuntimeLibraryUtil anymore,
since there are other classes for this purpose (KotlinPackage, Unit)
2014-03-02 19:54:58 +04:00
Evgeny Gerashchenko
836077916b Fixed tests after adding JetObject to generic signature. 2014-01-29 21:51:53 +04:00
Andrey Breslav
ed95463d1e Map Nothing to java.lang.Void 2013-10-25 15:39:01 +04:00
Andrey Breslav
7f46d7555e Do not write "? extends" and "? super" in immediate arguments of supertypes in Java generic signatures 2013-10-08 21:13:30 +04:00
Pavel V. Talanov
5f108905d1 Remove testing Kotlin signature from WriteSignatureTest 2013-08-26 15:59:34 +04:00
Yakov Zaytsev
bb364cd393 KT-3771 Fixed 2013-07-22 18:49:56 +04:00
Mikhael Bogdanov
d9fd04dd43 Refactoring: code duplication removed from accessor generators 2013-03-20 20:50:05 +04:00
Natalia.Ukhorskaya
47abdcf565 Rename namespace class to {package.name}Package
Conflicts:

	compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java
2013-01-15 19:45:06 +04:00
Andrey Breslav
889ea107f6 Reflect Kotlin's declaration-site variance in Java signatures 2012-11-24 15:59:15 +04:00
Svetlana Isakova
45dbf36b53 added tests for kotlin signature for Map.Entry 2012-09-20 14:42:39 +04:00
Svetlana Isakova
47769ed638 tests changed after KT-2745
Write exact Kotlin type (if it's mapped) in signature while generating bytecode
 #KT-2745 fixed
2012-09-19 13:06:25 +04:00
Svetlana Isakova
7c828b9ff7 diagnostic tests changes after collections mapping 2012-09-05 18:55:16 +04:00
Andrey Breslav
91606a3901 Introduce 'reified' instead of 'erased' 2012-06-05 20:19:07 +04:00
Stepan Koltsov
e2cb98df67 better import jet namespace 2012-03-19 23:25:27 +04:00
Stepan Koltsov
c9e3891a5e fix test 2012-03-02 21:25:18 +04:00
Stepan Koltsov
c15bd2f75d KT-1490 serialization of constructor parameters 2012-03-02 20:43:47 +04:00
Alex Tkachman
8b622f97f4 getting rid of TypeInfo 2012-02-21 14:54:00 +02:00
Stepan Koltsov
4545c72f69 properly serialize/parse Nothing type 2012-01-25 22:23:46 +04:00
Stepan Koltsov
614ee5d690 java.lang.String in signature should serialized and mapped back to java.lang.String 2012-01-24 00:38:26 +04:00
Stepan Koltsov
f21ad2f536 fix couple of bugs in constructor signature serialization/parsing 2012-01-23 22:49:46 +04:00
Stepan Koltsov
6ceb6816be ReadKotlinBinaryClassTest: List<*> 2012-01-18 12:03:42 +04:00
Stepan Koltsov
82880c82e3 WriteSignatureTest for varargs 2012-01-13 03:55:10 +04:00
Stepan Koltsov
046a92ed7a add lost tests 2012-01-11 19:36:48 +04:00
Stepan Koltsov
2338af30a0 arrays in signatures: more tests, fix bugs 2012-01-06 23:21:31 +04:00
Stepan Koltsov
74e72fbbc6 fix comparable signature generation
fix todo by Alex Tkachman 2ec54436c5
2012-01-03 21:15:26 +04:00
Stepan Koltsov
a7a1bd2102 omit generic signature for simple methods 2012-01-03 21:15:21 +04:00
Stepan Koltsov
52400dbd1e explicit test for java signature writing
(partially replaces CompileJavaAgainstKotlinTest)
2012-01-03 21:15:12 +04:00