Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ WARNING(pattern_type_not_usable_from_inline_warn,none,
"should be '@usableFromInline' or public",
(bool, bool))
ERROR(pattern_type_not_usable_from_inline_fixed_layout,none,
"type referenced from a stored property in a @_fixed_layout struct must "
"type referenced from a stored property in a '@_fixed_layout' struct must "
"be '@usableFromInline' or public",
(/*ignored*/bool, /*ignored*/bool))
ERROR(pattern_type_not_usable_from_inline_inferred,none,
Expand All @@ -1380,7 +1380,7 @@ WARNING(pattern_type_not_usable_from_inline_inferred_warn,none,
(bool, bool, Type))
ERROR(pattern_type_not_usable_from_inline_inferred_fixed_layout,none,
"type referenced from a stored property with inferred type %2 in a "
"@_fixed_layout struct must be '@usableFromInline' or public",
"'@_fixed_layout' struct must be '@usableFromInline' or public",
(/*ignored*/bool, /*ignored*/bool, Type))

ERROR(pattern_binds_no_variables,none,
Expand Down
12 changes: 6 additions & 6 deletions test/attr/attr_fixed_layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,31 @@ struct Rectangle {


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

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

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

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

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

// expected-warning@+1 {{the result of a '@usableFromInline' function should be '@usableFromInline' or public}}
@usableFromInline func notReallyUsableFromInline() -> InternalStruct? { return nil }
@_fixed_layout public struct BadFields6 {
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}}
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}}
}

@_fixed_layout public struct OKFields {
Expand Down
10 changes: 8 additions & 2 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1219,11 +1219,17 @@ config.target_sil_nm = (
'%s -target %s %s'
% (config.sil_nm, config.variant_triple, mcp_opt))

rth_flags = ''
if swift_execution_tests_extra_flags:
rth_flags = swift_execution_tests_extra_flags + ' -wmo'

config.target_resilience_test = (
'%s --target-build-swift "%s" --target-run "%s" --t %%t --S %%S --s %%s '
'--lib-prefix "%s" --lib-suffix ".%s" --target-codesign "%s"'
'--lib-prefix "%s" --lib-suffix ".%s" --target-codesign "%s" '
'--additional-compile-flags "%s"'
% (config.rth, config.target_build_swift, config.target_run, 'lib',
config.target_dylib_extension, config.target_codesign))
config.target_dylib_extension, config.target_codesign,
rth_flags))

# FIXME: Get symbol diffing working with binutils nm as well. The flags are slightly
# different.
Expand Down
16 changes: 9 additions & 7 deletions utils/rth
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ResilienceTest(object):

def __init__(self, target_build_swift, target_run, target_codesign,
target_nm, tmp_dir, test_dir, test_src, lib_prefix,
lib_suffix, additional_compile_flags_library,
lib_suffix, additional_compile_flags,
no_backward_deployment, no_symbol_diff):
self.target_build_swift = shlex.split(target_build_swift)
self.target_run = shlex.split(target_run)
Expand All @@ -44,8 +44,7 @@ class ResilienceTest(object):
self.test_src = test_src
self.lib_prefix = lib_prefix
self.lib_suffix = lib_suffix
self.additional_compile_flags_library = \
shlex.split(additional_compile_flags_library)
self.additional_compile_flags = shlex.split(additional_compile_flags)

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

command = self.target_build_swift + \
self.additional_compile_flags_library + compiler_flags
self.additional_compile_flags + \
compiler_flags
verbose_print_command(command)
returncode = subprocess.call(command)
assert returncode == 0, str(command)
Expand Down Expand Up @@ -143,7 +143,9 @@ class ResilienceTest(object):
'-Xfrontend', '-enable-class-resilience',
'-I', self.config_dir_map[config],
'-o', output_obj]
command = self.target_build_swift + compiler_flags
command = self.target_build_swift + \
self.additional_compile_flags + \
compiler_flags
verbose_print_command(command)
returncode = subprocess.call(command)
assert returncode == 0, str(command)
Expand Down Expand Up @@ -218,7 +220,7 @@ def main():
parser.add_argument('--s', required=True)
parser.add_argument('--lib-prefix', required=True)
parser.add_argument('--lib-suffix', required=True)
parser.add_argument('--additional-compile-flags-library', default='')
parser.add_argument('--additional-compile-flags', default='')
parser.add_argument('--no-backward-deployment', default=False,
action='store_true')
parser.add_argument('--no-symbol-diff', default=False,
Expand All @@ -230,7 +232,7 @@ def main():
args.target_codesign, args.target_nm,
args.t, args.S, args.s, args.lib_prefix,
args.lib_suffix,
args.additional_compile_flags_library,
args.additional_compile_flags,
args.no_backward_deployment,
args.no_symbol_diff)

