Skip to content

Commit ddb5c13

Browse files
committed
[Diagnostics] Improve the diagnostics for invalid type access on an
existential type in expression context.
1 parent 6d1b8d4 commit ddb5c13

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4297,7 +4297,8 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
42974297
}
42984298
}
42994299

4300-
if (BaseType->is<AnyMetatypeType>() && !Member->isStatic()) {
4300+
bool isStaticOrTypeMember = Member->isStatic() || isa<TypeDecl>(Member);
4301+
if (BaseType->is<AnyMetatypeType>() && !isStaticOrTypeMember) {
43014302
auto instanceTy = BaseType;
43024303

43034304
if (auto *AMT = instanceTy->getAs<AnyMetatypeType>()) {

test/decl/typealias/protocol.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ struct T5 : P5 {
190190
var v8 = P6.A.self
191191
var v9 = P6.B.self // expected-error {{cannot access type alias 'B' from 'P6'; use a concrete type or generic parameter base instead}}
192192

193+
var v10 = (any P6).A.self
194+
var v11 = (any P6).B.self // expected-error {{cannot access type alias 'B' from 'any P6'; use a concrete type or generic parameter base instead}}
195+
193196
struct Generic<T> {
194197
func okay(value: T.A) where T == any P6 {}
195198

0 commit comments

Comments
 (0)