You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -39,38 +41,37 @@ class ApiCallTest: Activity() {
39
41
// Ok
40
42
Bundle().getInt("")
41
43
42
-
// Ok, this constant is inlined
43
-
View.<warning descr="Field requires API level 16 (current min is 1): android.view.View#SYSTEM_UI_FLAG_FULLSCREEN">SYSTEM_UI_FLAG_FULLSCREEN</warning>
44
+
View.<warning descr="Field requires API level 16 (current min is 1): `android.view.View#SYSTEM_UI_FLAG_FULLSCREEN`">SYSTEM_UI_FLAG_FULLSCREEN</warning>
44
45
45
46
// Virtual call
46
47
<error descr="Call requires API level 11 (current min is 1): android.app.Activity#getActionBar">getActionBar</error>() // API 11
47
48
<error descr="Call requires API level 11 (current min is 1): android.app.Activity#getActionBar">actionBar</error>// API 11
48
49
49
50
// Class references (no call or field access)
50
51
val error:DOMError?=null// API 8
51
-
val clz =DOMErrorHandler::class// API 8
52
+
val clz =<error descr="Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler">DOMErrorHandler::class</error>// API 8
52
53
53
54
// Method call
54
55
chronometer.<error descr="Call requires API level 3 (current min is 1): android.widget.Chronometer#getOnChronometerTickListener">onChronometerTickListener</error>// API 3
55
56
56
57
// Inherited method call (from TextView
57
58
chronometer.<error descr="Call requires API level 11 (current min is 1): android.widget.TextView#setTextIsSelectable">setTextIsSelectable</error>(true) // API 11
58
59
59
-
GridLayout::class
60
+
<error descr="Class requires API level 14 (current min is 1): android.widget.GridLayout">GridLayout::class</error>
60
61
61
62
// Field access
62
-
val field =OpcodeInfo.<warning descr="Field requires API level 11 (current min is 1): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE">MAXIMUM_VALUE</warning>// API 11
63
+
val field =OpcodeInfo.<warning descr="Field requires API level 11 (current min is 1): `dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE`">MAXIMUM_VALUE</warning>// API 11
63
64
64
65
65
66
val fillParent =LayoutParams.FILL_PARENT// API 1
66
67
// This is a final int, which means it gets inlined
67
68
val matchParent =LayoutParams.MATCH_PARENT// API 8
68
69
// Field access: non final
69
-
val batteryInfo = report!!.<error descr="Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo">batteryInfo</error>
70
+
val batteryInfo = report!!.<error descr="Field requires API level 14 (current min is 1): `android.app.ApplicationErrorReport#batteryInfo`">batteryInfo</error>
70
71
71
72
// Enum access
72
73
if (Build.VERSION.SDK_INT<=Build.VERSION_CODES.LOLLIPOP) {
73
-
val mode =PorterDuff.Mode.<error descr="Field requires API level 11 (current min is 1): android.graphics.PorterDuff.Mode#OVERLAY">OVERLAY</error>// API 11
74
+
val mode =PorterDuff.Mode.<error descr="Field requires API level 11 (current min is 1): `android.graphics.PorterDuff.Mode#OVERLAY`">OVERLAY</error>// API 11
74
75
}
75
76
}
76
77
@@ -115,12 +116,6 @@ class ApiCallTest: Activity() {
115
116
}
116
117
117
118
funtest(priority:Boolean, layout:ViewGroup) {
118
-
if (layout isLinearLayout) {}
119
-
layout as?LinearLayout
120
-
121
-
if (layout isGridLayout) {}
122
-
layout as?GridLayout
123
-
124
119
if (android.os.Build.VERSION.SDK_INT>=Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
125
120
GridLayout(null).getOrientation(); // Not flagged
126
121
} else {
@@ -250,25 +245,131 @@ class ApiCallTest: Activity() {
250
245
//ERROR
251
246
}
252
247
253
-
if (SDK_INT>=JELLY_BEAN&& textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>()) {
248
+
if (SDK_INT>=JELLY_BEAN&& textView.isSuggestionsEnabled()) {
249
+
//NO ERROR
250
+
}
251
+
252
+
if (SDK_INT>=JELLY_BEAN&& textView.isSuggestionsEnabled) {
254
253
//NO ERROR
255
254
}
256
255
257
-
if (SDK_INT>=JELLY_BEAN&& textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>) {
256
+
if (SDK_INT>=JELLY_BEAN&&(textView.text !=""|| textView.isSuggestionsEnabled)) {
258
257
//NO ERROR
259
258
}
260
259
260
+
if (SDK_INT<JELLY_BEAN&& (textView.text !=""|| textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>)) {
261
+
//ERROR
262
+
}
263
+
261
264
if (SDK_INT<JELLY_BEAN&& textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>()) {
262
265
//ERROR
263
266
}
264
267
265
268
if (SDK_INT<JELLY_BEAN&& textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>) {
266
269
//ERROR
267
270
}
271
+
272
+
if (SDK_INT<JELLY_BEAN|| textView.isSuggestionsEnabled) {
273
+
//NO ERROR
274
+
}
275
+
276
+
if (SDK_INT>JELLY_BEAN|| textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>) {
277
+
//ERROR
278
+
}
279
+
280
+
281
+
// getActionBar() API 11
282
+
if (SDK_INT<=10|| getActionBar() ==null) {
283
+
//NO ERROR
284
+
}
285
+
286
+
if (SDK_INT<10||<error descr="Call requires API level 11 (current min is 1): android.app.Activity#getActionBar">getActionBar</error>() ==null) {
287
+
//ERROR
288
+
}
289
+
290
+
if (SDK_INT<11|| getActionBar() ==null) {
291
+
//NO ERROR
292
+
}
293
+
294
+
if (SDK_INT!=11|| getActionBar() ==null) {
295
+
//NO ERROR
296
+
}
297
+
298
+
if (SDK_INT!=12||<error descr="Call requires API level 11 (current min is 1): android.app.Activity#getActionBar">getActionBar</error>() ==null) {
299
+
//ERROR
300
+
}
301
+
302
+
if (SDK_INT<=11|| getActionBar() ==null) {
303
+
//NO ERROR
304
+
}
305
+
306
+
if (SDK_INT<12|| getActionBar() ==null) {
307
+
//NO ERROR
308
+
}
309
+
310
+
if (SDK_INT<=12|| getActionBar() ==null) {
311
+
//NO ERROR
312
+
}
313
+
314
+
if (SDK_INT<9||<error descr="Call requires API level 11 (current min is 1): android.app.Activity#getActionBar">getActionBar</error>() ==null) {
315
+
//ERROR
316
+
}
317
+
318
+
if (SDK_INT<=9||<error descr="Call requires API level 11 (current min is 1): android.app.Activity#getActionBar">getActionBar</error>() ==null) {
319
+
//ERROR
320
+
}
321
+
}
322
+
323
+
funtestReturn() {
324
+
if (SDK_INT<11) {
325
+
return
326
+
}
327
+
328
+
// No Error
329
+
val actionBar = getActionBar()
330
+
}
331
+
332
+
funtestThrow() {
333
+
if (SDK_INT<11) {
334
+
throwIllegalStateException()
335
+
}
336
+
337
+
// No Error
338
+
val actionBar = getActionBar()
339
+
}
340
+
341
+
funtestError() {
342
+
if (SDK_INT<11) {
343
+
error("Api")
344
+
}
345
+
346
+
// No Error
347
+
val actionBar = getActionBar()
348
+
}
349
+
350
+
funtestWithoutAnnotation(textView:TextView) {
351
+
if (textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>()) {
352
+
353
+
}
354
+
355
+
if (textView.<error descr="Call requires API level 14 (current min is 1): android.widget.TextView#isSuggestionsEnabled">isSuggestionsEnabled</error>) {
@@ -291,11 +392,70 @@ class ApiCallTest: Activity() {
291
392
Path().<error descr="Call requires API level 21 (current min is 1): android.graphics.Path#addOval">addOval</error>(0f, 0f, 0f, 0f, Path.Direction.CW)
292
393
}
293
394
395
+
// KT-14737 False error with short-circuit evaluation
396
+
funtestShortCircuitEvaluation() {
397
+
<error descr="Call requires API level 21 (current min is 1): android.content.Context#getDrawable">getDrawable</error>(0) // error here as expected
398
+
if(Build.VERSION.SDK_INT>=23
399
+
&&null== getDrawable(0)) // error here should not occur
400
+
{
401
+
getDrawable(0) // no error here as expected
402
+
}
403
+
}
404
+
405
+
// KT-1482 Kotlin Lint: "Calling new methods on older versions" does not report call on receiver in extension function
406
+
privatefun Bundle.caseE1a() { <error descr="Call requires API level 18 (current min is 1): android.os.Bundle#getBinder">getBinder</error>("") }
407
+
408
+
privatefun Bundle.caseE1c() { this.<error descr="Call requires API level 18 (current min is 1): android.os.Bundle#getBinder">getBinder</error>("") }
409
+
410
+
privatefuncaseE1b(bundle:Bundle) { bundle.<error descr="Call requires API level 18 (current min is 1): android.os.Bundle#getBinder">getBinder</error>("") }
0 commit comments