@@ -370,17 +370,6 @@ Type TypeChecker::getArraySliceType(SourceLoc loc, Type elementType) {
370
370
return ArraySliceType::get (elementType);
371
371
}
372
372
373
- Type TypeChecker::getDictionaryType (SourceLoc loc, Type keyType,
374
- Type valueType) {
375
- ASTContext &ctx = keyType->getASTContext ();
376
- if (!ctx.getDictionaryDecl ()) {
377
- ctx.Diags .diagnose (loc, diag::sugar_type_not_found, 3 );
378
- return Type ();
379
- }
380
-
381
- return DictionaryType::get (keyType, valueType);
382
- }
383
-
384
373
Type TypeChecker::getOptionalType (SourceLoc loc, Type elementType) {
385
374
ASTContext &ctx = elementType->getASTContext ();
386
375
if (!ctx.getOptionalDecl ()) {
@@ -3305,11 +3294,13 @@ Type TypeResolver::resolveSpecifierTypeRepr(SpecifierTypeRepr *repr,
3305
3294
Type TypeResolver::resolveArrayType (ArrayTypeRepr *repr,
3306
3295
TypeResolutionOptions options) {
3307
3296
Type baseTy = resolveType (repr->getBase (), options.withoutContext ());
3308
- if (!baseTy || baseTy->hasError ()) return baseTy;
3297
+ if (!baseTy || baseTy->hasError ()) {
3298
+ return ErrorType::get (Context);
3299
+ }
3309
3300
3310
3301
auto sliceTy =
3311
3302
TypeChecker::getArraySliceType (repr->getBrackets ().Start , baseTy);
3312
- if (! sliceTy)
3303
+ if (sliceTy-> hasError () )
3313
3304
return ErrorType::get (Context);
3314
3305
3315
3306
return sliceTy;
@@ -3320,28 +3311,30 @@ Type TypeResolver::resolveDictionaryType(DictionaryTypeRepr *repr,
3320
3311
options = adjustOptionsForGenericArgs (options);
3321
3312
3322
3313
Type keyTy = resolveType (repr->getKey (), options.withoutContext ());
3323
- if (!keyTy || keyTy->hasError ()) return keyTy;
3314
+ if (!keyTy || keyTy->hasError ()) {
3315
+ return ErrorType::get (Context);
3316
+ }
3324
3317
3325
3318
Type valueTy = resolveType (repr->getValue (), options.withoutContext ());
3326
- if (!valueTy || valueTy->hasError ()) return valueTy;
3319
+ if (!valueTy || valueTy->hasError ()) {
3320
+ return ErrorType::get (Context);
3321
+ }
3327
3322
3328
3323
auto dictDecl = Context.getDictionaryDecl ();
3329
-
3330
- if (auto dictTy = TypeChecker::getDictionaryType (repr->getBrackets ().Start ,
3331
- keyTy, valueTy)) {
3332
- auto unboundTy = dictDecl->getDeclaredType ()->castTo <UnboundGenericType>();
3333
-
3334
- Type args[] = {keyTy, valueTy};
3335
-
3336
- if (!TypeChecker::applyUnboundGenericArguments (
3337
- unboundTy, dictDecl, repr->getStartLoc (), resolution, args)) {
3338
- return nullptr ;
3339
- }
3340
-
3341
- return dictTy;
3324
+ if (!dictDecl) {
3325
+ Context.Diags .diagnose (repr->getBrackets ().Start ,
3326
+ diag::sugar_type_not_found, 3 );
3327
+ return ErrorType::get (Context);
3342
3328
}
3343
3329
3344
- return ErrorType::get (Context);
3330
+ auto unboundTy = dictDecl->getDeclaredType ()->castTo <UnboundGenericType>();
3331
+ Type args[] = {keyTy, valueTy};
3332
+ if (!TypeChecker::applyUnboundGenericArguments (
3333
+ unboundTy, dictDecl, repr->getStartLoc (), resolution, args)) {
3334
+ assert (Context.Diags .hadAnyError ());
3335
+ return ErrorType::get (Context);
3336
+ }
3337
+ return DictionaryType::get (keyTy, valueTy);
3345
3338
}
3346
3339
3347
3340
Type TypeResolver::resolveOptionalType (OptionalTypeRepr *repr,
0 commit comments