Skip to content

Commit 0f6e0db

Browse files
committed
[TypeChecker] Don't double validate dict types
Prior, binding generic args in dictionary type checking would double resolve the key and value types a second time, emitting duplicated errors potentially. Instead, we reuse the resolved types.
1 parent 897fc83 commit 0f6e0db

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,8 @@ Type TypeResolver::resolveDictionaryType(DictionaryTypeRepr *repr,
24372437
// Check the requirements on the generic arguments.
24382438
auto unboundTy = dictDecl->getDeclaredType();
24392439
TypeLoc args[2] = { TypeLoc(repr->getKey()), TypeLoc(repr->getValue()) };
2440+
args[0].setType(keyTy, true);
2441+
args[1].setType(valueTy, true);
24402442

24412443
if (!TC.applyUnboundGenericArguments(
24422444
unboundTy, dictDecl, repr->getStartLoc(), DC, args,

test/attr/attr_escaping.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func misuseEscaping(_ a: (@escaping (Int) -> Int, Int)) {} // expected-error{{@e
8989
func misuseEscaping(_ a: [@escaping (Int) -> Int]) {} // expected-error{{@escaping attribute may only be used in function parameter position}} {{27-37=}}
9090
func misuseEscaping(_ a: [@escaping (Int) -> Int]?) {} // expected-error{{@escaping attribute may only be used in function parameter position}} {{27-37=}}
9191
func misuseEscaping(_ a: [Int : @escaping (Int) -> Int]) {} // expected-error{{@escaping attribute may only be used in function parameter position}} {{33-43=}}
92-
// expected-error@-1{{@escaping attribute may only be used in function parameter position}} {{33-43=}}
9392
func misuseEscaping(_ a: GenericStruct<@escaping (Int) -> Int>) {} // expected-error{{@escaping attribute may only be used in function parameter position}} {{40-50=}}
9493

9594
func takesEscapingGeneric<T>(_ fn: @escaping () -> T) {}

0 commit comments

Comments
 (0)