Add a compiler parameter to generate not-null assertions on method call sites

It is off by default when invoking compiler directly, and on by default when
compiling from IDE
This commit is contained in:
Alexander Udalov
2012-10-01 18:50:15 +04:00
parent 1f3586a151
commit 19a6a3f390
7 changed files with 31 additions and 8 deletions
@@ -68,14 +68,20 @@ public class GenerationState {
@NotNull
private final JetTypeMapper typeMapper;
private final boolean generateNotNullAssertions;
public GenerationState(Project project, ClassBuilderFactory builderFactory, AnalyzeExhaust analyzeExhaust, List<JetFile> files) {
this(project, builderFactory, Progress.DEAF, analyzeExhaust, files, BuiltinToJavaTypesMapping.ENABLED);
this(project, builderFactory, Progress.DEAF, analyzeExhaust, files, BuiltinToJavaTypesMapping.ENABLED, true);
}
public GenerationState(
@NotNull Project project,
ClassBuilderFactory builderFactory, Progress progress,
@NotNull AnalyzeExhaust exhaust, @NotNull List<JetFile> files, @NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping
ClassBuilderFactory builderFactory,
@NotNull Progress progress,
@NotNull AnalyzeExhaust exhaust,
@NotNull List<JetFile> files,
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
boolean generateNotNullAssertions
) {
this.project = project;
this.progress = progress;
@@ -94,6 +100,8 @@ public class GenerationState {
this.scriptCodegen = injector.getScriptCodegen();
this.intrinsics = injector.getIntrinsics();
this.classFileFactory = injector.getClassFileFactory();
this.generateNotNullAssertions = generateNotNullAssertions;
}
@NotNull
@@ -146,6 +154,10 @@ public class GenerationState {
return intrinsics;
}
public boolean isGenerateNotNullAssertions() {
return generateNotNullAssertions;
}
public void beforeCompile() {
markUsed();