Files
kotlin-fork/compiler/ir/ir.psi2ir
Marco Pennekamp f11ea92601 [JVM IR] KTIJ-24335 Deduplicate class symbols of duplicate built-ins
- When the IR backend is invoked from the bytecode tool window,
  multiple descriptors may exist of the same built-in. For example,
  there may be multiple descriptors for `Boolean`.
- This caused issues when the `IrClassifierSymbol` of a type was used
  as a key for some built-ins map (such as `primitiveRefProviders` in
  `JvmSharedVariablesManager`). Because while the reference map is
  built from predeclared built-ins, with duplicate descriptors,
  multiple `IrClassifierSymbol`s may exist for the same type. Such a
  duplicated symbol would lead to an exception.
- The solution invents a special symbol table which de-duplicates
  built-ins at the point where `IrClassSymbol`s are created.

I tried other approaches:

- It's possible to fix the symptoms in `JvmSharedVariablesManager` and
  `JvmSymbols` by turning the keys of the requisite maps, i.e.
  `primitiveRefProviders` and `arraysCopyOfFunctions`, from
  `IrClassifierSymbol` to something like a `Name` or `PrimitiveType`.
  This however touches the IR backend beyond the IDE and still leaves
  error potential for all the other possibly duplicated built-ins.
- I tried to handle built-ins in `DeclarationStubGenerator` specially,
  to circumvent the issue of duplicated descriptors, but this is not a
  solution because the duplicated `IrClassSymbol`s will already be part
  of the IR at that point.

^KTIJ-24335 fixed
2023-02-03 12:23:09 +00:00
..