@@ -1100,6 +1100,7 @@ bool TypeChecker::coercePatternToType(Pattern *&P, TypeResolution resolution,
1100
1100
Type diagTy = type->getOptionalObjectType ();
1101
1101
if (!diagTy) diagTy = type;
1102
1102
1103
+ auto diag = diag::type_inferred_to_undesirable_type;
1103
1104
bool shouldRequireType = false ;
1104
1105
if (NP->isImplicit ()) {
1105
1106
// If the whole pattern is implicit, the user didn't write it.
@@ -1111,14 +1112,22 @@ bool TypeChecker::coercePatternToType(Pattern *&P, TypeResolution resolution,
1111
1112
shouldRequireType = true ;
1112
1113
} else if (diagTy->isStructurallyUninhabited ()) {
1113
1114
shouldRequireType = true ;
1115
+ diag = diag::type_inferred_to_uninhabited_type;
1116
+
1117
+ if (diagTy->is <TupleType>()) {
1118
+ diag = diag::type_inferred_to_uninhabited_tuple_type;
1119
+ } else {
1120
+ assert ((diagTy->is <EnumType>() || diagTy->is <BoundGenericEnumType>()) &&
1121
+ " unknown structurally uninhabited type" );
1122
+ }
1114
1123
}
1115
1124
1116
1125
if (shouldRequireType &&
1117
1126
!options.is (TypeResolverContext::ForEachStmt) &&
1118
1127
!options.is (TypeResolverContext::EditorPlaceholderExpr) &&
1119
1128
!(options & TypeResolutionFlags::FromNonInferredPattern)) {
1120
- diagnose (NP->getLoc (), diag::type_inferred_to_undesirable_type ,
1121
- NP->getDecl ()->getName (), type, NP-> getDecl ()-> isLet ());
1129
+ diagnose (NP->getLoc (), diag, NP-> getDecl ()-> getName (), type ,
1130
+ NP->getDecl ()->isLet ());
1122
1131
diagnose (NP->getLoc (), diag::add_explicit_type_annotation_to_silence);
1123
1132
}
1124
1133
0 commit comments