mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Normalize the way paren types are stripped in Sema.
This commit is contained in:
@@ -1487,9 +1487,7 @@ struct ASTNodeBase {};
|
||||
/// Retrieve the ith element type from the resulting tuple type.
|
||||
auto getOuterElementType = [&](unsigned i) -> Type {
|
||||
if (!TT) {
|
||||
if (auto parenTy = dyn_cast<ParenType>(E->getType().getPointer()))
|
||||
return parenTy->getUnderlyingType();
|
||||
return E->getType();
|
||||
return E->getType()->getWithoutParens();
|
||||
}
|
||||
|
||||
return TT->getElementType(i);
|
||||
|
||||
@@ -6388,10 +6388,8 @@ bool FailureDiagnosis::visitIdentityExpr(IdentityExpr *E) {
|
||||
|
||||
// If we have a paren expr and our contextual type is a ParenType, remove the
|
||||
// paren expr sugar.
|
||||
if (isa<ParenExpr>(E) && contextualType)
|
||||
if (auto *PT = dyn_cast<ParenType>(contextualType.getPointer()))
|
||||
contextualType = PT->getUnderlyingType();
|
||||
|
||||
if (contextualType)
|
||||
contextualType = contextualType->getWithoutParens();
|
||||
if (!typeCheckChildIndependently(E->getSubExpr(), contextualType,
|
||||
CS->getContextualTypePurpose()))
|
||||
return true;
|
||||
|
||||
@@ -699,14 +699,6 @@ namespace {
|
||||
return NTD->getHasFailableInits();
|
||||
}
|
||||
|
||||
Type getInnerParenType(const Type &t) {
|
||||
if (auto parenType = dyn_cast<ParenType>(t.getPointer())) {
|
||||
return getInnerParenType(parenType->getUnderlyingType());
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
size_t getOperandCount(Type t) {
|
||||
size_t nOperands = 0;
|
||||
|
||||
@@ -874,8 +866,8 @@ namespace {
|
||||
auto argTy = expr->getArg()->getType();
|
||||
auto argTupleTy = argTy->castTo<TupleType>();
|
||||
auto argTupleExpr = dyn_cast<TupleExpr>(expr->getArg());
|
||||
Type firstArgTy = getInnerParenType(argTupleTy->getElement(0).getType());
|
||||
Type secondArgTy = getInnerParenType(argTupleTy->getElement(1).getType());
|
||||
Type firstArgTy = argTupleTy->getElement(0).getType()->getWithoutParens();
|
||||
Type secondArgTy = argTupleTy->getElement(1).getType()->getWithoutParens();
|
||||
|
||||
// Determine whether the given declaration is favored.
|
||||
auto isFavoredDecl = [&](ValueDecl *value) -> bool {
|
||||
|
||||
@@ -2839,13 +2839,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
|
||||
if (auto fnType =
|
||||
fnTypeWithSelf->getResult()->getAs<FunctionType>()) {
|
||||
|
||||
auto argType = fnType->getInput();
|
||||
|
||||
if (auto parenType =
|
||||
dyn_cast<ParenType>(argType.getPointer())) {
|
||||
argType = parenType->getUnderlyingType();
|
||||
}
|
||||
|
||||
auto argType = fnType->getInput()->getWithoutParens();
|
||||
if (argType->isEqual(favoredType))
|
||||
result.FavoredChoice = result.ViableCandidates.size();
|
||||
}
|
||||
|
||||
@@ -3924,10 +3924,7 @@ static OmissionTypeName getTypeNameForOmission(Type type) {
|
||||
}
|
||||
|
||||
// Look through parentheses.
|
||||
if (auto parenTy = dyn_cast<ParenType>(type.getPointer())) {
|
||||
type = parenTy->getUnderlyingType();
|
||||
continue;
|
||||
}
|
||||
type = type->getWithoutParens();
|
||||
|
||||
// Look through optionals.
|
||||
if (auto optObjectTy = type->getAnyOptionalObjectType()) {
|
||||
|
||||
@@ -54,8 +54,7 @@ static void substituteInputSugarArgumentType(Type argTy, CanType resultTy,
|
||||
|
||||
// If this type is parenthesized, remove the parens. We don't want to
|
||||
// propagate parens from arguments to the result type.
|
||||
if (auto *PT = dyn_cast<ParenType>(argTy.getPointer()))
|
||||
argTy = PT->getUnderlyingType();
|
||||
argTy = argTy->getWithoutParens();
|
||||
|
||||
// If this is the first match against the sugar type we found, use it.
|
||||
if (!resultSugarTy) {
|
||||
|
||||
Reference in New Issue
Block a user