Skip to content

Commit f758930

Browse files
committed
Add a test showing inconsistent generic metatype type resolution
1 parent a41f1b0 commit f758930

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/Generics/generic_types.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,16 @@ struct UnsolvableInheritance2<T : U.A, U : T.A> {}
245245

246246
enum X7<T> where X7.X : G { case X } // expected-error{{enum case 'X' is not a member type of 'X7<T>'}}
247247
// expected-error@-1{{cannot find type 'G' in scope}}
248+
249+
protocol MetatypeTypeResolutionProto {}
250+
struct X8<T> {
251+
static var property1: T.Type { T.self }
252+
static func method1() -> T.Type { T.self }
253+
}
254+
extension X8 where T == MetatypeTypeResolutionProto {
255+
// FIXME: Inconsistent contextual type resolution for generic metatypes;
256+
// should be .Protocol in both cases.
257+
static var property2: T.Type { property1 }
258+
// expected-error@-1 {{cannot convert return expression of type 'MetatypeTypeResolutionProto.Protocol' to return type 'MetatypeTypeResolutionProto.Type'}}
259+
static func method2() -> T.Type { method1() } // ok
260+
}

0 commit comments

Comments
 (0)