- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathlibrary.swift
45 lines (36 loc) · 1.13 KB
/
library.swift
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
35
36
37
38
39
40
41
42
43
44
// RUN: %target-swift-frontend -typecheck %s -I %S/Inputs -enable-source-import -parse-as-library -verify
// Name lookup is global in a library.
varx:x_ty=4
typealiasx_ty=Int
// Name lookup is global in a library.
// This case requires doing semantic analysis (conversion checking) after
// parsing.
vary:y_ty=4
typealiasy_ty=(Int)
// Verify that never-defined types are caught.
varz:z_ty=42 // expected-error {{cannot find type 'z_ty' in scope}}
// Make sure we type-check all declarations before any initializers
vara:Int= b
varb:Int=1
varc=1
vard=2
vare=3
// Name lookup with imports.
import imported_module
func over1(_ x:UInt64){} // expected-note{{found this candidate}}
func over2(_ x:UInt32){}
func over3(_ x:UInt32){}
typealiasover4=UInt32
func testover(){
// FIXME: Very weird diagnostic here.
over1(0) // expected-error{{ambiguous use of 'over1'}}
over2(0)
over3(0) // FIXME: Should we produce an ambiguity error here?
varx:over4=10
}
// Referring to name within a module.
vard2:Swift.Int=5
vary2:library.y_ty=5
func increment_y2(){
y2 = library.y2 +1
}