@@ -3026,9 +3026,11 @@ bool TypeChecker::isPassThroughTypealias(TypeAliasDecl *typealias,
3026
3026
3027
3027
Type
3028
3028
ExtendedTypeRequest::evaluate (Evaluator &eval, ExtensionDecl *ext) const {
3029
- auto error = [&ext]() {
3029
+ auto &ctx = ext->getASTContext ();
3030
+
3031
+ auto error = [&]() {
3030
3032
ext->setInvalid ();
3031
- return ErrorType::get (ext-> getASTContext () );
3033
+ return ErrorType::get (ctx );
3032
3034
};
3033
3035
3034
3036
// If we didn't parse a type, fill in an error type and bail out.
@@ -3052,6 +3054,15 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const {
3052
3054
if (extendedType->hasError ())
3053
3055
return error ();
3054
3056
3057
+ auto &diags = ctx.Diags ;
3058
+
3059
+ // Cannot extend types who contain placeholders.
3060
+ if (extendedType->hasPlaceholder ()) {
3061
+ diags.diagnose (ext->getLoc (), diag::extension_placeholder)
3062
+ .highlight (extendedRepr->getSourceRange ());
3063
+ return error ();
3064
+ }
3065
+
3055
3066
// Hack to allow extending a generic typealias.
3056
3067
if (auto *unboundGeneric = extendedType->getAs <UnboundGenericType>()) {
3057
3068
if (auto *aliasDecl = dyn_cast<TypeAliasDecl>(unboundGeneric->getDecl ())) {
@@ -3069,8 +3080,6 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const {
3069
3080
}
3070
3081
}
3071
3082
3072
- auto &diags = ext->getASTContext ().Diags ;
3073
-
3074
3083
// Cannot extend a metatype.
3075
3084
if (extendedType->is <AnyMetatypeType>()) {
3076
3085
diags.diagnose (ext->getLoc (), diag::extension_metatype, extendedType)
@@ -3087,13 +3096,6 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const {
3087
3096
return error ();
3088
3097
}
3089
3098
3090
- // Cannot extend types who contain placeholders.
3091
- if (extendedType->hasPlaceholder ()) {
3092
- diags.diagnose (ext->getLoc (), diag::extension_placeholder)
3093
- .highlight (extendedRepr->getSourceRange ());
3094
- return error ();
3095
- }
3096
-
3097
3099
return extendedType;
3098
3100
}
3099
3101
0 commit comments