Files
swift-mirror/test/ParseableInterface/default-args.swift
Nathan Hawes d4f1894347 Simplify diagnostics for inherited default argument values in module interfaces
Also:
- additionally require the containing and overridden initializers are
  designated, as that's the only case in which we should produce the '= super'
  syntax in module interfaces
- Add notes to point out the locations of the overriden initializer when it's
  not designated, and the corresponding parameter in that initializer when it
  doesn't have a default argument to inherit.
2019-04-18 11:03:34 -07:00

57 lines
1.9 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o %t/Test~partial.swiftmodule -module-name Test -primary-file %s
// RUN: %target-swift-frontend -merge-modules -emit-module -o %t/Test.swiftmodule %t/Test~partial.swiftmodule
// RUN: %target-swift-ide-test -print-module -module-to-print=Test -source-filename=x -I %t | %FileCheck %s
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t/Test.swiftinterface -enable-library-evolution %s
// RUN: rm %t/Test.swiftmodule
// RUN: echo "import Test" > %t/test-client.swift
// RUN: %target-swift-frontend -typecheck -I%t %t/test-client.swift
// RUN: %FileCheck %s < %t/Test.swiftinterface
// CHECK: class Base {
public class Base {
// CHECK: init(x: Int = 3)
public init(x: Int = 3) {}
public convenience init(convInit: Int) {
self.init(x: convInit)
}
// CHECK: foo(y: Int = 42)
public func foo(y: Int = 42) {}
}
// CHECK: class Derived : Base {
public class Derived: Base {
// CHECK: init(y: Int)
public convenience init(y: Int) {
self.init()
}
// CHECK-NOT: init(convInit: Int = super)
// CHECK: override {{(public )?}}init(x: Int = super)
// CHECK-NOT: init(convInit: Int = super)
}
public enum Enum {
// CHECK: case pie(filling: String = "apple")
case pie(filling: String = "apple")
}
public struct HasSubscript {
// CHECK: subscript(x: Int = 0) -> Int {
public subscript(x: Int = 0) -> Int { return 0 }
}
// CHECK: func hasClosureDefaultArg(_ x: () -> Void = {
// CHECK-NEXT: })
public func hasClosureDefaultArg(_ x: () -> Void = {
}) {
}
// CHECK: func hasMagicDefaultArgs(_ f: String = #file, _ fu: String = #function, _ l: Int = #line)
public func hasMagicDefaultArgs(_ f: String = #file, _ fu: String = #function, _ l: Int = #line) {}
// CHECK: func hasSimpleDefaultArgs(_ x: Int = 0, b: Int = 1)
public func hasSimpleDefaultArgs(_ x: Int = 0, b: Int = 1) {
}