diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineAnalyzerExtension.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineAnalyzerExtension.java index 9247041ce61..f4069d53185 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineAnalyzerExtension.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineAnalyzerExtension.java @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.FunctionAnalyzerExtension; +import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import java.util.List; @@ -125,7 +126,7 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz hasInlinable |= InlineUtil.containsReifiedTypeParameters(functionDescriptor); - if (!hasInlinable) { + if (!hasInlinable && !AnnotationUtilKt.isInlineOnly(functionDescriptor)) { KtModifierList modifierList = function.getModifierList(); PsiElement inlineModifier = modifierList == null ? null : modifierList.getModifier(KtTokens.INLINE_KEYWORD); PsiElement reportOn = inlineModifier == null ? function : inlineModifier; diff --git a/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt new file mode 100644 index 00000000000..6bac4f49b01 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt @@ -0,0 +1,31 @@ +// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER -NULLABLE_INLINE_PARAMETER + +@kotlin.internal.InlineOnly +inline fun test() { + +} + +@kotlin.internal.InlineOnly +inline fun test3(noinline s : (Int) -> Int) { + +} + +@kotlin.internal.InlineOnly +inline fun test4(noinline s : Int.() -> Int) { + +} + +@kotlin.internal.InlineOnly +inline fun Function1?.test5() { + +} + +@kotlin.internal.InlineOnly +inline fun Function1?.test6() { + +} + +@kotlin.internal.InlineOnly +inline fun test2(s : ((Int) -> Int)?) { + +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.txt b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.txt new file mode 100644 index 00000000000..2e4b2d46150 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.txt @@ -0,0 +1,8 @@ +package + +@kotlin.internal.InlineOnly() public inline fun test(): kotlin.Unit +@kotlin.internal.InlineOnly() public inline fun test2(/*0*/ s: ((kotlin.Int) -> kotlin.Int)?): kotlin.Unit +@kotlin.internal.InlineOnly() public inline fun test3(/*0*/ noinline s: (kotlin.Int) -> kotlin.Int): kotlin.Unit +@kotlin.internal.InlineOnly() public inline fun test4(/*0*/ noinline s: kotlin.Int.() -> kotlin.Int): kotlin.Unit +@kotlin.internal.InlineOnly() public inline fun ((kotlin.Int) -> kotlin.Int)?.test5(): kotlin.Unit +@kotlin.internal.InlineOnly() public inline fun ((kotlin.Int) -> kotlin.Int)?.test6(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index bfb3ae4b025..c532c40ae9d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -824,6 +824,21 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/inline") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inline extends AbstractDiagnosticsTestWithStdLib { + public void testAllFilesPresentInInline() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/inline"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("inlineOnlySuppressesNothingToInline.kt") + public void testInlineOnlySuppressesNothingToInline() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inline/inlineOnlySuppressesNothingToInline.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/kt7585") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)