Files
swift-mirror/test/Generics/function_decls.swift
Doug Gregor ec31aaf04b Parse a generic parameter list within a function declaration, and
introduce the generic type parameters (which are simply type aliases
for a to-be-determined archetype type) into scope for name
lookup. We can now parse something like

  func f<T, U : Range>(x : T, y : U) { }

but there is no semantic analysis or even basic safety checking (yet).




Swift SVN r2197
2012-06-18 22:49:54 +00:00

12 lines
505 B
Swift

// RUN: %swift %s -verify
//===----------------------------------------------------------------------===//
// Generic function declarations
//===----------------------------------------------------------------------===//
func f0<T>(x : Int, y : Int) { }
func f1<T : Any>(x : Int, y : Int) { }
func f2<T : protocol<Range,Any>>(x : Int, y : Int) { }
func f3<T : () -> ()>(x : Int, y : Int) { } // expected-error{{expected a type name or protocol composition restricting 'T'}}
func f4<T>(x : T, y : T) { }