Expand Down
26 changes: 26 additions & 0 deletions validation-test/Evolution/Inputs/class_add_convenience_init.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
open class AddConvenienceInit {
public let age: Int

public init(x: Int) {
self.age = x
}

#if BEFORE

public convenience init(z: Int) {
self.init(x: z * z + 2)
}

#else

public convenience init(z: Int) {
self.init(y: z * z)
}

public convenience init(y: Int) {
self.init(x: y + 2)
}

#endif

}
25 changes: 25 additions & 0 deletions validation-test/Evolution/Inputs/class_add_deinit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public var count = 0

public func getVersion() -> Int {
#if BEFORE
return 0
#else
return 1
#endif
}

open class Base {
public init() {}

#if AFTER
deinit {
count += 1
}
#endif
}

open class Derived : Base {
deinit {
count += 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public var count = 0

public func getVersion() -> Int {
#if BEFORE
return 0
#else
return 1
#endif
}

public class MathClass {
public init() {}
}

public class Attributed {
public init(x: MathClass, y: MathClass) {
self.x = x
self.y = y
}

#if BEFORE
public var x: MathClass?
public var y: MathClass
#else
public weak var x: MathClass?
public unowned var y: MathClass
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#if BEFORE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are backwards, no? BEFORE should be the lazy one. (I mean, we're testing in both directions, but the names should match the code.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


public class ChangeLazyToComputed {
private var celsius: Int

public init(celsius: Int) {
self.celsius = celsius
}

public lazy var fahrenheit: Int = (celsius * 9) / 5 + 32
}

#else

public class ChangeLazyToComputed {
private var celsius: Int

public init(celsius: Int) {
self.celsius = celsius
}

public var fahrenheit: Int {
get {
return (celsius * 9) / 5 + 32
}
set {
celsius = ((newValue - 32) * 5) / 9
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#if BEFORE

public func getVersion() -> Int {
return 0
}

public class ChangeStoredToObserved {
public var friends: [String] = []
public var count: Int = 0

public var friend: String = "cat"

public init() {}
}

#else

public func getVersion() -> Int {
return 1

}

public class ChangeStoredToObserved {
public var friends: [String] = []
public var count: Int = 0

public var friend: String = "cat" {
willSet {
friends.append(friend)
}
didSet {
count += 1
}
}

public init() {}
}

#endif
25 changes: 25 additions & 0 deletions validation-test/Evolution/Inputs/move_method_to_extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public struct Rain {
public init() {}

#if BEFORE
public func doIt() {}
#endif
}

public class Snow {
public init() {}

#if BEFORE
public final func doIt() {}
#endif
}

#if AFTER
extension Rain {
public func doIt() {}
}

extension Snow {
public func doIt() {}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public var count = 0

public func getVersion() -> Int {
#if BEFORE
return 0
#else
return 1
#endif
}

public class MathClass {
public init() {}
}

public struct Attributed {
public init(x: MathClass, y: MathClass) {
self.x = x
self.y = y
}

#if BEFORE
public var x: MathClass?
public var y: MathClass
#else
public weak var x: MathClass?
public unowned var y: MathClass
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#if BEFORE

public struct ChangeLazyToComputed {
private var celsius: Int

public init(celsius: Int) {
self.celsius = celsius
}

public lazy var fahrenheit: Int = (celsius * 9) / 5 + 32
}

#else

public struct ChangeLazyToComputed {
private var celsius: Int

public init(celsius: Int) {
self.celsius = celsius
}

public var fahrenheit: Int {
mutating get {
return (celsius * 9) / 5 + 32
}
set {
celsius = ((newValue - 32) * 5) / 9
}
}
}

#endif
Loading