mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
There was a ton of complicated logic here to work around two problems: - Same-type constraints were not represented properly in RequirementReprs, requiring us to store them in strong form and parse them out when printing type interfaces. - The TypeBase::getAllGenericArgs() method did not do the right thing for members of protocols and protocol extensions, and so instead of simple calls to Type::subst(), we had an elaborate 'ArchetypeTransformer' abstraction repeated in two places. Rewrite this code to use GenericSignatures and GenericFunctionType instead of old-school GenericParamLists and PolymorphicFunctionType. This changes the code completion and AST printer output slightly. A few of the changes are actually fixes for cases where the old code didn't handle substitutions properly. A few others are subjective, for example a generic parameter list of the form <T : Proto> now prints as <T where T : Proto>. We can add heuristics to make the output whatever we want here; the important thing is that now we're using modern abstractions.
66 lines
959 B
Plaintext
66 lines
959 B
Plaintext
|
|
precedencegroup High {
|
|
associativity: left
|
|
higherThan: BitwiseShiftPrecedence
|
|
}
|
|
|
|
infix operator %%% : High
|
|
|
|
postfix operator =->
|
|
|
|
postfix operator =>
|
|
|
|
func %%%(lhs: Int, rhs: Int) -> Int
|
|
|
|
postfix func =->(lhs: Int) -> Int
|
|
|
|
postfix func =>(lhs: Int) -> Int
|
|
|
|
struct BarGenericSwiftStruct1<T> {
|
|
init(t: T)
|
|
func bar1InstanceFunc()
|
|
}
|
|
|
|
struct BarGenericSwiftStruct2<T, U> where T : BarProtocol {
|
|
init(t: T, u: U)
|
|
func bar2InstanceFunc()
|
|
}
|
|
|
|
protocol BarProtocol {
|
|
func instanceFunc()
|
|
}
|
|
|
|
/// FooSwiftStruct Aaa.
|
|
/**
|
|
* Bbb.
|
|
* Ccc.
|
|
*/
|
|
struct FooSwiftStruct {
|
|
/// fooInstanceFunc Aaa.
|
|
/**
|
|
* Bbb
|
|
*/
|
|
/**
|
|
* Ccc.
|
|
*/
|
|
func fooInstanceFunc()
|
|
init()
|
|
}
|
|
|
|
/// rdar://18457785
|
|
enum MyQuickLookObject {
|
|
/// A rectangle.
|
|
///
|
|
/// Uses explicit coordinates to avoid coupling a particular Cocoa type.
|
|
case Rectangle(Float64, Float64, Float64, Float64)
|
|
}
|
|
|
|
var globalVar: Int
|
|
|
|
func hiddenImport()
|
|
|
|
func overlayedFoo()
|
|
|
|
func visibleImport()
|
|
|