IR: '!!' is generated as 'CHECK_NOT_NULL' intrinsic

```
fun <T : Any> CHECK_NOT_NULL(x: T?): x =
  if (x != null) x else throw NullPointerException(...)
```

This allows to compile both Kotlin/JVM and Kotlin/JS effectively.
This commit is contained in:
Dmitry Petrov
2019-08-08 16:22:48 +03:00
parent b9db4148cc
commit 7170439517
12 changed files with 217 additions and 161 deletions
@@ -19,7 +19,7 @@ class ExceptionHelperCallsTransformer(private val context: JsIrBackendContext) :
}
private val helperMapping = mapOf(
context.irBuiltIns.throwNpeSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_NPE"))),
// context.irBuiltIns.throwNpeSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_NPE"))), -- TODO checkNotNullSymbol
context.irBuiltIns.throwCceSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_CCE"))),
context.irBuiltIns.throwIseSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))),
context.irBuiltIns.noWhenBranchMatchedExceptionSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("noWhenBranchMatchedException")))