File: typealias.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (34 lines) | stat: -rw-r--r-- 1,639 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: %target-typecheck-verify-swift

//===--- Simple positive tests.

typealias IntPair = (Int, Int)
typealias IntTriple = (Int, Int, Int)
typealias FiveInts = (IntPair, IntTriple)
var fiveInts : FiveInts = ((4,2), (1,2,3))


// <rdar://problem/13339798> QoI: poor diagnostic in malformed typealias
typealias Foo1 : Int  // expected-error {{expected '=' in type alias declaration}} {{16-17==}}
typealias Foo2: Int  // expected-error {{expected '=' in type alias declaration}} {{15-16= =}}
typealias Foo3 :Int  // expected-error {{expected '=' in type alias declaration}} {{16-17== }}
typealias Foo4:/*comment*/Int  // expected-error {{expected '=' in type alias declaration}} {{15-16= = }}

//===--- Tests for error recovery.

typealias Recovery1 // expected-error {{expected '=' in type alias declaration}}

typealias Recovery2 : // expected-error {{expected '=' in type alias declaration}}
// expected-error @-1 {{expected type in type alias declaration}}

typealias Recovery3 = // expected-error {{expected type in type alias declaration}}

typealias Recovery4 : Int // expected-error {{expected '=' in type alias declaration}}

typealias Recovery5 : Int, Float // expected-error {{expected '=' in type alias declaration}}
// expected-error @-1 {{consecutive statements on a line must be separated by ';'}}
// expected-error @-2 {{expected expression}}

typealias Recovery6 = = // expected-error {{expected type in type alias declaration}}

typealias switch = Int // expected-error {{keyword 'switch' cannot be used as an identifier here}} expected-note {{if this name is unavoidable, use backticks to escape it}} {{11-17=`switch`}}