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:
Ilya Kirillov
2019-08-09 12:46:50 +03:00
parent 0c3c0989b4
commit 09ab98a4f8
17 changed files with 180 additions and 14 deletions
@@ -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()
}
}
}
}