mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
This commit is contained in:
11
test/Generics/function_decls.swift
Normal file
11
test/Generics/function_decls.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
// 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) { }
|
||||
Reference in New Issue
Block a user