Override/Implement: Fix processing of unresolved types

#KT-17350 Fixed
This commit is contained in:
Alexey Sedunov
2018-06-08 16:34:48 +03:00
parent ed8b4b761a
commit 694997651a
8 changed files with 33 additions and 1 deletions
@@ -214,6 +214,7 @@ interface DescriptorRendererOptions {
var includeAdditionalModifiers: Boolean
var parameterNamesInFunctionalTypes: Boolean
var renderFunctionContracts: Boolean
var presentableUnresolvedTypes: Boolean
}
object ExcludedTypeAnnotations {
@@ -229,7 +229,11 @@ internal class DescriptorRendererImpl(
this.renderAnnotations(type)
if (type.isError) {
append(type.constructor.toString()) // Debug name of an error type is more informative
if (type is UnresolvedType && presentableUnresolvedTypes) {
append(type.presentableName)
} else {
append(type.constructor.toString()) // Debug name of an error type is more informative
}
append(renderTypeArguments(type.arguments))
}
else {
@@ -115,4 +115,6 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions {
override var parameterNamesInFunctionalTypes: Boolean by property(true)
override var renderFunctionContracts: Boolean by property(false)
override var presentableUnresolvedTypes: Boolean by property(false)
}
@@ -44,6 +44,8 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
preferNotNull: Boolean = false,
preferStarForRaw: Boolean = false
): SimpleType {
if (this is ErrorType) return this
if (isFlexible()) {
val flexible = asFlexibleType()
val lowerClass = flexible.lowerBound.constructor.declarationDescriptor as? ClassDescriptor?
@@ -162,6 +162,7 @@ private val OVERRIDE_RENDERER = DescriptorRenderer.withOptions {
annotationFilter = {
it.type.constructor.declarationDescriptor?.annotations?.hasAnnotation(ExperimentalUsageChecker.EXPERIMENTAL_FQ_NAME) ?: false
}
presentableUnresolvedTypes = true
}
private fun PropertyDescriptor.wrap(): PropertyDescriptor {
@@ -0,0 +1,8 @@
// DISABLE-ERRORS
interface A<in TPipeline, out TBuilder : Any, TFeature : Any> {
fun install(pipeline: TPipeline, configure: TBuilder.() -> Unit): TFeature
}
class X : A<String, UnresolvedType, Unit> {
<caret>
}
@@ -0,0 +1,10 @@
// DISABLE-ERRORS
interface A<in TPipeline, out TBuilder : Any, TFeature : Any> {
fun install(pipeline: TPipeline, configure: TBuilder.() -> Unit): TFeature
}
class X : A<String, UnresolvedType, Unit> {
override fun install(pipeline: String, configure: UnresolvedType.() -> Unit) {
<selection><caret>TODO("not implemented") //To change body of created functions use File | Settings | File Templates.</selection>
}
}
@@ -289,4 +289,8 @@ class OverrideImplementTest : AbstractOverrideImplementTest() {
configureLanguageAndApiVersion(project, module, "1.3", "1.3")
doOverrideFileTest("targetFun")
}
fun testUnresolvedType() {
doOverrideFileTest()
}
}