use of org.jetbrains.kotlin.types.TypeReconstructionResult in project kotlin by JetBrains.
the class TypeReconstructionUtil method reconstructBareType.
@NotNull
public static KotlinType reconstructBareType(@NotNull KtTypeReference right, @NotNull PossiblyBareType possiblyBareTarget, @Nullable KotlinType subjectType, @NotNull BindingTrace trace, @NotNull KotlinBuiltIns builtIns) {
if (subjectType == null) {
// Recovery: let's reconstruct as if we were casting from Any, to get some type there
subjectType = builtIns.getAnyType();
}
TypeReconstructionResult reconstructionResult = possiblyBareTarget.reconstruct(subjectType);
if (!reconstructionResult.isAllArgumentsInferred()) {
TypeConstructor typeConstructor = possiblyBareTarget.getBareTypeConstructor();
trace.report(NO_TYPE_ARGUMENTS_ON_RHS.on(right, typeConstructor.getParameters().size(), allStarProjectionsString(typeConstructor)));
}
KotlinType targetType = reconstructionResult.getResultingType();
if (targetType != null) {
if (possiblyBareTarget.isBare()) {
trace.record(BindingContext.TYPE, right, targetType);
}
return targetType;
}
return ErrorUtils.createErrorType("Failed to reconstruct type: " + right.getText());
}
Aggregations