Skip to content

Commit 7ad33be

Browse files
committed
---
yaml --- r: 346039 b: refs/heads/master c: e46dacb h: refs/heads/master i: 346037: 0552304 346035: a3aa7aa 346031: c5b24db
1 parent 3a6cbb3 commit 7ad33be

38 files changed

+545
-39
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8ea6c5eb2892cf8e5b9174def9e5fc9f6a703794
2+
refs/heads/master: e46dacb96c84ff43a3bd07a97cc05cb5b43bddd2
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/benchmark/utils/ArgParse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func checked<T>(
4646
if let t = try parse(value) { return t }
4747
var type = "\(T.self)"
4848
if type.starts(with: "Optional<") {
49-
let s = type.index(after: type.index(of:"<")!)
49+
let s = type.index(after: type.firstIndex(of: "<")!)
5050
let e = type.index(before: type.endIndex) // ">"
5151
type = String(type[s ..< e]) // strip Optional< >
5252
}
@@ -66,7 +66,7 @@ class ArgumentParser<U> {
6666
private let programName: String = {
6767
// Strip full path from the program name.
6868
let r = CommandLine.arguments[0].reversed()
69-
let ss = r[r.startIndex ..< (r.index(of:"/") ?? r.endIndex)]
69+
let ss = r[r.startIndex ..< (r.firstIndex(of: "/") ?? r.endIndex)]
7070
return String(ss.reversed())
7171
}()
7272
private var positionalArgs = [String]()

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ WARNING(pattern_type_not_usable_from_inline_warn,none,
13631363
"should be '@usableFromInline' or public",
13641364
(bool, bool))
13651365
ERROR(pattern_type_not_usable_from_inline_fixed_layout,none,
1366-
"type referenced from a stored property in a @_fixed_layout struct must "
1366+
"type referenced from a stored property in a '@_fixed_layout' struct must "
13671367
"be '@usableFromInline' or public",
13681368
(/*ignored*/bool, /*ignored*/bool))
13691369
ERROR(pattern_type_not_usable_from_inline_inferred,none,
@@ -1380,7 +1380,7 @@ WARNING(pattern_type_not_usable_from_inline_inferred_warn,none,
13801380
(bool, bool, Type))
13811381
ERROR(pattern_type_not_usable_from_inline_inferred_fixed_layout,none,
13821382
"type referenced from a stored property with inferred type %2 in a "
1383-
"@_fixed_layout struct must be '@usableFromInline' or public",
1383+
"'@_fixed_layout' struct must be '@usableFromInline' or public",
13841384
(/*ignored*/bool, /*ignored*/bool, Type))
13851385

13861386
ERROR(pattern_binds_no_variables,none,

trunk/lib/Sema/CSSimplify.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,21 +1962,23 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
19621962
auto meta1 = cast<AnyMetatypeType>(desugar1);
19631963
auto meta2 = cast<AnyMetatypeType>(desugar2);
19641964

1965-
ConstraintKind subKind = ConstraintKind::Equal;
19661965
// A.Type < B.Type if A < B and both A and B are classes.
1967-
if (isa<MetatypeType>(meta1) &&
1968-
meta1->getInstanceType()->mayHaveSuperclass() &&
1969-
meta2->getInstanceType()->getClassOrBoundGenericClass())
1970-
subKind = std::min(kind, ConstraintKind::Subtype);
19711966
// P.Type < Q.Type if P < Q, both P and Q are protocols, and P.Type
1972-
// and Q.Type are both existential metatypes.
1973-
else if (isa<ExistentialMetatypeType>(meta1))
1974-
subKind = std::min(kind, ConstraintKind::Subtype);
1975-
1976-
return matchTypes(meta1->getInstanceType(), meta2->getInstanceType(),
1977-
subKind, subflags,
1978-
locator.withPathElement(
1979-
ConstraintLocator::InstanceType));
1967+
// and Q.Type are both existential metatypes
1968+
auto subKind = std::min(kind, ConstraintKind::Subtype);
1969+
// If instance types can't have a subtype relationship
1970+
// it means that such types can be simply equated.
1971+
auto instanceType1 = meta1->getInstanceType();
1972+
auto instanceType2 = meta2->getInstanceType();
1973+
if (isa<MetatypeType>(meta1) &&
1974+
!(instanceType1->mayHaveSuperclass() &&
1975+
instanceType2->getClassOrBoundGenericClass())) {
1976+
subKind = ConstraintKind::Equal;
1977+
}
1978+
1979+
return matchTypes(
1980+
instanceType1, instanceType2, subKind, subflags,
1981+
locator.withPathElement(ConstraintLocator::InstanceType));
19801982
}
19811983

19821984
case TypeKind::Function: {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
class A {}
4+
class B: A {}
5+
class C: A {}
6+
7+
struct S {
8+
func foo<T: A>(types: [T.Type]) {}
9+
}
10+
11+
func bar(_ s: S, _ forced_s: S!) {
12+
s.foo(types: [A.self, B.self]) // ok
13+
s.foo(types: [B.self, A.self]) // ok
14+
forced_s.foo(types: [A.self, B.self]) // ok
15+
forced_s.foo(types: [B.self, A.self]) // ok
16+
}

trunk/test/attr/attr_fixed_layout.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,31 @@ struct Rectangle {
7070

7171

7272
@_fixed_layout public struct BadFields1 {
73-
private var field: PrivateStruct // expected-error {{type referenced from a stored property in a @_fixed_layout struct must be '@usableFromInline' or public}}
73+
private var field: PrivateStruct // expected-error {{type referenced from a stored property in a '@_fixed_layout' struct must be '@usableFromInline' or public}}
7474
}
7575

7676
@_fixed_layout public struct BadFields2 {
77-
private var field: PrivateStruct? // expected-error {{type referenced from a stored property in a @_fixed_layout struct must be '@usableFromInline' or public}}
77+
private var field: PrivateStruct? // expected-error {{type referenced from a stored property in a '@_fixed_layout' struct must be '@usableFromInline' or public}}
7878
}
7979

8080
@_fixed_layout public struct BadFields3 {
81-
internal var field: InternalStruct? // expected-error {{type referenced from a stored property in a @_fixed_layout struct must be '@usableFromInline' or public}}
81+
internal var field: InternalStruct? // expected-error {{type referenced from a stored property in a '@_fixed_layout' struct must be '@usableFromInline' or public}}
8282
}
8383

8484
@_fixed_layout @usableFromInline struct BadFields4 {
85-
internal var field: InternalStruct? // expected-error {{type referenced from a stored property in a @_fixed_layout struct must be '@usableFromInline' or public}}
85+
internal var field: InternalStruct? // expected-error {{type referenced from a stored property in a '@_fixed_layout' struct must be '@usableFromInline' or public}}
8686
}
8787

8888
@_fixed_layout public struct BadFields5 {
89-
private var field: PrivateStruct? { // expected-error {{type referenced from a stored property in a @_fixed_layout struct must be '@usableFromInline' or public}}
89+
private var field: PrivateStruct? { // expected-error {{type referenced from a stored property in a '@_fixed_layout' struct must be '@usableFromInline' or public}}
9090
didSet {}
9191
}
9292
}
9393

9494
// expected-warning@+1 {{the result of a '@usableFromInline' function should be '@usableFromInline' or public}}
9595
@usableFromInline func notReallyUsableFromInline() -> InternalStruct? { return nil }
9696
@_fixed_layout public struct BadFields6 {
97-
private var field = notReallyUsableFromInline() // expected-error {{type referenced from a stored property with inferred type 'InternalStruct?' in a @_fixed_layout struct must be '@usableFromInline' or public}}
97+
private var field = notReallyUsableFromInline() // expected-error {{type referenced from a stored property with inferred type 'InternalStruct?' in a '@_fixed_layout' struct must be '@usableFromInline' or public}}
9898
}
9999

100100
@_fixed_layout public struct OKFields {

trunk/test/lit.cfg

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,11 +1219,17 @@ config.target_sil_nm = (
12191219
'%s -target %s %s'
12201220
% (config.sil_nm, config.variant_triple, mcp_opt))
12211221

1222+
rth_flags = ''
1223+
if swift_execution_tests_extra_flags:
1224+
rth_flags = swift_execution_tests_extra_flags + ' -wmo'
1225+
12221226
config.target_resilience_test = (
12231227
'%s --target-build-swift "%s" --target-run "%s" --t %%t --S %%S --s %%s '
1224-
'--lib-prefix "%s" --lib-suffix ".%s" --target-codesign "%s"'
1228+
'--lib-prefix "%s" --lib-suffix ".%s" --target-codesign "%s" '
1229+
'--additional-compile-flags "%s"'
12251230
% (config.rth, config.target_build_swift, config.target_run, 'lib',
1226-
config.target_dylib_extension, config.target_codesign))
1231+
config.target_dylib_extension, config.target_codesign,
1232+
rth_flags))
12271233

12281234
# FIXME: Get symbol diffing working with binutils nm as well. The flags are slightly
12291235
# different.

trunk/utils/rth

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ResilienceTest(object):
3333

3434
def __init__(self, target_build_swift, target_run, target_codesign,
3535
target_nm, tmp_dir, test_dir, test_src, lib_prefix,
36-
lib_suffix, additional_compile_flags_library,
36+
lib_suffix, additional_compile_flags,
3737
no_backward_deployment, no_symbol_diff):
3838
self.target_build_swift = shlex.split(target_build_swift)
3939
self.target_run = shlex.split(target_run)
@@ -44,8 +44,7 @@ class ResilienceTest(object):
4444
self.test_src = test_src
4545
self.lib_prefix = lib_prefix
4646
self.lib_suffix = lib_suffix
47-
self.additional_compile_flags_library = \
48-
shlex.split(additional_compile_flags_library)
47+
self.additional_compile_flags = shlex.split(additional_compile_flags)
4948

5049
self.before_dir = os.path.join(self.tmp_dir, 'before')
5150
self.after_dir = os.path.join(self.tmp_dir, 'after')
@@ -95,7 +94,8 @@ class ResilienceTest(object):
9594
os.path.join('@rpath', lib_file)]
9695

9796
command = self.target_build_swift + \
98-
self.additional_compile_flags_library + compiler_flags
97+
self.additional_compile_flags + \
98+
compiler_flags
9999
verbose_print_command(command)
100100
returncode = subprocess.call(command)
101101
assert returncode == 0, str(command)
@@ -143,7 +143,9 @@ class ResilienceTest(object):
143143
'-Xfrontend', '-enable-class-resilience',
144144
'-I', self.config_dir_map[config],
145145
'-o', output_obj]
146-
command = self.target_build_swift + compiler_flags
146+
command = self.target_build_swift + \
147+
self.additional_compile_flags + \
148+
compiler_flags
147149
verbose_print_command(command)
148150
returncode = subprocess.call(command)
149151
assert returncode == 0, str(command)
@@ -218,7 +220,7 @@ def main():
218220
parser.add_argument('--s', required=True)
219221
parser.add_argument('--lib-prefix', required=True)
220222
parser.add_argument('--lib-suffix', required=True)
221-
parser.add_argument('--additional-compile-flags-library', default='')
223+
parser.add_argument('--additional-compile-flags', default='')
222224
parser.add_argument('--no-backward-deployment', default=False,
223225
action='store_true')
224226
parser.add_argument('--no-symbol-diff', default=False,
@@ -230,7 +232,7 @@ def main():
230232
args.target_codesign, args.target_nm,
231233
args.t, args.S, args.s, args.lib_prefix,
232234
args.lib_suffix,
233-
args.additional_compile_flags_library,
235+
args.additional_compile_flags,
234236
args.no_backward_deployment,
235237
args.no_symbol_diff)
236238

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
open class AddConvenienceInit {
2+
public let age: Int
3+
4+
public init(x: Int) {
5+
self.age = x
6+
}
7+
8+
#if BEFORE
9+
10+
public convenience init(z: Int) {
11+
self.init(x: z * z + 2)
12+
}
13+
14+
#else
15+
16+
public convenience init(z: Int) {
17+
self.init(y: z * z)
18+
}
19+
20+
public convenience init(y: Int) {
21+
self.init(x: y + 2)
22+
}
23+
24+
#endif
25+
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public var count = 0
2+
3+
public func getVersion() -> Int {
4+
#if BEFORE
5+
return 0
6+
#else
7+
return 1
8+
#endif
9+
}
10+
11+
open class Base {
12+
public init() {}
13+
14+
#if AFTER
15+
deinit {
16+
count += 1
17+
}
18+
#endif
19+
}
20+
21+
open class Derived : Base {
22+
deinit {
23+
count += 10
24+
}
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
public var count = 0
2+
3+
public func getVersion() -> Int {
4+
#if BEFORE
5+
return 0
6+
#else
7+
return 1
8+
#endif
9+
}
10+
11+
public class MathClass {
12+
public init() {}
13+
}
14+
15+
public class Attributed {
16+
public init(x: MathClass, y: MathClass) {
17+
self.x = x
18+
self.y = y
19+
}
20+
21+
#if BEFORE
22+
public var x: MathClass?
23+
public var y: MathClass
24+
#else
25+
public weak var x: MathClass?
26+
public unowned var y: MathClass
27+
#endif
28+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
#if BEFORE
3+
4+
public class ChangeLazyToComputed {
5+
private var celsius: Int
6+
7+
public init(celsius: Int) {
8+
self.celsius = celsius
9+
}
10+
11+
public lazy var fahrenheit: Int = (celsius * 9) / 5 + 32
12+
}
13+
14+
#else
15+
16+
public class ChangeLazyToComputed {
17+
private var celsius: Int
18+
19+
public init(celsius: Int) {
20+
self.celsius = celsius
21+
}
22+
23+
public var fahrenheit: Int {
24+
get {
25+
return (celsius * 9) / 5 + 32
26+
}
27+
set {
28+
celsius = ((newValue - 32) * 5) / 9
29+
}
30+
}
31+
}
32+
33+
#endif
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
#if BEFORE
3+
4+
public func getVersion() -> Int {
5+
return 0
6+
}
7+
8+
public class ChangeStoredToObserved {
9+
public var friends: [String] = []
10+
public var count: Int = 0
11+
12+
public var friend: String = "cat"
13+
14+
public init() {}
15+
}
16+
17+
#else
18+
19+
public func getVersion() -> Int {
20+
return 1
21+
22+
}
23+
24+
public class ChangeStoredToObserved {
25+
public var friends: [String] = []
26+
public var count: Int = 0
27+
28+
public var friend: String = "cat" {
29+
willSet {
30+
friends.append(friend)
31+
}
32+
didSet {
33+
count += 1
34+
}
35+
}
36+
37+
public init() {}
38+
}
39+
40+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public struct Rain {
2+
public init() {}
3+
4+
#if BEFORE
5+
public func doIt() {}
6+
#endif
7+
}
8+
9+
public class Snow {
10+
public init() {}
11+
12+
#if BEFORE
13+
public final func doIt() {}
14+
#endif
15+
}
16+
17+
#if AFTER
18+
extension Rain {
19+
public func doIt() {}
20+
}
21+
22+
extension Snow {
23+
public func doIt() {}
24+
}
25+
#endif

0 commit comments

Comments
 (0)