diff --git a/lib/Sema/DerivedConformanceAdditiveArithmetic.cpp b/lib/Sema/DerivedConformanceAdditiveArithmetic.cpp index 8f38f6e6b14..4f0d38ba6c1 100644 --- a/lib/Sema/DerivedConformanceAdditiveArithmetic.cpp +++ b/lib/Sema/DerivedConformanceAdditiveArithmetic.cpp @@ -126,11 +126,10 @@ deriveBodyMathOperator(AbstractFunctionDecl *funcDecl, MathOperator op) { confRef.getConcrete()->getWitnessDecl(operatorReq)) memberOpDecl = concreteMemberMethodDecl; assert(memberOpDecl && "Member operator declaration must exist"); - auto memberOpDRE = - new (C) DeclRefExpr(memberOpDecl, DeclNameLoc(), /*Implicit*/ true); auto *memberTypeExpr = TypeExpr::createImplicit(memberType, C); auto memberOpExpr = - new (C) DotSyntaxCallExpr(memberOpDRE, SourceLoc(), memberTypeExpr); + new (C) MemberRefExpr(memberTypeExpr, SourceLoc(), memberOpDecl, + DeclNameLoc(), /*Implicit*/ true); // Create expression `lhs.member rhs.member`. // NOTE(TF-1054): create new `DeclRefExpr`s per loop iteration to avoid diff --git a/lib/Sema/DerivedConformanceCaseIterable.cpp b/lib/Sema/DerivedConformanceCaseIterable.cpp index a1c445efe32..19dee6674aa 100644 --- a/lib/Sema/DerivedConformanceCaseIterable.cpp +++ b/lib/Sema/DerivedConformanceCaseIterable.cpp @@ -48,9 +48,9 @@ deriveCaseIterable_enum_getter(AbstractFunctionDecl *funcDecl, void *) { SmallVector elExprs; for (EnumElementDecl *elt : parentEnum->getAllElements()) { - auto *ref = new (C) DeclRefExpr(elt, DeclNameLoc(), /*implicit*/true); auto *base = TypeExpr::createImplicit(enumTy, C); - auto *apply = new (C) DotSyntaxCallExpr(ref, SourceLoc(), base); + auto *apply = new (C) MemberRefExpr(base, SourceLoc(), + elt, DeclNameLoc(), /*implicit*/true); elExprs.push_back(apply); } auto *arrayExpr = ArrayExpr::create(C, SourceLoc(), elExprs, {}, SourceLoc()); diff --git a/lib/Sema/DerivedConformanceCodable.cpp b/lib/Sema/DerivedConformanceCodable.cpp index ae8f1d7b1ea..3f2d927c4ed 100644 --- a/lib/Sema/DerivedConformanceCodable.cpp +++ b/lib/Sema/DerivedConformanceCodable.cpp @@ -619,9 +619,9 @@ deriveBodyEncodable_encode(AbstractFunctionDecl *encodeDecl, void *) { DeclNameLoc(), /*Implicit=*/true); // CodingKeys.x - auto *eltRef = new (C) DeclRefExpr(elt, DeclNameLoc(), /*implicit=*/true); auto *metaTyRef = TypeExpr::createImplicit(codingKeysType, C); - auto *keyExpr = new (C) DotSyntaxCallExpr(eltRef, SourceLoc(), metaTyRef); + auto *keyExpr = new (C) MemberRefExpr(metaTyRef, SourceLoc(), elt, + DeclNameLoc(), /*Implicit=*/true); // encode(_:forKey:)/encodeIfPresent(_:forKey:) auto methodName = useIfPresentVariant ? C.Id_encodeIfPresent : C.Id_encode; @@ -901,9 +901,9 @@ deriveBodyDecodable_init(AbstractFunctionDecl *initDecl, void *) { SourceLoc(), varType); // CodingKeys.x - auto *eltRef = new (C) DeclRefExpr(elt, DeclNameLoc(), /*implicit=*/true); metaTyRef = TypeExpr::createImplicit(codingKeysType, C); - auto *keyExpr = new (C) DotSyntaxCallExpr(eltRef, SourceLoc(), metaTyRef); + auto *keyExpr = new (C) MemberRefExpr(metaTyRef, SourceLoc(), + elt, DeclNameLoc(), /*Implicit=*/true); // decode(_:forKey:)/decodeIfPresent(_:forKey:) SmallVector argNames{Identifier(), C.Id_forKey}; diff --git a/lib/Sema/DerivedConformanceCodingKey.cpp b/lib/Sema/DerivedConformanceCodingKey.cpp index 03a5a47335c..e233a7a47f9 100644 --- a/lib/Sema/DerivedConformanceCodingKey.cpp +++ b/lib/Sema/DerivedConformanceCodingKey.cpp @@ -284,9 +284,9 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl, void *) { auto labelItem = CaseLabelItem(litPat); - auto *eltRef = new (C) DeclRefExpr(elt, DeclNameLoc(), /*Implicit=*/true); auto *metaTyRef = TypeExpr::createImplicit(enumType, C); - auto *valueExpr = new (C) DotSyntaxCallExpr(eltRef, SourceLoc(), metaTyRef); + auto *valueExpr = new (C) MemberRefExpr(metaTyRef, SourceLoc(), elt, + DeclNameLoc(), /*Implicit=*/true); auto *assignment = new (C) AssignExpr(selfRef, SourceLoc(), valueExpr, /*Implicit=*/true); diff --git a/lib/Sema/DerivedConformanceComparable.cpp b/lib/Sema/DerivedConformanceComparable.cpp index 216db050d32..3e7325ede4b 100644 --- a/lib/Sema/DerivedConformanceComparable.cpp +++ b/lib/Sema/DerivedConformanceComparable.cpp @@ -74,39 +74,21 @@ deriveBodyComparable_enum_noAssociatedValues_lt(AbstractFunctionDecl *ltDecl, FuncDecl *cmpFunc = C.getLessThanIntDecl(); assert(cmpFunc && "should have a < for int as we already checked for it"); - auto fnType = cmpFunc->getInterfaceType()->castTo(); + Expr *cmpFuncExpr = new (C) DeclRefExpr(cmpFunc, DeclNameLoc(), + /*implicit*/ true, + AccessSemantics::Ordinary); - Expr *cmpFuncExpr; - if (cmpFunc->getDeclContext()->isTypeContext()) { - auto contextTy = cmpFunc->getDeclContext()->getSelfInterfaceType(); - Expr *base = TypeExpr::createImplicitHack(SourceLoc(), contextTy, C); - Expr *ref = new (C) DeclRefExpr(cmpFunc, DeclNameLoc(), /*Implicit*/ true, - AccessSemantics::Ordinary, fnType); - - fnType = fnType->getResult()->castTo(); - cmpFuncExpr = new (C) DotSyntaxCallExpr(ref, SourceLoc(), base, fnType); - cmpFuncExpr->setImplicit(); - } else { - cmpFuncExpr = new (C) DeclRefExpr(cmpFunc, DeclNameLoc(), - /*implicit*/ true, - AccessSemantics::Ordinary, - fnType); - } - - TupleTypeElt abTupleElts[2] = { aIndex->getType(), bIndex->getType() }; TupleExpr *abTuple = TupleExpr::create(C, SourceLoc(), { aIndex, bIndex }, { }, { }, SourceLoc(), /*HasTrailingClosure*/ false, - /*Implicit*/ true, - TupleType::get(abTupleElts, C)); + /*Implicit*/ true); auto *cmpExpr = new (C) BinaryExpr( - cmpFuncExpr, abTuple, /*implicit*/ true, - fnType->castTo()->getResult()); + cmpFuncExpr, abTuple, /*implicit*/ true); statements.push_back(new (C) ReturnStmt(SourceLoc(), cmpExpr)); BraceStmt *body = BraceStmt::create(C, SourceLoc(), statements, SourceLoc()); - return { body, /*isTypeChecked=*/true }; + return { body, /*isTypeChecked=*/false }; } /// Derive the body for an '==' operator for an enum where at least one of the diff --git a/lib/Sema/DerivedConformanceDifferentiable.cpp b/lib/Sema/DerivedConformanceDifferentiable.cpp index a4228a08ac0..82a5c3f76f6 100644 --- a/lib/Sema/DerivedConformanceDifferentiable.cpp +++ b/lib/Sema/DerivedConformanceDifferentiable.cpp @@ -268,16 +268,14 @@ deriveBodyDifferentiable_move(AbstractFunctionDecl *funcDecl, void *) { if (auto *witness = confRef.getConcrete()->getWitnessDecl(requirement)) memberWitnessDecl = witness; assert(memberWitnessDecl && "Member witness declaration must exist"); - auto *memberMethodDRE = new (C) - DeclRefExpr(memberWitnessDecl, DeclNameLoc(), /*Implicit*/ true); - memberMethodDRE->setFunctionRefKind(FunctionRefKind::SingleApply); // Create reference to member method: `self..move(along:)`. Expr *memberExpr = new (C) MemberRefExpr(selfDRE, SourceLoc(), member, DeclNameLoc(), /*Implicit*/ true); auto *memberMethodExpr = - new (C) DotSyntaxCallExpr(memberMethodDRE, SourceLoc(), memberExpr); + new (C) MemberRefExpr(memberExpr, SourceLoc(), memberWitnessDecl, + DeclNameLoc(), /*Implicit*/ true); // Create reference to parameter member: `direction.`. VarDecl *paramMember = nullptr; diff --git a/lib/Sema/DerivedConformanceEquatableHashable.cpp b/lib/Sema/DerivedConformanceEquatableHashable.cpp index 589c61b447d..fee4e9012b3 100644 --- a/lib/Sema/DerivedConformanceEquatableHashable.cpp +++ b/lib/Sema/DerivedConformanceEquatableHashable.cpp @@ -386,19 +386,17 @@ deriveBodyEquatable_struct_eq(AbstractFunctionDecl *eqDecl, void *) { if (!propertyDecl->isUserAccessible()) continue; - auto aPropertyRef = new (C) DeclRefExpr(propertyDecl, DeclNameLoc(), - /*implicit*/ true); auto aParamRef = new (C) DeclRefExpr(aParam, DeclNameLoc(), /*implicit*/ true); - auto aPropertyExpr = new (C) DotSyntaxCallExpr(aPropertyRef, SourceLoc(), - aParamRef); + auto aPropertyExpr = new (C) MemberRefExpr(aParamRef, SourceLoc(), + propertyDecl, DeclNameLoc(), + /*implicit*/ true); - auto bPropertyRef = new (C) DeclRefExpr(propertyDecl, DeclNameLoc(), - /*implicit*/ true); auto bParamRef = new (C) DeclRefExpr(bParam, DeclNameLoc(), /*implicit*/ true); - auto bPropertyExpr = new (C) DotSyntaxCallExpr(bPropertyRef, SourceLoc(), - bParamRef); + auto bPropertyExpr = new (C) MemberRefExpr(bParamRef, SourceLoc(), + propertyDecl, DeclNameLoc(), + /*implicit*/ true); auto guardStmt = DerivedConformance::returnFalseIfNotEqualGuard(C, aPropertyExpr, bPropertyExpr); @@ -873,12 +871,12 @@ deriveBodyHashable_struct_hashInto(AbstractFunctionDecl *hashIntoDecl, void *) { if (!propertyDecl->isUserAccessible()) continue; - auto propertyRef = new (C) DeclRefExpr(propertyDecl, DeclNameLoc(), - /*implicit*/ true); auto selfRef = new (C) DeclRefExpr(selfDecl, DeclNameLoc(), /*implicit*/ true); - auto selfPropertyExpr = new (C) DotSyntaxCallExpr(propertyRef, SourceLoc(), - selfRef); + auto selfPropertyExpr = new (C) MemberRefExpr(selfRef, SourceLoc(), + propertyDecl, DeclNameLoc(), + /*implicit*/ true); + // Generate: hasher.combine(self.) auto combineExpr = createHasherCombineCall(C, hasherParam, selfPropertyExpr); statements.emplace_back(ASTNode(combineExpr)); diff --git a/lib/Sema/DerivedConformanceRawRepresentable.cpp b/lib/Sema/DerivedConformanceRawRepresentable.cpp index beb22f6af41..2c03f3f5660 100644 --- a/lib/Sema/DerivedConformanceRawRepresentable.cpp +++ b/lib/Sema/DerivedConformanceRawRepresentable.cpp @@ -332,9 +332,9 @@ deriveBodyRawRepresentable_init(AbstractFunctionDecl *initDecl, void *) { // Create a statement which assigns the case to self. // valueExpr = "\(enumType).\(elt)" - auto eltRef = new (C) DeclRefExpr(elt, DeclNameLoc(), /*implicit*/true); auto metaTyRef = TypeExpr::createImplicit(enumType, C); - auto valueExpr = new (C) DotSyntaxCallExpr(eltRef, SourceLoc(), metaTyRef); + auto valueExpr = new (C) MemberRefExpr(metaTyRef, SourceLoc(), + elt, DeclNameLoc(), /*implicit*/true); // assignment = "self = \(valueExpr)" auto selfRef = new (C) DeclRefExpr(selfDecl, DeclNameLoc(), diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 113e01d9789..bb54abd9ffa 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -1900,17 +1900,13 @@ void AttributeChecker::visitMainTypeAttr(MainTypeAttr *attr) { } auto funcDeclRef = ConcreteDeclRef(mainFunction, substitutionMap); - auto *funcDeclRefExpr = new (context) DeclRefExpr( - funcDeclRef, DeclNameLoc(location), /*Implicit*/ true); - funcDeclRefExpr->setImplicit(true); - funcDeclRefExpr->setType(mainFunction->getInterfaceType()); - auto *dotSyntaxCallExpr = new (context) DotSyntaxCallExpr( - funcDeclRefExpr, /*DotLoc*/ SourceLoc(), typeExpr, voidToVoidFunctionType); - dotSyntaxCallExpr->setImplicit(true); - dotSyntaxCallExpr->setThrows(mainFunctionThrows); + auto *memberRefExpr = new (context) MemberRefExpr( + typeExpr, SourceLoc(), funcDeclRef, DeclNameLoc(location), + /*Implicit*/ true); + memberRefExpr->setImplicit(true); - auto *callExpr = CallExpr::createImplicit(context, dotSyntaxCallExpr, {}, {}); + auto *callExpr = CallExpr::createImplicit(context, memberRefExpr, {}, {}); callExpr->setImplicit(true); callExpr->setThrows(mainFunctionThrows); callExpr->setType(context.TheEmptyTupleType);