Fix for KT-9364: M13 Wrong compiler error for "unable to inline function"
#KT-9364 Fixed
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.checkers;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
@@ -114,6 +115,18 @@ class InlineChecker implements CallChecker {
|
||||
}
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
//UGLY HACK
|
||||
//check there is no casts
|
||||
PsiElement current = expression;
|
||||
while (current != parent) {
|
||||
if (current instanceof KtBinaryExpressionWithTypeRHS) {
|
||||
return false;
|
||||
}
|
||||
current = current.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
return parent != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
inline public fun reg(converter: (Any) -> Any, flag: Boolean) {
|
||||
flag
|
||||
converter("")
|
||||
}
|
||||
|
||||
public inline fun register(converter: (Any) -> Any) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>converter<!> is (Any) -> Any
|
||||
reg(converter, <!USAGE_IS_NOT_INLINABLE!>converter<!> is (Any) -> Any)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public inline fun reg(/*0*/ converter: (kotlin.Any) -> kotlin.Any, /*1*/ flag: kotlin.Boolean): kotlin.Unit
|
||||
public inline fun register(/*0*/ converter: (kotlin.Any) -> kotlin.Any): kotlin.Unit
|
||||
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNCHECKED_CAST -USELESS_CAST
|
||||
inline public fun reg(convertFunc: (Any) -> Any) {
|
||||
convertFunc("")
|
||||
}
|
||||
|
||||
public inline fun <reified T : Any, reified R : Any> register(converter: (T) -> R) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>converter<!> as (Any) -> Any
|
||||
reg(<!USAGE_IS_NOT_INLINABLE!>converter<!> as (Any) -> Any)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public inline fun reg(/*0*/ convertFunc: (kotlin.Any) -> kotlin.Any): kotlin.Unit
|
||||
public inline fun </*0*/ reified T : kotlin.Any, /*1*/ reified R : kotlin.Any> register(/*0*/ converter: (T) -> R): kotlin.Unit
|
||||
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
inline public fun reg(converter: (Any) -> Any, str: String) {
|
||||
str
|
||||
converter("")
|
||||
}
|
||||
|
||||
public inline fun register(converter: (Any) -> Any) {
|
||||
"123$<!USAGE_IS_NOT_INLINABLE!>converter<!>"
|
||||
reg(converter, "123$<!USAGE_IS_NOT_INLINABLE!>converter<!>")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public inline fun reg(/*0*/ converter: (kotlin.Any) -> kotlin.Any, /*1*/ str: kotlin.String): kotlin.Unit
|
||||
public inline fun register(/*0*/ converter: (kotlin.Any) -> kotlin.Any): kotlin.Unit
|
||||
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
inline public fun reg(converter: (Any) -> Any) {
|
||||
converter("")
|
||||
}
|
||||
|
||||
public inline fun register(converter: (Any) -> Any) {
|
||||
reg(when(<!USAGE_IS_NOT_INLINABLE!>converter<!>) {
|
||||
is (Any) -> Any -> <!USAGE_IS_NOT_INLINABLE!>converter<!>
|
||||
else -> <!USAGE_IS_NOT_INLINABLE!>converter<!>
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public inline fun reg(/*0*/ converter: (kotlin.Any) -> kotlin.Any): kotlin.Unit
|
||||
public inline fun register(/*0*/ converter: (kotlin.Any) -> kotlin.Any): kotlin.Unit
|
||||
@@ -8310,6 +8310,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("isCheck.kt")
|
||||
public void testIsCheck() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/isCheck.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4869.kt")
|
||||
public void testKt4869() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/kt4869.kt");
|
||||
@@ -8322,6 +8328,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaCast.kt")
|
||||
public void testLambdaCast() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/lambdaCast.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localFun.kt")
|
||||
public void testLocalFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/localFun.kt");
|
||||
@@ -8382,6 +8394,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("stringTemplate.kt")
|
||||
public void testStringTemplate() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/stringTemplate.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("unsupportedConstruction.kt")
|
||||
public void testUnsupportedConstruction() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/unsupportedConstruction.kt");
|
||||
@@ -8394,6 +8412,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("when.kt")
|
||||
public void testWhen() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/when.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongUsage.kt")
|
||||
public void testWrongUsage() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/wrongUsage.kt");
|
||||
|
||||
Reference in New Issue
Block a user