Provide configurable constructor call normalization
Three modes: - 'disable' (default): normalize constructor calls in coroutines only (required because uninitialized objects can't be stored in fields), don't insert additional code for forced class initialization; - 'enable': normalize constructor calls, don't insert additional code for forced class initialization; - 'preserve-class-initialization': normalize constructor calls, insert additional code for forced class initialization.
This commit is contained in:
@@ -57,6 +57,8 @@ public class JVMConfigurationKeys {
|
||||
CompilerConfigurationKey.create("disable not-null call receiver assertions");
|
||||
public static final CompilerConfigurationKey<Boolean> DISABLE_PARAM_ASSERTIONS =
|
||||
CompilerConfigurationKey.create("disable not-null parameter assertions");
|
||||
public static final CompilerConfigurationKey<JVMConstructorCallNormalizationMode> CONSTRUCTOR_CALL_NORMALIZATION_MODE =
|
||||
CompilerConfigurationKey.create("constructor call normalization mode");
|
||||
public static final CompilerConfigurationKey<Boolean> NO_EXCEPTION_ON_EXPLICIT_EQUALS_FOR_BOXED_NULL =
|
||||
CompilerConfigurationKey.create("do not throw NPE on explicit 'equals' call for null receiver of platform boxed primitive type");
|
||||
public static final CompilerConfigurationKey<Boolean> DISABLE_OPTIMIZATION =
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
enum class JVMConstructorCallNormalizationMode(
|
||||
val description: String,
|
||||
val isEnabled: Boolean,
|
||||
val shouldPreserveClassInitialization: Boolean
|
||||
) {
|
||||
DISABLE("disable", false, false),
|
||||
ENABLE("enable", true, false),
|
||||
PRESERVE_CLASS_INITIALIZATION("preserve-class-initialization", true, true)
|
||||
;
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT = DISABLE
|
||||
|
||||
@JvmStatic
|
||||
fun fromStringOrNull(string: String?) = values().find { it.description == string }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user