Commit Graph

37769 Commits

Author SHA1 Message Date
Igor Laevsky 049e48e780 [Wasm] Keep error message for the IAE exception 2021-10-14 17:24:03 +03:00
Dmitry Petrov 6ba65065ee JVM add tests for KT-48544 & KT-49226 2021-10-14 17:23:12 +03:00
Artem Kobzar d2e5523180 test: adapt genericParameterResult.kt test for JS IR backend. 2021-10-14 14:05:39 +00:00
Ilmir Usmanov 559d7015f7 Extend NON_MODIFIER_FORM_FOR_BUILT_IN_SUSPEND diagnostic
to include "suspend fun" token sequence as well
2021-10-14 12:44:18 +00:00
Sergej Jaskiewicz 55ae6d1f3e [JS IR] Optimize pattern-matching of enums into comparing their ordinals
For this code:
```
enum class Season {
    WINTER,
    SPRING,
    SUMMER,
    AUTUMN
}

fun bar1(x : Season) : String {
    return when (x) {
        Season.WINTER, Season.SPRING -> "winter_spring"
        Season.SUMMER -> "summer"
        else -> "autumn"
    }
}
```

previously we generated this:
```
function foo(x) {
    var tmp0_subject = x;
    return (tmp0_subject.equals(Season_WINTER_getInstance())
        ? true
        : tmp0_subject.equals(Season_SPRING_getInstance()))
            ? 'winter_spring'
            : tmp0_subject.equals(Season_SUMMER_getInstance())
                ? 'summer'
                : 'autumn';
}
```

And now we generated this:
```
function bar2(x) {
  var tmp0_subject = x;
  var tmp0 = tmp0_subject._get_ordinal__0_k$();
  var tmp;
  switch (tmp0) {
    case 0:
    case 1:
      tmp = 'winter_spring';
      break;
    case 2:
      tmp = 'summer';
      break;
    case 3:
      tmp = 'autumn';
      break;
    default:
      noWhenBranchMatchedException();
      break;
  }
  return tmp;
}
```
2021-10-14 11:44:01 +00:00
Pavel Kunyavskiy e4a4cd3e16 [K/N] Transform constant varargs to ConstantValue 2021-10-14 11:22:25 +00:00
Pavel Kunyavskiy bf3c343ced Introduce new ir nodes for constant values 2021-10-14 11:22:21 +00:00
Pavel Kunyavskiy 2fe9420ca1 Compatibility hack for instantiating annotations from old klibs
^KT-49181
2021-10-14 11:03:17 +00:00
Denis.Zharkov cac69edff2 FIR: Fix forEach resolution within local class 2021-10-14 14:01:51 +03:00
Denis.Zharkov 056657525e FIR: Temporary support FE 1.0 behavior for SAM vs. generic ambiguity
^KT-48300 Relates
^KT-48938 Fixed
2021-10-14 14:01:50 +03:00
Denis.Zharkov 10c5d987d7 FIR: Fix exception on remaining flexible ILT in lambda
^KT-49191 Related
2021-10-14 14:01:49 +03:00
Dmitry Petrov 6f33259bc3 PSI2IR KT-49203 INVISIBLE_FAKE setter is non-referenceable 2021-10-13 18:38:23 +03:00
Dmitry Petrov 2a00def84e JVM_IR make proxy funs for inline and arrayOf funs non-synthetic 2021-10-13 16:07:53 +03:00
Svyatoslav Kuzmich 4e74e9baee [Wasm] Add test for KT-49182 2021-10-13 15:30:00 +03:00
Artem Kobzar f645c89ebf fix(KT-43191): add static qualifier for Companion and non-inner objects. 2021-10-13 11:09:59 +00:00
Alexander Udalov 357f3184bf JVM IR: fix the type of IrGetField
The `irGetField` utility uses the field's own type as the type of the
resulting expression. But the field's type does not make sense outside
of the place of declaration of the field if it references a generic type
parameter of the containing class. Using this non-sensical generic type
led, for example, to an error in Ieee754 intrinsic (KT-48648).

The type of the expression should be kept as is in
JvmPropertiesLowering, i.e. taken from `expression` which the lowering
is replacing with the field access.

 #KT-48648 Fixed
2021-10-12 23:35:17 +02:00
Svyatoslav Kuzmich 279f184703 [JS] Remove failed checks based on unstable naming 2021-10-12 23:29:39 +03:00
Svyatoslav Kuzmich 3f8dce4b53 [JS IR] Support per-file mode and ES modules 2021-10-12 23:29:39 +03:00
Svyatoslav Kuzmich 5affd9d2f9 Visit declaration reference when visiting member access 2021-10-12 23:01:00 +03:00
Roman Golyshev d3e2f9a3f6 [FIR IDE] Fix bug in diagnostics' combining during code generation 2021-10-12 19:21:11 +00:00
Dmitry Petrov b946a284b0 JVM_IR move 'arrayOf' handling to JvmBuiltInsLowering
FunctionReferenceLowering creates calls to 'arrayOf' functions that
should be processed later.
2021-10-12 21:12:44 +03:00
Dmitry Petrov 27e5655480 JVM_IR minor: more JvmIrBuilder helpers 2021-10-12 21:12:43 +03:00
Mark Punzalan 4f0b52b653 FIR: Transform annotations on type arguments during body resolve. 2021-10-12 18:56:32 +03:00
Dmitriy Novozhilov fce6efe412 [FIR] Validate generated member declarations 2021-10-12 17:26:44 +03:00
Dmitriy Novozhilov b4d955838e [FIR] Properly use FirContainingNamesAwareScope in all places
Split some delegating scopes to basic and name aware implementations

