Minor: make variables initialized in defineClass lateinit instead of nullable.

This commit is contained in:
Ilya Gorbunov
2016-03-15 03:08:24 +03:00
parent d9329456b5
commit 1ae0040ca3
5 changed files with 16 additions and 18 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2016 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ abstract class ClassNameCollectionClassBuilderFactory(
override fun getDelegate() = _delegate override fun getDelegate() = _delegate
private var classInternalName: String? = null private lateinit var classInternalName: String
override fun defineClass(origin: PsiElement?, version: Int, access: Int, name: String, signature: String?, superName: String, interfaces: Array<out String>) { override fun defineClass(origin: PsiElement?, version: Int, access: Int, name: String, signature: String?, superName: String, interfaces: Array<out String>) {
classInternalName = name classInternalName = name
@@ -50,9 +50,7 @@ abstract class ClassNameCollectionClassBuilderFactory(
} }
override fun done() { override fun done() {
if (classInternalName != null) { handleClashingNames(classInternalName, classCreatedFor)
handleClashingNames(classInternalName!!, classCreatedFor)
}
super.done() super.done()
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2016 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ abstract class SignatureCollectingClassBuilderFactory(
protected abstract fun handleClashingSignatures(data: ConflictingJvmDeclarationsData) protected abstract fun handleClashingSignatures(data: ConflictingJvmDeclarationsData)
protected abstract fun onClassDone(classOrigin: JvmDeclarationOrigin, protected abstract fun onClassDone(classOrigin: JvmDeclarationOrigin,
classInternalName: String?, classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>) signatures: MultiMap<RawSignature, JvmDeclarationOrigin>)
override fun newClassBuilder(origin: JvmDeclarationOrigin): DelegatingClassBuilder { override fun newClassBuilder(origin: JvmDeclarationOrigin): DelegatingClassBuilder {
@@ -46,7 +46,7 @@ abstract class SignatureCollectingClassBuilderFactory(
override fun getDelegate() = _delegate override fun getDelegate() = _delegate
private var classInternalName: String? = null private lateinit var classInternalName: String
private val signatures = LinkedMultiMap<RawSignature, JvmDeclarationOrigin>() private val signatures = LinkedMultiMap<RawSignature, JvmDeclarationOrigin>()
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2016 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -91,7 +91,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
override fun onClassDone( override fun onClassDone(
classOrigin: JvmDeclarationOrigin, classOrigin: JvmDeclarationOrigin,
classInternalName: String?, classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin> signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
) { ) {
reportDiagnosticsTasks.add { reportClashingSignaturesInHierarchy(classOrigin, classInternalName, signatures) } reportDiagnosticsTasks.add { reportClashingSignaturesInHierarchy(classOrigin, classInternalName, signatures) }
@@ -99,7 +99,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
private fun reportClashingSignaturesInHierarchy( private fun reportClashingSignaturesInHierarchy(
classOrigin: JvmDeclarationOrigin, classOrigin: JvmDeclarationOrigin,
classInternalName: String?, classInternalName: String,
signatures: MultiMap<RawSignature, JvmDeclarationOrigin> signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
) { ) {
val descriptor = classOrigin.descriptor val descriptor = classOrigin.descriptor
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2016 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.resolve.jvm.diagnostics package org.jetbrains.kotlin.resolve.jvm.diagnostics
class ConflictingJvmDeclarationsData( class ConflictingJvmDeclarationsData(
val classInternalName: String?, val classInternalName: String,
val classOrigin: JvmDeclarationOrigin, val classOrigin: JvmDeclarationOrigin,
val signature: RawSignature, val signature: RawSignature,
val signatureOrigins: Collection<JvmDeclarationOrigin> val signatureOrigins: Collection<JvmDeclarationOrigin>
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2016 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -101,9 +101,9 @@ abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnotations:
} }
} }
private var currentClassSimpleName: String? = null private lateinit var currentClassSimpleName: String
private var currentPackageName: String? = null private lateinit var currentPackageName: String
override fun getVisitor() = classVisitor override fun getVisitor() = classVisitor
@@ -184,13 +184,13 @@ abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnotations:
try { try {
val annotationId = shortenedAnnotationCache.save(annotationFqName, writer) val annotationId = shortenedAnnotationCache.save(annotationFqName, writer)
val packageName = this.currentPackageName!! val packageName = this.currentPackageName
val packageNameId = if (!packageName.isEmpty()) val packageNameId = if (!packageName.isEmpty())
shortenedPackageNameCache.save(packageName, writer) shortenedPackageNameCache.save(packageName, writer)
else null else null
val className = this.currentClassSimpleName!! val className = this.currentClassSimpleName
val outputClassName = getOutputClassName(packageNameId, className) val outputClassName = getOutputClassName(packageNameId, className)
val elementName = if (name != null) " $name" else "" val elementName = if (name != null) " $name" else ""