mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Since9ba892cwe always transform `CurrentType` in `ASTPrinter` to be an interface type. This causes issues when the variable type is a generic parameter type. Previously we had `CurrentType` set to a `PrimaryArchetypeType`. With the fix ind93ae06, we are mapping the archetype out of context to a `GenericParamType`. A `GenericParamType`, however, can’t have members, so we’re hitting an assertion when creating a `TypeTransformContext`. Since the entire type transformation in `printTransformedTypeWithOptions` is only affecting type members, we should be able to safely skip over the transformation if `CurrentType` can’t have any members. Fixes rdar://76750555 [SR-14497]
55 lines
1.7 KiB
Swift
55 lines
1.7 KiB
Swift
func testGenerics<T>(x: T) {
|
|
}
|
|
|
|
/// Doc Comment...
|
|
func testGenericsWithComment<T>(x: T) {
|
|
}
|
|
|
|
func someFunc <A>() -> A {
|
|
fatalError()
|
|
}
|
|
|
|
// rdar://problem/36871908
|
|
class MyType<T> {
|
|
let test: Bool = false
|
|
let items: [Int] = []
|
|
func myMethod() {
|
|
if test {}
|
|
for i in items {}
|
|
}
|
|
}
|
|
|
|
// rdar://76750555
|
|
public protocol IP {
|
|
init(networkBytes: Int)
|
|
}
|
|
|
|
public struct HostRecord<IPType: IP> {
|
|
func foo() {
|
|
let ipType = IPType(networkBytes: 42)
|
|
}
|
|
}
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=1:10 %s -- %s | %FileCheck -check-prefix=CHECK1 %s
|
|
// CHECK1: <Declaration>func testGenerics<T>(x: <Type usr="s:15cursor_generics12testGenerics1xyx_tlF1TL_xmfp">T</Type>)</Declaration>
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=5:10 %s -- %s | %FileCheck -check-prefix=CHECK2 %s
|
|
// CHECK2: <Function
|
|
// CHECK2: <Declaration>func testGenericsWithComment<T>(x: T)</Declaration>
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=8:16 %s -- %s | %FileCheck -check-prefix=CHECK3 %s
|
|
// CHECK3: source.lang.swift.decl.generic_type_param
|
|
// CHECK3: <Declaration>A</Declaration>
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=17:8 %s -- %s | %FileCheck -check-prefix=CHECK4 %s
|
|
// CHECK4: source.lang.swift.ref.var.instance
|
|
// CHECK4: <Declaration>let test: <Type usr="s:Sb">Bool</Type></Declaration>
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=18:14 %s -- %s | %FileCheck -check-prefix=CHECK5 %s
|
|
// CHECK5: source.lang.swift.ref.var.instance
|
|
// CHECK5: <Declaration>let items: [<Type usr="s:Si">Int</Type>]</Declaration>
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=29:22 %s -- %s | %FileCheck -check-prefix=CHECK_IP_TYPE %s
|
|
// CHECK_IP_TYPE: source.lang.swift.ref.generic_type_param
|
|
// CHECK_IP_TYPE: <Declaration>IPType : <Type usr="s:15cursor_generics2IPP">IP</Type></Declaration>
|