Diagnostic update to support default parameters in inline methods
This commit is contained in:
+4
-1
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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") {}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ inline fun unsupported() {
|
||||
}<!>
|
||||
}
|
||||
|
||||
inline fun unsupportedDefault(<!NOT_YET_SUPPORTED_IN_INLINE!>s : Int = 10<!>) {
|
||||
inline fun unsupportedDefault(<!NOT_YET_SUPPORTED_IN_INLINE!>s : ()->Unit = {}<!>) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user