diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index ad891af868296..cd78a5ac6d94d 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -1344,6 +1344,9 @@ class alignas(1 << TypeAlignInBits) TypeBase /// the given type. Type replaceDynamicSelfType(Type newSelfType); + /// Hack to deal with ConstructorDecl interface types. + Type withCovariantResultType(); + /// Deprecated in favor of the above. Type replaceCovariantResultType(Type newResultType, unsigned uncurryLevel); diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index ee20b87f48c6a..ef9aca690f6d0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4076,7 +4076,7 @@ AnyFunctionType::Param swift::computeSelfParam(AbstractFunctionDecl *AFD, // Methods returning 'Self' have a dynamic 'self'. // // FIXME: All methods of non-final classes should have this. - else if (wantDynamicSelf && FD->hasDynamicSelfResult()) + else if (wantDynamicSelf && FD->getResultInterfaceType()->hasDynamicSelfType()) isDynamicSelf = true; } else if (auto *CD = dyn_cast(AFD)) { diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 76c725a9df4a0..f31c50f94fa17 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1357,6 +1357,42 @@ Type TypeBase::replaceDynamicSelfType(Type newSelfType) { }); } +Type TypeBase::withCovariantResultType() { + // Unwrap the outer function type. + auto fnType = this->castTo(); + ASSERT(fnType->getParams().size() == 1); + + // Unwrap the inner function type. + auto resultFnType = fnType->getResult()->castTo(); + auto resultType = resultFnType->getResult(); + + bool wasOptional = false; + if (auto objectType = resultType->getOptionalObjectType()) { + wasOptional = true; + resultType = objectType; + } + + ASSERT(resultType->getClassOrBoundGenericClass()); + resultType = DynamicSelfType::get(resultType, getASTContext()); + + // Rebuild the inner function type. + if (wasOptional) + resultType = OptionalType::get(resultType); + + resultFnType = FunctionType::get(resultFnType->getParams(), resultType, + resultFnType->getExtInfo()); + + // Rebuild the outer function type. + if (auto genericFn = dyn_cast(fnType)) { + return GenericFunctionType::get(genericFn->getGenericSignature(), + fnType->getParams(), resultFnType, + fnType->getExtInfo()); + } + + return FunctionType::get(fnType->getParams(), resultFnType, + fnType->getExtInfo()); +} + Type TypeBase::replaceCovariantResultType(Type newResultType, unsigned uncurryLevel) { if (uncurryLevel == 0) { diff --git a/lib/AST/TypeSubstitution.cpp b/lib/AST/TypeSubstitution.cpp index 0749288f2e7e5..2c04ea3de0517 100644 --- a/lib/AST/TypeSubstitution.cpp +++ b/lib/AST/TypeSubstitution.cpp @@ -885,8 +885,9 @@ Type TypeBase::adjustSuperclassMemberDeclType(const ValueDecl *baseDecl, if (auto *afd = dyn_cast(baseDecl)) { type = type->replaceSelfParameterType(this); - if (isa(afd)) - return type->replaceCovariantResultType(this, /*uncurryLevel=*/2); + if (isa(afd) && + afd->getDeclContext()->getSelfClassDecl()) + type = type->withCovariantResultType(); } return type->replaceDynamicSelfType(this); diff --git a/lib/PrintAsClang/DeclAndTypePrinter.cpp b/lib/PrintAsClang/DeclAndTypePrinter.cpp index e222d44613a14..a88f2bd0c7c33 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -1250,7 +1250,8 @@ class DeclAndTypePrinter::Implementation // Constructors and methods returning DynamicSelf return // instancetype. if (isa(AFD) || - (isa(AFD) && cast(AFD)->hasDynamicSelfResult() && + (isa(AFD) && + cast(AFD)->getResultInterfaceType()->hasDynamicSelfType() && !AFD->hasAsync())) { if (errorConvention && errorConvention->stripsResultOptionality()) { printNullability(OTK_Optional, NullabilityPrintKind::ContextSensitive); diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index a3a4504930a2f..bf85680b6a4ea 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -4283,7 +4283,7 @@ class SILVerifier : public SILVerifierBase { // If the method returns dynamic Self, substitute AnyObject for the // result type. if (auto fnDecl = dyn_cast(method.getDecl())) { - if (fnDecl->hasDynamicSelfResult()) { + if (fnDecl->getResultInterfaceType()->hasDynamicSelfType()) { auto anyObjectTy = C.getAnyObjectType(); for (auto &result : results) { auto resultTy = diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index f7fe4c546b8dc..e74eab2ae01af 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -1403,23 +1403,25 @@ namespace { // special handling. if (baseExpr) { if (auto *fnDecl = dyn_cast(declOrClosure)) { - if (fnDecl->hasDynamicSelfResult()) { - Type convTy; - - if (cs.getType(baseExpr)->hasOpenedExistential()) { - // FIXME: Sometimes we need to convert to an opened existential - // first, because CovariantReturnConversionExpr does not support - // direct conversions from a class C to an existential C & P. - convTy = cs.getType(baseExpr)->getMetatypeInstanceType(); - convTy = - thunkTy->getResult()->replaceCovariantResultType(convTy, 0); - } else { - convTy = thunkTy->getResult(); - } + if (fnDecl->getDeclContext()->getSelfClassDecl()) { + if (fnDecl->hasDynamicSelfResult()) { + Type convTy; + + if (cs.getType(baseExpr)->hasOpenedExistential()) { + // FIXME: Sometimes we need to convert to an opened existential + // first, because CovariantReturnConversionExpr does not support + // direct conversions from a class C to an existential C & P. + convTy = cs.getType(baseExpr)->getMetatypeInstanceType(); + if (thunkTy->getResult()->getOptionalObjectType()) + convTy = OptionalType::get(thunkTy); + } else { + convTy = thunkTy->getResult(); + } - if (!thunkBody->getType()->isEqual(convTy)) { - thunkBody = cs.cacheType( - new (ctx) CovariantReturnConversionExpr(thunkBody, convTy)); + if (!thunkBody->getType()->isEqual(convTy)) { + thunkBody = cs.cacheType( + new (ctx) CovariantReturnConversionExpr(thunkBody, convTy)); + } } } } @@ -1964,9 +1966,10 @@ namespace { auto *func = dyn_cast(member); if (func && func->getResultInterfaceType()->hasDynamicSelfType()) { - refTy = refTy->replaceCovariantResultType(containerTy, 2); - adjustedRefTy = adjustedRefTy->replaceCovariantResultType( - containerTy, 2); + ASSERT(refTy->hasDynamicSelfType()); + refTy = refTy->replaceDynamicSelfType(containerTy); + adjustedRefTy = adjustedRefTy->replaceDynamicSelfType( + containerTy); } // Handle all other references. @@ -2110,10 +2113,9 @@ namespace { // // Note: For unbound references this is handled inside the thunk. if (!isUnboundInstanceMember && - !member->getDeclContext()->getSelfProtocolDecl()) { + member->getDeclContext()->getSelfClassDecl()) { if (auto func = dyn_cast(member)) { - if (func->hasDynamicSelfResult() && - !baseTy->getOptionalObjectType()) { + if (func->hasDynamicSelfResult()) { // FIXME: Once CovariantReturnConversionExpr (unchecked_ref_cast) // supports a class existential dest., consider using the opened // type directly to avoid recomputing the 'Self' replacement and @@ -2543,9 +2545,9 @@ namespace { new (ctx) OtherConstructorDeclRefExpr(ref, loc, implicit, resultTy)); // Wrap in covariant `Self` return if needed. - if (selfTy->hasReferenceSemantics()) { - auto covariantTy = resultTy->replaceCovariantResultType( - cs.getType(base)->getWithoutSpecifierType(), 2); + if (ref.getDecl()->getDeclContext()->getSelfClassDecl()) { + auto covariantTy = resultTy->withCovariantResultType() + ->replaceDynamicSelfType(cs.getType(base)->getWithoutSpecifierType()); if (!covariantTy->isEqual(resultTy)) ctorRef = cs.cacheType( new (ctx) CovariantFunctionConversionExpr(ctorRef, covariantTy)); diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 4bf6a62e38af6..b4913ba84113a 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -13210,18 +13210,14 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl( /// The common result type amongst all function overloads. Type commonResultType; - auto updateCommonResultType = [&](Type choiceType) { - auto markFailure = [&] { - commonResultType = ErrorType::get(getASTContext()); - }; - auto choiceFnType = choiceType->getAs(); - if (!choiceFnType) - return markFailure(); + auto markFailure = [&] { + commonResultType = ErrorType::get(getASTContext()); + }; + auto updateCommonResultType = [&](Type choiceResultType) { // For now, don't attempt to establish a common result type when there // are type parameters. - Type choiceResultType = choiceFnType->getResult(); if (choiceResultType->hasTypeParameter()) return markFailure(); @@ -13359,8 +13355,28 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl( choiceType = objectType; } - // If we have a function type, we can compute a common result type. - updateCommonResultType(choiceType); + if (auto *choiceFnType = choiceType->getAs()) { + if (isa(choice.getDecl())) { + auto choiceResultType = choice.getBaseType() + ->getRValueType() + ->getMetatypeInstanceType(); + + if (choiceResultType->getOptionalObjectType()) { + hasUnhandledConstraints = true; + return true; + } + + if (choiceFnType->getResult()->getOptionalObjectType()) + choiceResultType = OptionalType::get(choiceResultType); + + updateCommonResultType(choiceResultType); + } else { + updateCommonResultType(choiceFnType->getResult()); + } + } else { + markFailure(); + } + return true; }); diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 460f489995a4c..84f0d96da50e7 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -6800,13 +6800,15 @@ TypeChecker::omitNeedlessWords(AbstractFunctionDecl *afd) { // Handle contextual type, result type, and returnsSelf. Type contextType = afd->getDeclContext()->getDeclaredInterfaceType(); Type resultType; - bool returnsSelf = afd->hasDynamicSelfResult(); + bool returnsSelf; if (auto func = dyn_cast(afd)) { resultType = func->getResultInterfaceType(); resultType = func->mapTypeIntoContext(resultType); + returnsSelf = func->getResultInterfaceType()->hasDynamicSelfType(); } else if (isa(afd)) { resultType = contextType; + returnsSelf = true; } // Figure out the first parameter name. diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index f4a8dae839360..1fd363ae586ee 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -6641,21 +6641,21 @@ typecheckDifferentiableAttrforDecl(AbstractFunctionDecl *original, // Dynamic `Self` is supported only as a single top-level result for class // members. JVP/VJP functions returning `(Self, ...)` tuples would not // type-check. - bool diagnoseDynamicSelfResult = original->hasDynamicSelfResult(); - if (diagnoseDynamicSelfResult) { - // Diagnose class initializers in non-final classes. - if (isa(original)) { - if (!classDecl->isSemanticallyFinal()) { - diags.diagnose( - attr->getLocation(), - diag::differentiable_attr_nonfinal_class_init_unsupported, - classDecl->getDeclaredInterfaceType()); - attr->setInvalid(); - return nullptr; - } + // Diagnose class initializers in non-final classes. + if (isa(original)) { + if (!classDecl->isSemanticallyFinal()) { + diags.diagnose( + attr->getLocation(), + diag::differentiable_attr_nonfinal_class_init_unsupported, + classDecl->getDeclaredInterfaceType()); + attr->setInvalid(); + return nullptr; } + } + + if (auto *funcDecl = dyn_cast(original)) { // Diagnose all other declarations returning dynamic `Self`. - else { + if (funcDecl->getResultInterfaceType()->hasDynamicSelfType()) { diags.diagnose( attr->getLocation(), diag:: @@ -7035,19 +7035,19 @@ static bool typeCheckDerivativeAttr(DerivativeAttr *attr) { // Dynamic `Self` is supported only as a single top-level result for class // members. JVP/VJP functions returning `(Self, ...)` tuples would not // type-check. - bool diagnoseDynamicSelfResult = originalAFD->hasDynamicSelfResult(); - if (diagnoseDynamicSelfResult) { + if (isa(originalAFD)) { // Diagnose class initializers in non-final classes. - if (isa(originalAFD)) { - if (!classDecl->isSemanticallyFinal()) { - diags.diagnose(attr->getLocation(), - diag::derivative_attr_nonfinal_class_init_unsupported, - classDecl->getDeclaredInterfaceType()); - return true; - } + if (!classDecl->isSemanticallyFinal()) { + diags.diagnose(attr->getLocation(), + diag::derivative_attr_nonfinal_class_init_unsupported, + classDecl->getDeclaredInterfaceType()); + return true; } + } + + if (auto *FD = dyn_cast(originalAFD)) { // Diagnose all other declarations returning dynamic `Self`. - else { + if (FD->getResultInterfaceType()->hasDynamicSelfType()) { diags.diagnose( attr->getLocation(), diag::derivative_attr_class_member_dynamic_self_result_unsupported, diff --git a/lib/Sema/TypeCheckDeclObjC.cpp b/lib/Sema/TypeCheckDeclObjC.cpp index 9762633060006..8e7661055dd66 100644 --- a/lib/Sema/TypeCheckDeclObjC.cpp +++ b/lib/Sema/TypeCheckDeclObjC.cpp @@ -855,7 +855,7 @@ bool swift::isRepresentableInLanguage( // The completion handler transformation cannot properly represent a // dynamic 'Self' type, so disallow @objc for such methods. - if (FD->hasDynamicSelfResult()) { + if (FD->getResultInterfaceType()->hasDynamicSelfType()) { AFD->diagnose(diag::async_objc_dynamic_self) .highlight(AFD->getAsyncLoc()) .limitBehavior(behavior); diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index a1350bfd42a99..2eda2445cc609 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -4246,8 +4246,10 @@ void ConformanceChecker::checkNonFinalClassWitness(ValueDecl *requirement, // by holding onto Self accordingly. if (witness->getDeclContext()->getSelfClassDecl()) { const bool hasDynamicSelfResult = [&] { - if (auto func = dyn_cast(witness)) { - return func->hasDynamicSelfResult(); + if (isa(witness)) { + return true; + } else if (auto func = dyn_cast(witness)) { + return func->getResultInterfaceType()->hasDynamicSelfType(); } else if (auto var = dyn_cast(witness)) { return var->getInterfaceType()->hasDynamicSelfType(); } diff --git a/lib/Sema/TypeOfReference.cpp b/lib/Sema/TypeOfReference.cpp index 30fdee97131b5..c3f66cb463a85 100644 --- a/lib/Sema/TypeOfReference.cpp +++ b/lib/Sema/TypeOfReference.cpp @@ -1008,16 +1008,6 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value, // If we opened up any type variables, record the replacements. recordOpenedTypes(locator, replacements, preparedOverload); - // If this is a method whose result type is dynamic Self, replace - // DynamicSelf with the actual object type. - if (openedType->hasDynamicSelfType()) { - auto params = openedType->getParams(); - assert(params.size() == 1); - Type selfTy = params.front().getPlainType()->getMetatypeInstanceType(); - openedType = openedType->replaceDynamicSelfType(selfTy) - ->castTo(); - } - auto origOpenedType = openedType; if (!isRequirementOrWitness(locator)) { unsigned numApplies = getNumApplications(/*hasAppliedSelf*/ false, @@ -1027,9 +1017,30 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value, replacements, locator, preparedOverload); } + // If this is a method whose result type is dynamic Self, replace + // DynamicSelf with the actual object type. Repeat the adjustment + // for the original and adjusted types. + auto type = openedType; + if (openedType->hasDynamicSelfType()) { + auto params = openedType->getParams(); + assert(params.size() == 1); + Type selfTy = params.front().getPlainType()->getMetatypeInstanceType(); + type = openedType->replaceDynamicSelfType(selfTy) + ->castTo(); + } + + auto origType = origOpenedType; + if (origOpenedType->hasDynamicSelfType()) { + auto params = origOpenedType->getParams(); + assert(params.size() == 1); + Type selfTy = params.front().getPlainType()->getMetatypeInstanceType(); + origType = origOpenedType->replaceDynamicSelfType(selfTy) + ->castTo(); + } + // The reference implicitly binds 'self'. return {origOpenedType, openedType, - origOpenedType->getResult(), openedType->getResult(), Type()}; + origType->getResult(), type->getResult(), Type()}; } // Unqualified reference to a local or global function. @@ -1472,8 +1483,8 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType( if (auto func = dyn_cast(value)) { if (isa(func) && - !baseObjTy->getOptionalObjectType()) { - type = type->replaceCovariantResultType(replacementTy, 2); + func->getDeclContext()->getSelfClassDecl()) { + type = type->withCovariantResultType(); } } @@ -1935,16 +1946,17 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator, if (!allowMembers) return Type(); - const auto withDynamicSelfResultReplaced = [&](Type type, - unsigned uncurryLevel) { - const Type baseObjTy = overload.getBaseType() - ->getRValueType() - ->getMetatypeInstanceType() - ->lookThroughAllOptionalTypes(); + auto getBaseObjectType = [&] () -> Type { + return overload.getBaseType() + ->getRValueType() + ->getMetatypeInstanceType() + ->lookThroughAllOptionalTypes(); + }; - return type->replaceCovariantResultType( - getDynamicSelfReplacementType(baseObjTy, decl, locator), - uncurryLevel); + auto withDynamicSelfResultReplaced = [&](Type type) { + return type->replaceDynamicSelfType( + getDynamicSelfReplacementType( + getBaseObjectType(), decl, locator)); }; SmallVector emptyReplacements; @@ -1955,8 +1967,7 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator, useDC, *this, locator)) elementTy = LValueType::get(elementTy); else if (elementTy->hasDynamicSelfType()) { - elementTy = withDynamicSelfResultReplaced(elementTy, - /*uncurryLevel=*/0); + elementTy = withDynamicSelfResultReplaced(elementTy); } // See ConstraintSystem::resolveOverload() -- optional and dynamic @@ -1980,7 +1991,7 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator, var, overload.getBaseType(), useDC, *this, locator)) { type = LValueType::get(type); } else if (type->hasDynamicSelfType()) { - type = withDynamicSelfResultReplaced(type, /*uncurryLevel=*/0); + type = withDynamicSelfResultReplaced(type); } type = adjustVarTypeForConcurrency( type, var, useDC, GetClosureType{*this}, @@ -1997,26 +2008,17 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator, return Type(); } + if (isa(decl) && + decl->getDeclContext()->getSelfClassDecl()) { + type = type->withCovariantResultType(); + } + // Cope with 'Self' returns. - if (!decl->getDeclContext()->getSelfProtocolDecl()) { - if (isa(decl) && - cast(decl)->hasDynamicSelfResult()) { - if (!overload.getBaseType()) - return Type(); - - if (!overload.getBaseType()->getOptionalObjectType()) { - // `Int??(0)` if we look through all optional types for `Self` - // we'll end up with incorrect type `Int?` for result because - // the actual result type is `Int??`. - if (isa(decl) && overload.getBaseType() - ->getRValueType() - ->getMetatypeInstanceType() - ->getOptionalObjectType()) - return Type(); - - type = withDynamicSelfResultReplaced(type, /*uncurryLevel=*/2); - } - } + if (type->hasDynamicSelfType()) { + if (!overload.getBaseType()) + return Type(); + + type = withDynamicSelfResultReplaced(type); } auto hasAppliedSelf = diff --git a/test/Constraints/pack-expansion-expressions.swift b/test/Constraints/pack-expansion-expressions.swift index cfee782a59d80..c9b6d65fae32a 100644 --- a/test/Constraints/pack-expansion-expressions.swift +++ b/test/Constraints/pack-expansion-expressions.swift @@ -327,28 +327,28 @@ func test_pack_expansions_with_closures() { func test_pack_expansion_specialization(tuple: (Int, String, Float)) { struct Data { init(_: repeat each T) {} // expected-note 4 {{'init(_:)' declared here}} - init(vals: repeat each T) {} - init(x: Int, _: repeat each T, y: repeat each U) {} + init(vals: repeat each T) {} // expected-note {{'init(vals:)' declared here}} + init(x: Int, _: repeat each T, y: repeat each U) {} // expected-note 3 {{'init(x:_:y:)' declared here}} } _ = Data() // expected-error {{missing argument for parameter #1 in call}} _ = Data(0) // Ok _ = Data(42, "") // Ok - _ = Data(42, "") // expected-error {{pack expansion requires that 'Int' and 'Int, String' have the same shape}} + _ = Data(42, "") // expected-error {{extra argument in call}} _ = Data((42, "")) // expected-error@-1 {{initializer expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{25-26=}} {{32-33=}} _ = Data(vals: (42, "", 0)) - // expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Int)' have the same shape}} + // expected-error@-1 {{initializer expects 3 separate arguments; remove extra parentheses to change tuple into separate arguments}} _ = Data((vals: 42, "", 0)) // expected-error@-1 {{initializer expects 3 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{32-33=}} {{48-49=}} _ = Data(tuple) // expected-error@-1 {{initializer expects 3 separate arguments}} _ = Data(x: 42, tuple) - // expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Float)' have the same shape}} + // expected-error@-1 {{missing arguments for parameters #2, #2 in call}} _ = Data(x: 42, tuple, y: 1, 2, 3) - // expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Float)' have the same shape}} + // expected-error@-1 {{missing arguments for parameters #2, #2 in call}} _ = Data(x: 42, (42, "", 0), y: 1, 2, 3) - // expected-error@-1 {{pack expansion requires that 'Int, String, Float' and '(Int, String, Int)' have the same shape}} + // expected-error@-1 {{missing arguments for parameters #2, #2 in call}} struct Ambiguity { func test(_: repeat each T) -> Int { 42 } diff --git a/test/IDE/complete_init.swift b/test/IDE/complete_init.swift index db5469201a63f..a36081020d3d9 100644 --- a/test/IDE/complete_init.swift +++ b/test/IDE/complete_init.swift @@ -138,8 +138,8 @@ typealias CAlias = C var CAliasInstance = CAlias(#^ALIAS_CONSTRUCTOR_0^# // rdar://18586415 -// ALIAS_CONSTRUCTOR_0: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#x: A#}[')'][#CAlias#]; -// ALIAS_CONSTRUCTOR_0: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#y: A#}[')'][#CAlias#]; +// ALIAS_CONSTRUCTOR_0: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#x: A#}[')'][#C#]; +// ALIAS_CONSTRUCTOR_0: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#y: A#}[')'][#C#]; // https://github.com/apple/swift/issues/57916 struct Issue57916 { diff --git a/test/decl/protocol/conforms/typed_throws.swift b/test/decl/protocol/conforms/typed_throws.swift index 85306c4ae5a5f..f030b2031d3ee 100644 --- a/test/decl/protocol/conforms/typed_throws.swift +++ b/test/decl/protocol/conforms/typed_throws.swift @@ -62,7 +62,7 @@ struct S3: FailureAssociatedType { func testAssociatedTypes() { let _ = S1.Failure() // expected-error{{'S1.Failure' (aka 'MyError') cannot be constructed because it has no accessible initializers}} let _ = S2.Failure() // expected-error{{'S2.Failure' (aka 'any Error') cannot be constructed because it has no accessible initializers}} - let _: Int = S3.Failure() // expected-error{{cannot convert value of type 'S3.Failure' (aka 'Never') to specified type 'Int'}} + let _: Int = S3.Failure() // expected-error{{cannot convert value of type 'Never' to specified type 'Int'}} // expected-error@-1{{missing argument for parameter 'from' in call}} } diff --git a/test/decl/typealias/generic.swift b/test/decl/typealias/generic.swift index 1314602a75fe0..75a893ba3d099 100644 --- a/test/decl/typealias/generic.swift +++ b/test/decl/typealias/generic.swift @@ -178,7 +178,7 @@ class GenericClass { } func testCaptureInvalid1(s: S, t: T) -> TA { - return TA(a: t, b: s) // expected-error {{cannot convert return expression of type 'GenericClass.TA' (aka 'MyType') to return type 'GenericClass.TA' (aka 'MyType')}} + return TA(a: t, b: s) // expected-error {{cannot convert return expression of type 'MyType' to return type 'GenericClass.TA' (aka 'MyType')}} } func testCaptureInvalid2(s: Int, t: T) -> TA {