Also get rid of getContainingCallableNamesIfPresent and
  getContainingClassifierNamesIfPresent functions because they are not
  needed anymore
2021-10-12 17:26:43 +03:00
Dmitriy Novozhilov 5f625f3c16 [FIR] Fail with error if multiple plugins generated classes with same classId
In future we can turn this failure to some proper diagnostic
2021-10-12 17:26:42 +03:00
Dmitriy Novozhilov af6d6ec2b9 [FIR] Properly collect constructors from class in presence of plugins 2021-10-12 17:26:41 +03:00
Dmitriy Novozhilov 9a802e7cd7 [FIR] Return symbols instead of FIR from FirPredicateBasedProvider 2021-10-12 17:26:40 +03:00
Dmitriy Novozhilov 1cfe4deda9 [FIR] Remove unused methods from FirPredicateBasedProvider 2021-10-12 17:26:40 +03:00
Dmitriy Novozhilov 6a14d91dbd [FIR] Change predicate providing API for FIR extensions
Predicate declaration was split into two parts:
- registering any number of predicates which are used in specific extension
- special checks for declaration applicability for each specific extension
2021-10-12 17:26:39 +03:00
Dmitriy Novozhilov fc1f2e9c72 [FIR2IR] Run IrGenerationExtensions after fir2ir stage 2021-10-12 17:26:38 +03:00
Dmitriy Novozhilov b3768a201f [FIR2IR] Create special IrDeclarationOrigin for generated declarations 2021-10-12 17:26:37 +03:00
Dmitriy Novozhilov 233b9f1242 [FIR] Generate IR for generated FIR declarations 2021-10-12 17:26:37 +03:00
Dmitriy Novozhilov b454fcc1e0 [FIR] Save IR dumps to .ir.txt files instead of .txt in tests
This is needed to avoid clashes between different dumps from different
  handlers
2021-10-12 17:26:36 +03:00
Dmitriy Novozhilov c60ba51f8f [FIR] Include generated declarations into FIR dump in tests
Also include non root package directive of FirFile to dump
2021-10-12 17:26:34 +03:00
Dmitriy Novozhilov 79f1779d89 [FIR] Add methods to collect all class and callable ids from extensions
They will be needed for generating IR for all declarations from plugins
2021-10-12 17:26:33 +03:00
Dmitriy Novozhilov 38877ba842 [FIR] Implement extension for providing additional type attributes 2021-10-12 17:26:32 +03:00
Dmitriy Novozhilov 32709151c3 [FIR] Move base FirExtension infrastructure to :fir:tree module
This is needed for type attribute extension which is used not only
  from :resolve module but also from :(de)serialization modules
2021-10-12 17:26:32 +03:00
Dmitriy Novozhilov e26cd74b16 [FIR] Fix applying generated supertypes for classes without explicit supertypes 2021-10-12 17:26:31 +03:00
Dmitriy Novozhilov 26fa772846 [FIR] Add ability to generate members and nested classifiers for existing classes 2021-10-12 17:26:30 +03:00
Dmitriy Novozhilov 9bfa6c54b8 [FIR] Inherit FirContainingNamesAwareScope from FirScope
This is needed to simplify FirScope hierarchy, because in
  fact all inheritors of `FirContainingNamesAwareScope` were
  inheritors of `FirScope` too
2021-10-12 17:26:29 +03:00
Dmitriy Novozhilov f3a9d70eb6 [FIR] Add ability to generate members and nested classifiers for generated classes 2021-10-12 17:26:29 +03:00
Dmitriy Novozhilov 270962e176 [FIR] Make KotlinScopeProvider a session component 2021-10-12 17:26:27 +03:00
Dmitriy Novozhilov 4f764c28cb [FIR] Use proper caches in FirDeclaredMemberScopeProvider 2021-10-12 17:26:27 +03:00
Dmitriy Novozhilov 15abd839ed [FIR] Rewrite algorithm of generating declarations by plugins
Before there was separate global stage which asks extensions
  to generate new declarations. Now it is changed to provider
  like requests, so extensions will decide do they have declarations
  with specific classId/callableId or not
2021-10-12 17:26:26 +03:00
Dmitriy Novozhilov e011ca183d [FIR] Fix FirPluginAnnotationsResolveTransformer after recent compiler changes 2021-10-12 17:26:22 +03:00
Dmitriy Novozhilov 91624dd841 [FIR] Move call of status transform extensions to FirStatusResolver
It makes more sense to run status transformer extension
  right in status resolve stage, because it reduces
  number of compiler stages
2021-10-12 17:26:21 +03:00
Dmitriy Novozhilov 6d42914e56 [FIR] Migrate fir plugin prototype tests to new test infrastructure 2021-10-12 17:26:18 +03:00
Dmitriy Novozhilov e56c87a17a [Build] Move utils for generation JUnit 5 tests to :generators module 2021-10-12 17:26:18 +03:00
Dmitriy Novozhilov 48aa063b21 [FIR] Cleanup utils for creating FirTotalResolveProcessor 2021-10-12 17:26:16 +03:00