Commit Graph

2190 Commits

Author SHA1 Message Date
Chris Smowton
5fe65ed983 Extract no-when-branch-found calls
These are extracted as "throw new kotlin.NoWhenBranchFoundException();", which is the Java lowering of the intrinsic.

In the process, amend the control-flow graph to let when branches propagate `throw`s outwards, and similarly statement expressions.
2022-05-10 19:51:19 +01:00
Ian Lynagh
d09dff482c Kotlin: Add diagnostics table to the 'trap' test 2022-05-10 19:51:19 +01:00
Ian Lynagh
a512ee7ac1 Kotlin: Extend long-comment test 2022-05-10 19:51:19 +01:00
Ian Lynagh
4454ef7f95 Kotlin: Add tests for long comments 2022-05-10 19:51:18 +01:00
Ian Lynagh
9af99c584e Kotlin: Tweak test 2022-05-10 19:51:18 +01:00
Ian Lynagh
1d824a4e2f Kotlin: Add a test for truncated literals 2022-05-10 19:51:18 +01:00
Chris Smowton
da159d7239 Add test showing assign expressions 2022-05-10 19:51:18 +01:00
Chris Smowton
7cb6e19e44 Extract array update operations
These are of the form arrExpr[indexExpr] op= rhs
2022-05-10 19:51:18 +01:00
Tamas Vajk
d9c72b1c04 Fix changed expected file 2022-05-10 19:51:18 +01:00
Tamas Vajk
ff5bbee75a Change extracted base type of function references 2022-05-10 19:51:18 +01:00
Tamas Vajk
55428c0c3c Update test 2022-05-10 19:51:18 +01:00
Tamas Vajk
42803a161c WIP: add test for reflective calls 2022-05-10 19:51:18 +01:00
Tony Torralba
b626e80a61 Add test for StmtExpr flow 2022-05-10 19:51:18 +01:00
Chris Smowton
8af0f26411 Extract simple in-place operators
Complex in-place operators (someFieldOrArrayCell += e) get a harder-to-parse lowering which needs to be intercepted at the IrBlock level
2022-05-10 19:51:18 +01:00
Chris Smowton
2fb54de269 Extract ordinary array get and set operations as ArrayAccesses, not calls 2022-05-10 19:51:18 +01:00
Tamas Vajk
6154c2be18 Change arguments of big arity invoke call 2022-05-10 19:51:18 +01:00
Tamas Vajk
3f2c275e5f Fix functional interface selection 2022-05-10 19:51:18 +01:00
Tamas Vajk
46bd6b096e Add big arity SAM conversion test case 2022-05-10 19:51:18 +01:00
Tamas Vajk
a598c7fc0c Rework SAM conversion extraction (handle arbitrary expression that's being converted) 2022-05-10 19:51:17 +01:00
Tamas Vajk
34ae00fa62 Extract SAM lambda conversion 2022-05-10 19:51:17 +01:00
Chris Smowton
377a0f91f0 Add missing times operator 2022-05-10 19:51:17 +01:00
Chris Smowton
96f3ea460f Make varargs extraction more Java-like:
* Extract varargs as if they are ordinary positional arguments
* Adapt the QL that distinguishes varargs from ordinary arguments to account for Kotlin's varargs which can occur in the middle of the arg list
* Add a test checking dataflow through varargs which doesn't work yet due to array-get and array-set not being extracted as IndexExprs
* Extract the special case arrayOf(*x) as a clone call, which is (equivalent to) the Java lowering of that operation
2022-05-10 19:51:17 +01:00
Chris Smowton
7368b49b16 Implement Any?.String using java.lang.String.valueOf
This is how kotlinc does it, and doesn't involve an unchecked null deref like the existing use of Object.toString.
2022-05-10 19:51:17 +01:00
Tamas Vajk
616f20fa52 Handle more cases of qualified this references 2022-05-10 19:51:17 +01:00
Chris Smowton
d593185a8c Quieten errors relating to generic type aliases
Turns out type aliases are always substituted by the compiler, with the `IrSimpleType.abbreviation` field indicating what the original alias was if any. Therefore we're already extracting the right types. This commit simply omits extracting a kt_type for a type alias that uses type parameters as this certainly won't work at present because we don't have IrTypes for the type parameters declared by the alias and used in its RHS.
2022-05-10 19:51:17 +01:00
Chris Smowton
f6db91f294 Update test expectations 2022-05-10 19:51:17 +01:00
Chris Smowton
a120fab9f7 Complete implementation of equality tests
- Create a new operator representing an infix value [in]equality test, equivalent to Objects.equals(lhs, rhs)
- Continue to use simple equality where it is clearly possible at the callsite
- Note that ieee754equals is the same as Java's == and != operators
2022-05-10 19:51:17 +01:00
Ian Lynagh
458cb850a7 Kotlin: Accept test changes 2022-05-10 19:51:16 +01:00
Chris Smowton
377bd8f2e9 Extract String?.plus as either an AddExpr or a call to an intrinsic
If it is used by the compiler to implement the infix plus operator, resugar it and extract a `+` as Java would. If it is literally called by the user (e.g. `(if (x) then "not null" else null).plus(something)`), then extract a call to the real method Intrinsics.stringPlus (a two-arg static method).
2022-05-10 19:51:16 +01:00
Chris Smowton
93e8d5a2d6 Add tests for mutually-recursive types 2022-05-10 19:51:16 +01:00
Chris Smowton
8bb23651ae Extract type parameter bounds 2022-05-10 19:51:16 +01:00
Tamas Vajk
2965e780cc Add local dataflow test for string templates 2022-05-10 19:51:16 +01:00
Tamas Vajk
d495badc1e Rename companion object QL class 2022-05-10 19:51:16 +01:00
Tamas Vajk
4adf5829e4 Fix expected files 2022-05-10 19:51:16 +01:00
Tamas Vajk
cd5555a5dd Extract companion objects from interfaces 2022-05-10 19:51:15 +01:00
Chris Smowton
4d408159aa When extracting a call to an inherited method, substitute the callee's type parameters appropriately. 2022-05-10 19:51:15 +01:00
Ian Lynagh
46ccd45833 Kotlin: Add tests for fake overrides 2022-05-10 19:51:15 +01:00
Chris Smowton
27b0d579d0 Add compilation-units test 2022-05-10 19:51:14 +01:00
Chris Smowton
024f8c651e Accept test changes 2022-05-10 19:51:14 +01:00
Chris Smowton
863037ec41 Always extract methods of user-class supertypes
This matches the Java extractor's behaviour. Also if we re-visit a class to extract its members, revisit its supertypes to extract their members too.
2022-05-10 19:51:14 +01:00
Tamas Vajk
8f48c1b161 Add test for missing generic method 2022-05-10 19:51:14 +01:00
Ian Lynagh
c0f194316f Kotlin: Update test following changes to casting operators 2022-05-10 19:51:13 +01:00
Ian Lynagh
ad33c47536 Kotlin: Add a test for Kotlin seeing Java code as properties 2022-05-10 19:51:13 +01:00
Ian Lynagh
579c590ea6 Kotlin: Accept test changes following "casting" operator changes 2022-05-10 19:51:13 +01:00
Chris Smowton
221fa37081 Fix naming of local class instances that fall within generic functions 2022-05-10 19:51:13 +01:00
Ian Lynagh
735520a4ce Kotlin: Accept test changes in types test 2022-05-10 19:51:13 +01:00
Tamas Vajk
646fc58c25 Fix expected test files 2022-05-10 19:51:13 +01:00
Tamas Vajk
44b731c68e Exclude extraction of fake overridden properties 2022-05-10 19:51:13 +01:00
Tamas Vajk
55b8e4400d Code quality improvements 2022-05-10 19:51:13 +01:00
Tamas Vajk
b6e5e1977d Extract more visibility modifiers 2022-05-10 19:51:13 +01:00