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.
|
/// Retrieve the ith element type from the resulting tuple type.
|
||||||
auto getOuterElementType = [&](unsigned i) -> Type {
|
auto getOuterElementType = [&](unsigned i) -> Type {
|
||||||
if (!TT) {
|
if (!TT) {
|
||||||
if (auto parenTy = dyn_cast<ParenType>(E->getType().getPointer()))
|
return E->getType()->getWithoutParens();
|
||||||
return parenTy->getUnderlyingType();
|
|
||||||
return E->getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TT->getElementType(i);
|
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
|
// If we have a paren expr and our contextual type is a ParenType, remove the
|
||||||
// paren expr sugar.
|
// paren expr sugar.
|
||||||
if (isa<ParenExpr>(E) && contextualType)
|
if (contextualType)
|
||||||
if (auto *PT = dyn_cast<ParenType>(contextualType.getPointer()))
|
contextualType = contextualType->getWithoutParens();
|
||||||
contextualType = PT->getUnderlyingType();
|
|
||||||
|
|
||||||
if (!typeCheckChildIndependently(E->getSubExpr(), contextualType,
|
if (!typeCheckChildIndependently(E->getSubExpr(), contextualType,
|
||||||
CS->getContextualTypePurpose()))
|
CS->getContextualTypePurpose()))
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -699,14 +699,6 @@ namespace {
|
|||||||
return NTD->getHasFailableInits();
|
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 getOperandCount(Type t) {
|
||||||
size_t nOperands = 0;
|
size_t nOperands = 0;
|
||||||
|
|
||||||
@@ -874,8 +866,8 @@ namespace {
|
|||||||
auto argTy = expr->getArg()->getType();
|
auto argTy = expr->getArg()->getType();
|
||||||
auto argTupleTy = argTy->castTo<TupleType>();
|
auto argTupleTy = argTy->castTo<TupleType>();
|
||||||
auto argTupleExpr = dyn_cast<TupleExpr>(expr->getArg());
|
auto argTupleExpr = dyn_cast<TupleExpr>(expr->getArg());
|
||||||
Type firstArgTy = getInnerParenType(argTupleTy->getElement(0).getType());
|
Type firstArgTy = argTupleTy->getElement(0).getType()->getWithoutParens();
|
||||||
Type secondArgTy = getInnerParenType(argTupleTy->getElement(1).getType());
|
Type secondArgTy = argTupleTy->getElement(1).getType()->getWithoutParens();
|
||||||
|
|
||||||
// Determine whether the given declaration is favored.
|
// Determine whether the given declaration is favored.
|
||||||
auto isFavoredDecl = [&](ValueDecl *value) -> bool {
|
auto isFavoredDecl = [&](ValueDecl *value) -> bool {
|
||||||
|
|||||||
@@ -2839,13 +2839,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
|
|||||||
if (auto fnType =
|
if (auto fnType =
|
||||||
fnTypeWithSelf->getResult()->getAs<FunctionType>()) {
|
fnTypeWithSelf->getResult()->getAs<FunctionType>()) {
|
||||||
|
|
||||||
auto argType = fnType->getInput();
|
auto argType = fnType->getInput()->getWithoutParens();
|
||||||
|
|
||||||
if (auto parenType =
|
|
||||||
dyn_cast<ParenType>(argType.getPointer())) {
|
|
||||||
argType = parenType->getUnderlyingType();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argType->isEqual(favoredType))
|
if (argType->isEqual(favoredType))
|
||||||
result.FavoredChoice = result.ViableCandidates.size();
|
result.FavoredChoice = result.ViableCandidates.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3924,10 +3924,7 @@ static OmissionTypeName getTypeNameForOmission(Type type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look through parentheses.
|
// Look through parentheses.
|
||||||
if (auto parenTy = dyn_cast<ParenType>(type.getPointer())) {
|
type = type->getWithoutParens();
|
||||||
type = parenTy->getUnderlyingType();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look through optionals.
|
// Look through optionals.
|
||||||
if (auto optObjectTy = type->getAnyOptionalObjectType()) {
|
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
|
// If this type is parenthesized, remove the parens. We don't want to
|
||||||
// propagate parens from arguments to the result type.
|
// propagate parens from arguments to the result type.
|
||||||
if (auto *PT = dyn_cast<ParenType>(argTy.getPointer()))
|
argTy = argTy->getWithoutParens();
|
||||||
argTy = PT->getUnderlyingType();
|
|
||||||
|
|
||||||
// If this is the first match against the sugar type we found, use it.
|
// If this is the first match against the sugar type we found, use it.
|
||||||
if (!resultSugarTy) {
|
if (!resultSugarTy) {
|
||||||
|
|||||||
Reference in New Issue
Block a user