Changes in TypeBounds interface
inlined 'isEmpty' (correctly) replaced functions 'getValue, getValues' with properties
This commit is contained in:
@@ -216,7 +216,7 @@ public object Renderers {
|
|||||||
): TabledDescriptorRenderer {
|
): TabledDescriptorRenderer {
|
||||||
var firstUnknownParameter: TypeParameterDescriptor? = null
|
var firstUnknownParameter: TypeParameterDescriptor? = null
|
||||||
for (typeParameter in inferenceErrorData.constraintSystem.getTypeVariables()) {
|
for (typeParameter in inferenceErrorData.constraintSystem.getTypeVariables()) {
|
||||||
if (inferenceErrorData.constraintSystem.getTypeBounds(typeParameter).isEmpty()) {
|
if (inferenceErrorData.constraintSystem.getTypeBounds(typeParameter).values.isEmpty()) {
|
||||||
firstUnknownParameter = typeParameter
|
firstUnknownParameter = typeParameter
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ public object Renderers {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
val inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).getValue()
|
val inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).value
|
||||||
if (inferredValueForTypeParameter == null) {
|
if (inferredValueForTypeParameter == null) {
|
||||||
LOG.error(renderDebugMessage("System without weak constraints is not successful, there is no value for type parameter " +
|
LOG.error(renderDebugMessage("System without weak constraints is not successful, there is no value for type parameter " +
|
||||||
typeParameterDescriptor.getName() + "\n: " + systemWithoutWeakConstraints, inferenceErrorData))
|
typeParameterDescriptor.getName() + "\n: " + systemWithoutWeakConstraints, inferenceErrorData))
|
||||||
@@ -372,7 +372,7 @@ public object Renderers {
|
|||||||
if (renderPosition) type + '(' + bound.position + ')' else type
|
if (renderPosition) type + '(' + bound.position + ')' else type
|
||||||
}
|
}
|
||||||
val typeVariableName = typeBounds.typeVariable.getName()
|
val typeVariableName = typeBounds.typeVariable.getName()
|
||||||
return if (typeBounds.isEmpty()) {
|
return if (typeBounds.bounds.isEmpty()) {
|
||||||
typeVariableName.asString()
|
typeVariableName.asString()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+3
-3
@@ -68,9 +68,9 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
|
|
||||||
override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful()
|
override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful()
|
||||||
|
|
||||||
override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.getValues().size() > 1 }
|
override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.values.size() > 1 }
|
||||||
|
|
||||||
override fun hasUnknownParameters() = typeParameterBounds.values().any { it.isEmpty() }
|
override fun hasUnknownParameters() = typeParameterBounds.values().any { it.values.isEmpty() }
|
||||||
|
|
||||||
override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch }
|
override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch }
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
val substitutionContext = HashMap<TypeParameterDescriptor, TypeProjection>()
|
val substitutionContext = HashMap<TypeParameterDescriptor, TypeProjection>()
|
||||||
for ((typeParameter, typeBounds) in typeParameterBounds) {
|
for ((typeParameter, typeBounds) in typeParameterBounds) {
|
||||||
val typeProjection: TypeProjection
|
val typeProjection: TypeProjection
|
||||||
val value = typeBounds.getValue()
|
val value = typeBounds.value
|
||||||
if (value != null && !TypeUtils.containsSpecialType(value, DONT_CARE)) {
|
if (value != null && !TypeUtils.containsSpecialType(value, DONT_CARE)) {
|
||||||
typeProjection = TypeProjectionImpl(value)
|
typeProjection = TypeProjectionImpl(value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ public trait TypeBounds {
|
|||||||
|
|
||||||
public val bounds: Collection<Bound>
|
public val bounds: Collection<Bound>
|
||||||
|
|
||||||
public fun isEmpty(): Boolean
|
public val value: JetType?
|
||||||
|
|
||||||
public fun getValue(): JetType?
|
public val values: Collection<JetType>
|
||||||
|
|
||||||
public fun getValues(): Collection<JetType>
|
|
||||||
|
|
||||||
public enum class BoundKind {
|
public enum class BoundKind {
|
||||||
LOWER_BOUND,
|
LOWER_BOUND,
|
||||||
|
|||||||
+8
-16
@@ -45,10 +45,6 @@ public class TypeBoundsImpl(
|
|||||||
bounds.add(Bound(constrainingType, kind, position))
|
bounds.add(Bound(constrainingType, kind, position))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isEmpty(): Boolean {
|
|
||||||
return getValues().isEmpty()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind): Set<JetType> {
|
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind): Set<JetType> {
|
||||||
return filterBounds(bounds, kind, null)
|
return filterBounds(bounds, kind, null)
|
||||||
}
|
}
|
||||||
@@ -81,20 +77,16 @@ public class TypeBoundsImpl(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getValue(): JetType? {
|
override val value: JetType?
|
||||||
val values = getValues()
|
get() = if (values.size() == 1) values.first() else null
|
||||||
if (values.size() == 1) {
|
|
||||||
return values.iterator().next()
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getValues(): Collection<JetType> {
|
override val values: Collection<JetType>
|
||||||
if (resultValues == null) {
|
get() {
|
||||||
resultValues = computeValues()
|
if (resultValues == null) {
|
||||||
|
resultValues = computeValues()
|
||||||
|
}
|
||||||
|
return resultValues!!
|
||||||
}
|
}
|
||||||
return resultValues!!
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun computeValues(): Collection<JetType> {
|
private fun computeValues(): Collection<JetType> {
|
||||||
val values = LinkedHashSet<JetType>()
|
val values = LinkedHashSet<JetType>()
|
||||||
|
|||||||
Reference in New Issue
Block a user