Skip to content

Commit 692e6af

Browse files
committed
Turn on Existential Metatypes
These were accidentally left off - turn them on subject to the -enable-parameterized-existential-types flag.
1 parent b6ad4ef commit 692e6af

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/Sema/TypeCheckType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ class TypeResolutionOptions {
288288
case Context::GenericRequirement:
289289
return true;
290290
case Context::ExistentialConstraint:
291+
case Context::MetatypeBase:
291292
return opts.EnableParameterizedExistentialTypes;
292293
case Context::None:
293294
case Context::TypeAliasDecl:
294295
case Context::GenericTypeAliasDecl:
295-
case Context::MetatypeBase:
296296
case Context::InExpression:
297297
case Context::ExplicitCastExpr:
298298
case Context::ForEachStmt:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-typecheck-verify-swift -enable-parameterized-existential-types
2+
//
3+
// FIXME: Merge this file with existential_metatypes.swift once -enable-parameterized-existential-types becomes the default
4+
5+
protocol P<T> {
6+
associatedtype T
7+
}
8+
9+
protocol Q<T> {
10+
associatedtype T
11+
}
12+
13+
protocol PP<U>: P<Self.U.T> {
14+
associatedtype U: P<U>
15+
}
16+
17+
var qp: (any Q<Int>).Type
18+
var pp: (any P<Int>).Type = qp // expected-error{{cannot convert value of type '(any Q<Int>).Type' to specified type '(any P<Int>).Type'}}
19+
20+
var qt: any Q<Int>.Type
21+
qt = qp // expected-error{{cannot assign value of type '(any Q<Int>).Type' to type 'any Q<Int>.Type'}}
22+
qp = qt // expected-error{{cannot assign value of type 'any Q<Int>.Type' to type '(any Q<Int>).Type'}}
23+
var pt: any P<Int>.Type = qt // expected-error{{cannot convert value of type 'any Q<Int>.Type' to specified type 'any P<Int>.Type'}}
24+
pt = pp // expected-error{{cannot assign value of type '(any P<Int>).Type' to type 'any P<Int>.Type'}}
25+
pp = pt // expected-error{{cannot assign value of type 'any P<Int>.Type' to type '(any P<Int>).Type'}}
26+
27+
var ppp: (any PP<Int>).Type
28+
pp = ppp // expected-error{{cannot assign value of type '(any PP<Int>).Type' to type '(any P<Int>).Type'}}
29+
30+
var ppt: any PP<Int>.Type
31+
pt = ppt

0 commit comments

Comments
 (0)