Fix minor compile warnings

This commit is contained in:
Dmitry Gridin
2019-04-17 17:48:26 +07:00
parent 79793a4bda
commit 37c856290f
226 changed files with 618 additions and 479 deletions
@@ -18,7 +18,8 @@ package org.jetbrains.kotlin.android.parcel
import kotlinx.android.parcel.Parceler
import kotlinx.android.parcel.Parcelize
import org.jetbrains.kotlin.android.parcel.ParcelableSyntheticComponent.ComponentKind.*
import org.jetbrains.kotlin.android.parcel.ParcelableSyntheticComponent.ComponentKind.DESCRIBE_CONTENTS
import org.jetbrains.kotlin.android.parcel.ParcelableSyntheticComponent.ComponentKind.WRITE_TO_PARCEL
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
@@ -82,33 +83,35 @@ open class ParcelableResolveExtension : SyntheticResolveExtension {
override fun getSyntheticCompanionObjectNameIfNeeded(thisDescriptor: ClassDescriptor) = null
override fun generateSyntheticMethods(
clazz: ClassDescriptor,
thisDescriptor: ClassDescriptor,
name: Name,
bindingContext: BindingContext,
fromSupertypes: List<SimpleFunctionDescriptor>,
result: MutableCollection<SimpleFunctionDescriptor>
) {
fun isExperimental(): Boolean {
val sourceElement = (clazz.source as? PsiSourceElement)?.psi as? KtElement ?: return false
val sourceElement = (thisDescriptor.source as? PsiSourceElement)?.psi as? KtElement ?: return false
return isExperimental(sourceElement)
}
if (name.asString() == DESCRIBE_CONTENTS.methodName
&& clazz.isParcelize
&& isExperimental()
&& result.none { it.isDescribeContents() }
&& fromSupertypes.none { it.isDescribeContents() }
&& thisDescriptor.isParcelize
&& isExperimental()
&& result.none { it.isDescribeContents() }
&& fromSupertypes.none { it.isDescribeContents() }
) {
result += createMethod(clazz, DESCRIBE_CONTENTS, Modality.OPEN, clazz.builtIns.intType)
result += createMethod(thisDescriptor, DESCRIBE_CONTENTS, Modality.OPEN, thisDescriptor.builtIns.intType)
} else if (name.asString() == WRITE_TO_PARCEL.methodName
&& clazz.isParcelize
&& isExperimental()
&& result.none { it.isWriteToParcel() }
&& thisDescriptor.isParcelize
&& isExperimental()
&& result.none { it.isWriteToParcel() }
) {
val builtIns = clazz.builtIns
val parcelClassType = resolveParcelClassType(clazz.module) ?: ErrorUtils.createErrorType("Unresolved 'Parcel' type")
result += createMethod(clazz, WRITE_TO_PARCEL, Modality.OPEN,
builtIns.unitType, "parcel" to parcelClassType, "flags" to builtIns.intType)
val builtIns = thisDescriptor.builtIns
val parcelClassType = resolveParcelClassType(thisDescriptor.module) ?: ErrorUtils.createErrorType("Unresolved 'Parcel' type")
result += createMethod(
thisDescriptor, WRITE_TO_PARCEL, Modality.OPEN,
builtIns.unitType, "parcel" to parcelClassType, "flags" to builtIns.intType
)
}
}
@@ -816,12 +816,12 @@ private fun writeValueNullAware(v: InstructionAdapter, block: () -> Unit) {
v.goTo(labelReturn)
labelNull@ v.visitLabel(labelNull)
v.visitLabel(labelNull)
v.pop()
v.aconst(0)
v.invokevirtual(PARCEL_TYPE.internalName, "writeInt", "(I)V", false)
labelReturn@ v.visitLabel(labelReturn)
v.visitLabel(labelReturn)
}
internal class Method<out T : String?>(val name: String, val signature: T) {
@@ -37,6 +37,7 @@ class AndroidExtensionsReferenceSearchExecutor : QueryExecutorBase<PsiReference,
override fun processQuery(queryParameters: ReferencesSearch.SearchParameters, consumer: Processor<in PsiReference>) {
val elementToSearch = queryParameters.elementToSearch as? XmlAttributeValue ?: return
val scopeElements = (queryParameters.effectiveSearchScope as? LocalSearchScope)?.scope ?: return
@Suppress("UNNECESSARY_SAFE_CALL", "USELESS_ELVIS") // BUNCH: 182
val referenceName = elementToSearch.value?.substringAfterLast("/") ?: return
scopeElements.filterIsInstance<KtElement>().forEach {
@@ -33,7 +33,7 @@ class AndroidSimpleNameReferenceExtension : SimpleNameReferenceExtension {
element is XmlFile && reference.isReferenceToXmlFile(element)
private fun isLayoutPackageIdentifier(reference: KtSimpleNameReference): Boolean {
val probablyVariant = reference.element?.parent as? KtDotQualifiedExpression ?: return false
val probablyVariant = reference.element.parent as? KtDotQualifiedExpression ?: return false
val probablyKAS = probablyVariant.receiverExpression as? KtDotQualifiedExpression ?: return false
return probablyKAS.receiverExpression.text == AndroidConst.SYNTHETIC_PACKAGE
}
@@ -51,6 +51,7 @@ class AndroidSimpleNameReferenceExtension : SimpleNameReferenceExtension {
return null
}
@Suppress("UNNECESSARY_SAFE_CALL", "USELESS_ELVIS") // BUNCH: 182
private fun isIdDeclaration(declaration: XmlAttributeValue) = declaration.value?.startsWith("@+id/") ?: false
private fun KtSimpleNameReference.isReferenceToXmlFile(xmlFile: XmlFile): Boolean {
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.android
abstract class AbstractAndroidFindUsagesTest : KotlinAndroidTestCase() {
@Suppress("UNREACHABLE_CODE")
fun doTest(path: String) {
return // TODO: investigate and fix this test
copyResourceDirectoryForTest(path)