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