Skip to content

Commit 6549553

Browse files
committed
[Sema] Emit diagnostic only once
If the TypeRepr is marked invalid, the function isn't called a second time
1 parent b71ad06 commit 6549553

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ Type TypeChecker::applyGenericArguments(Type type, SourceLoc loc,
395395
if (!type->is<ErrorType>())
396396
diagnose(loc, diag::not_a_generic_type, type)
397397
.fixItRemove(generic->getAngleBrackets());
398+
generic->setInvalid();
398399
return type;
399400
}
400401

test/Generics/function_decls.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,4 @@ public class A<X> {
3838

3939
protocol P { associatedtype A }
4040

41-
// FIXME: only emit this diagnostic once
42-
func f12<T : P>(x: T) -> T.A<Int> {}
43-
// expected-error @-1 {{cannot specialize non-generic type 'T.A'}}
44-
// expected-error @-2 {{cannot specialize non-generic type 'T.A'}}
41+
func f12<T : P>(x: T) -> T.A<Int> {} //expected-error{{cannot specialize non-generic type 'T.A'}}{{29-34=}}

0 commit comments

Comments
 (0)