New J2K: Don't fail on captured types & don't use functional interface with captured types
Note: we have to print captured types for lambda parameters. It is needed for nullability inference as it requires explicit types specification to work. Later in post-processing we remove explicit type specifications for lambda parameters which have captured types #KT-33186 fixed
This commit is contained in:
+8
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.isNullable
|
||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSignedOrUnsignedNumberType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
@@ -56,6 +57,13 @@ val fixTypeMismatchDiagnosticBasedProcessing =
|
||||
val fix = NumberConversionFix(element, expectedType, disableIfAvailable = null)
|
||||
fix.invoke(element.project, null, element.containingFile)
|
||||
}
|
||||
element is KtLambdaExpression
|
||||
&& expectedType.isNothing() -> {
|
||||
for (valueParameter in element.valueParameters) {
|
||||
valueParameter.typeReference?.delete()
|
||||
valueParameter.colon?.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user