Skip to content

Commit bad1524

Browse files
committed
Fixed exception in android lint
1 parent 1ea2e8c commit bad1524

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/KtLightPsiReferenceList.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.jetbrains.kotlin.asJava.elements
1818

19+
import com.intellij.openapi.util.TextRange
1920
import com.intellij.psi.PsiElement
2021
import com.intellij.psi.PsiJavaCodeReferenceElement
2122
import com.intellij.psi.PsiReferenceList
@@ -56,6 +57,8 @@ class KtLightPsiReferenceList (
5657
val entry = kotlinOrigin ?: return
5758
superTypeList.removeEntry(entry)
5859
}
60+
61+
override fun getTextRange(): TextRange? = kotlinOrigin?.typeReference?.textRange ?: TextRange.EMPTY_RANGE
5962
}
6063

6164
override val kotlinOrigin: KtSuperTypeList?

idea/testData/android/lint/apiCheck.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import android.os.Build.VERSION_CODES
2929
import android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH
3030
import android.os.Build.VERSION_CODES.JELLY_BEAN
3131
import android.os.Bundle
32+
import android.os.Parcelable
3233
import android.system.ErrnoException
3334
import android.widget.TextView
3435

@@ -415,16 +416,15 @@ class ApiCallTest: Activity() {
415416
layout as? LinearLayout // OK API 1
416417
layout as LinearLayout // OK API 1
417418

418-
if (layout !is GridLayout) {} // TODO: should be error, fixed in uast > 1.0.8
419-
layout as? GridLayout // TODO: should be error, fixed in uast > 1.0.8
420-
layout as GridLayout // TODO: should be error, fixed in uast > 1.0.8
419+
if (layout !is <error descr="Class requires API level 14 (current min is 1): android.widget.GridLayout">GridLayout</error>) {}
420+
layout as? <error descr="Class requires API level 14 (current min is 1): android.widget.GridLayout">GridLayout</error>
421+
layout as <error descr="Class requires API level 14 (current min is 1): android.widget.GridLayout">GridLayout</error>
421422

422-
val grid = layout as? GridLayout // TODO: should be error, fixed in uast > 1.0.8
423+
val grid = layout as? <error descr="Class requires API level 14 (current min is 1): android.widget.GridLayout">GridLayout</error>
423424
val linear = layout as LinearLayout // OK API 1
424425
}
425426

426-
// TODO: should be error
427-
class ErrorVectorDravable : VectorDrawable()
427+
abstract class ErrorVectorDravable : <error descr="Class requires API level 21 (current min is 1): android.graphics.drawable.VectorDrawable">VectorDrawable</error>(), Parcelable
428428

429429
@TargetApi(21)
430430
class MyVectorDravable : VectorDrawable()

0 commit comments

Comments
 (0)