@@ -37,31 +37,14 @@ void Parser::DefaultArgumentInfo::setFunctionContext(
3737 }
3838}
3939
40- static ParserStatus parseDefaultArgument (
41- Parser &P, Parser::DefaultArgumentInfo *defaultArgs, unsigned argIndex ,
42- Expr *&init, bool &hasInheritedDefaultArg ,
43- Parser::ParameterContextKind paramContext) {
40+ static ParserStatus
41+ parseDefaultArgument ( Parser &P, Parser::DefaultArgumentInfo *defaultArgs,
42+ unsigned argIndex, Expr *&init ,
43+ Parser::ParameterContextKind paramContext) {
4444 assert (P.Tok .is (tok::equal) ||
4545 (P.Tok .isBinaryOperator () && P.Tok .getText () == " ==" ));
4646 SourceLoc equalLoc = P.consumeToken ();
4747
48- if (P.SF .Kind == SourceFileKind::Interface) {
49- // Swift module interfaces don't synthesize inherited initializers and
50- // instead include them explicitly in subclasses. Since the
51- // \c DefaultArgumentKind of these initializers is \c Inherited, this is
52- // represented textually as `= super` in the interface.
53-
54- // If we're in a module interface and the default argument is exactly
55- // `super` (i.e. the token after that is `,` or `)` which end a parameter)
56- // report an inherited default argument to the caller and return.
57- if (P.Tok .is (tok::kw_super) && P.peekToken ().isAny (tok::comma, tok::r_paren)) {
58- hasInheritedDefaultArg = true ;
59- P.consumeToken (tok::kw_super);
60- defaultArgs->HasDefaultArgument = true ;
61- return ParserStatus ();
62- }
63- }
64-
6548 // Enter a fresh default-argument context with a meaningless parent.
6649 // We'll change the parent to the function later after we've created
6750 // that declaration.
@@ -483,9 +466,8 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
483466 .fixItReplace (EqualLoc, " =" );
484467 }
485468
486- status |= parseDefaultArgument (
487- *this , defaultArgs, defaultArgIndex, param.DefaultArg ,
488- param.hasInheritedDefaultArg , paramContext);
469+ status |= parseDefaultArgument (*this , defaultArgs, defaultArgIndex,
470+ param.DefaultArg , paramContext);
489471 }
490472
491473 // If we haven't made progress, don't add the parameter.
@@ -547,10 +529,9 @@ mapParsedParameters(Parser &parser,
547529 Identifier argName, SourceLoc argNameLoc,
548530 Identifier paramName, SourceLoc paramNameLoc)
549531 -> ParamDecl * {
550- auto param = new (ctx) ParamDecl (paramInfo.SpecifierLoc ,
551- argNameLoc, argName,
552- paramNameLoc, paramName,
553- parser.CurDeclContext );
532+ auto param = ParamDecl::createParsed (
533+ ctx, paramInfo.SpecifierLoc , argNameLoc, argName, paramNameLoc,
534+ paramName, paramInfo.DefaultArg , parser.CurDeclContext );
554535 param->getAttrs () = paramInfo.Attrs ;
555536
556537 bool parsingEnumElt
@@ -713,8 +694,7 @@ mapParsedParameters(Parser &parser,
713694 param.FirstName , param.FirstNameLoc );
714695 }
715696
716- assert (((!param.DefaultArg &&
717- !param.hasInheritedDefaultArg ) ||
697+ assert ((!param.DefaultArg ||
718698 paramContext == Parser::ParameterContextKind::Function ||
719699 paramContext == Parser::ParameterContextKind::Operator ||
720700 paramContext == Parser::ParameterContextKind::Initializer ||
@@ -723,14 +703,6 @@ mapParsedParameters(Parser &parser,
723703 paramContext == Parser::ParameterContextKind::Macro) &&
724704 " Default arguments are only permitted on the first param clause" );
725705
726- if (param.DefaultArg ) {
727- DefaultArgumentKind kind = getDefaultArgKind (param.DefaultArg );
728- result->setDefaultArgumentKind (kind);
729- result->setDefaultExpr (param.DefaultArg , /* isTypeChecked*/ false );
730- } else if (param.hasInheritedDefaultArg ) {
731- result->setDefaultArgumentKind (DefaultArgumentKind::Inherited);
732- }
733-
734706 elements.push_back (result);
735707
736708 if (argNames)
0 commit comments