Skip to content

Commit c6bd5c7

Browse files
committed
[Type checker] Validate not-yet-typed declarations we find via unqualified name lookup.
When using the ASTScope-based unqualified name lookup, we might find things that are in scope but haven't been fully type-checked yet; allow us to perform type checking.
1 parent 2b57b80 commit c6bd5c7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE, DeclContext *DC) {
472472
}
473473

474474
ValueDecl *D = Result.Decl;
475+
if (!D->hasType()) validateDecl(D);
476+
475477
if (!D->hasType()) {
476478
assert(D->getDeclContext()->isLocalContext());
477479
if (!D->isInvalid()) {

test/NameBinding/scope_map_lookup.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ protocol Fooable {
104104

105105
var foo: Foo { get }
106106
}
107+
108+
let a = b ; let b = a // expected-error{{could not infer type for 'a'}}
109+
// expected-error@-1 {{'a' used within its own type}}
110+
// FIXME: That second error is bogus.

0 commit comments

Comments
 (0)