diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/extension/InlineAnalyzerExtension.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/extension/InlineAnalyzerExtension.java index 2e31c6e9d0c..1e37f347da2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/extension/InlineAnalyzerExtension.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/extension/InlineAnalyzerExtension.java @@ -93,7 +93,10 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz for (ValueParameterDescriptor parameter : functionDescriptor.getValueParameters()) { if (parameter.hasDefaultValue()) { JetParameter jetParameter = jetParameters.get(index); - trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(jetParameter, jetParameter, functionDescriptor)); + //report not supported default only on inlinable lambda and on parameter with inherited dafault (there is some problems to inline it) + if (checkInlinableParameter(parameter, jetParameter, functionDescriptor, null) || !parameter.declaresDefaultValue()) { + trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(jetParameter, jetParameter, functionDescriptor)); + } } index++; } diff --git a/compiler/testData/diagnostics/tests/inline/default.kt b/compiler/testData/diagnostics/tests/inline/default.kt new file mode 100644 index 00000000000..6a0b5067607 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inline/default.kt @@ -0,0 +1,15 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE + +inline fun default(s : Int = 10) { + +} + +inline fun default2(p: Int, s : String = "OK") { + +} + +open class Base { + inline final fun foo(a: Int = 1) {} + + inline final fun foo2(a: Int = 1, s: String = "OK") {} +} diff --git a/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt b/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt index 3cb86a2fbe4..c564b001b72 100644 --- a/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt +++ b/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt @@ -17,7 +17,7 @@ inline fun unsupported() { } } -inline fun unsupportedDefault(s : Int = 10) { +inline fun unsupportedDefault(s : ()->Unit = {}) { } diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index d814507641f..d412a22b57f 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3973,6 +3973,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest("compiler/testData/diagnostics/tests/inline/constructor.kt"); } + @TestMetadata("default.kt") + public void testDefault() throws Exception { + doTest("compiler/testData/diagnostics/tests/inline/default.kt"); + } + @TestMetadata("extensionOnFunction.kt") public void testExtensionOnFunction() throws Exception { doTest("compiler/testData/diagnostics/tests/inline/extensionOnFunction.kt");