File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,11 @@ acceptMeta(A) // expected-error {{expected member name or constructor call after
21
21
22
22
acceptMeta ( ( A) - > Void) // expected-error {{expected member name or constructor call after type name}}
23
23
// expected-note@-1 {{use '.self' to reference the type object}}
24
+
25
+ func id< T> ( _ x: T . Type ) -> T . Type { x }
26
+
27
+ // rdar://62890683: Don't allow arbitrary subtyping for a metatype's instance type.
28
+ let _: A ? . Type = B . self // expected-error {{cannot convert value of type 'B.Type' to specified type 'A?.Type'}}
29
+ let _: A ? . Type = id ( B . self) // expected-error {{cannot convert value of type 'B.Type' to specified type 'A?.Type'}}
30
+ let _: S ? . Type = id ( S . self) // expected-error {{cannot convert value of type 'S.Type' to specified type 'S?.Type'}}
31
+
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ class C {
4
+ init !( ) { }
5
+ }
6
+
7
+ func foo< T> ( _: T . Type , _ fn: ( ) -> T ) { }
8
+
9
+ func test( ) {
10
+ foo ( C . self) { C ( ) }
11
+ }
You can’t perform that action at this time.
0 commit comments