Skip to content

Commit ca124d1

Browse files
committed
Remove Android api diagnostic error on Kotlin interface default methods
They don't require java 8 or any other special support to work on Android #KT-18059 Fixed
1 parent 286f82a commit ca124d1

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

idea/testData/android/lint/apiCheck.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,11 @@ fun testJava8() {
476476

477477
// Ok, Kotlin
478478
mapOf(1 to 2).forEach { (key, value) -> key + value }
479+
}
480+
481+
interface WithDefault {
482+
// Should be ok
483+
fun methodWithBody() {
484+
return
485+
}
479486
}

plugins/lint/lint-checks/src/com/android/tools/klint/checks/ApiDetector.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -982,24 +982,6 @@ private void checkCast(@NonNull UElement node, @NonNull PsiClassType classType,
982982
mContext.report(UNSUPPORTED, location, message);
983983
}
984984

985-
@Override
986-
public boolean visitMethod(@NotNull UMethod method) {
987-
// API check for default methods
988-
if (method.getModifierList().hasExplicitModifier(PsiModifier.DEFAULT)) {
989-
int api = 24; // minSdk for default methods
990-
int minSdk = getMinSdk(mContext);
991-
992-
if (!isSuppressed(api, method, minSdk, mContext, UNSUPPORTED)) {
993-
Location location = mContext.getLocation(method);
994-
String message = String.format("Default method requires API level %1$d "
995-
+ "(current min is %2$d)", api, minSdk);
996-
mContext.reportUast(UNSUPPORTED, method, location, message);
997-
}
998-
}
999-
1000-
return super.visitMethod(method);
1001-
}
1002-
1003985
@Override
1004986
public boolean visitClass(@NotNull UClass aClass) {
1005987
// Check for repeatable annotations

0 commit comments

Comments
 (0)