Skip to content

Commit af9d16b

Browse files
authored
[QoI] Improve diagnostics for unbound generic types (#7178)
Since the type is declared in other modules, we should use Decl instead of its location.
1 parent 24b620c commit af9d16b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ static void diagnoseUnboundGenericType(TypeChecker &tc, Type ty,SourceLoc loc) {
707707
diag.fixItInsertAfter(loc, genericArgsToAdd);
708708
}
709709
}
710-
tc.diagnose(unbound->getDecl()->getLoc(), diag::generic_type_declared_here,
710+
tc.diagnose(unbound->getDecl(), diag::generic_type_declared_here,
711711
unbound->getDecl()->getName());
712712
}
713713

test/Constraints/generics.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,7 @@ func sr3525_2(t: SR_3525<Int>) {
439439
func sr3525_3<T>(t: SR_3525<T>) {
440440
let _ = sr3525_arg_gen(&t) // expected-error {{cannot pass immutable value as inout argument: 't' is a 'let' constant}}
441441
}
442+
443+
class testStdlibType {
444+
let _: Array // expected-error {{reference to generic type 'Array' requires arguments in <...>}} {{15-15=<Any>}}
445+
}

0 commit comments

Comments
 (0)