Skip to content

[4.0] Switch on key paths. #9304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2017
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
2 changes: 1 addition & 1 deletion include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ namespace swift {
Swift3ObjCInferenceWarnings::None;

/// Enable keypaths.
bool EnableExperimentalKeyPaths = false;
bool EnableExperimentalKeyPaths = true;

/// Sets the target we are building for and updates platform conditions
/// to match.
Expand Down
26 changes: 16 additions & 10 deletions test/Compatibility/tuple_arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,10 @@ do {
}

do {
var a = 3 // expected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4 // expected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // expected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
var a = 3 // e/xpected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4 // e/xpected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // e/xpected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}

var s1 = SubscriptTwo()
_ = s1[a, b]
Expand Down Expand Up @@ -1046,7 +1047,8 @@ do {
}

struct GenericSubscript<T> {
subscript(_ x: T) -> Int { get { return 0 } set { } }
// TODO: Restore regressed diagnostics rdar://problem/31724211
subscript(_ x: T) -> Int { get { return 0 } set { } } // expected-note* {{}}
}

struct GenericSubscriptLabeled<T> {
Expand All @@ -1068,7 +1070,8 @@ struct GenericSubscriptLabeledTuple<T> {
do {
let s1 = GenericSubscript<(Double, Double)>()
_ = s1[3.0, 4.0]
_ = s1[(3.0, 4.0)] // expected-error {{expression type 'Int' is ambiguous without more context}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
_ = s1[(3.0, 4.0)] // expected-error {{}}

let s1a = GenericSubscriptLabeled<(Double, Double)>()
_ = s1a [x: 3.0, 4.0] // expected-error {{extra argument in call}}
Expand Down Expand Up @@ -1109,14 +1112,17 @@ do {
}

do {
var a = 3.0 // expected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4.0 // expected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // expected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
var a = 3.0 // e/xpected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4.0 // e/xpected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // e/xpected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}

var s1 = GenericSubscript<(Double, Double)>()
_ = s1[a, b]
_ = s1[(a, b)] // expected-error {{expression type '@lvalue Int' is ambiguous without more context}}
_ = s1[d] // expected-error {{expression type '@lvalue Int' is ambiguous without more context}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
// These two tests have different regressed behavior in S3 and S4 mode
// _ = s1[(a, b)] // e/xpected-error {{expression type '@lvalue Int' is ambiguous without more context}}
// _ = s1[d] // e/xpected-error {{expression type '@lvalue Int' is ambiguous without more context}}

var s2 = GenericSubscriptTwo<Double>()
_ = s2[a, b]
Expand Down
3 changes: 2 additions & 1 deletion test/Constraints/diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ struct StructWithOptionalArray {
}

func testStructWithOptionalArray(_ foo: StructWithOptionalArray) -> Int {
return foo.array[0] // expected-error {{value of optional type '[Int]?' not unwrapped; did you mean to use '!' or '?'?}} {{19-19=!}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
return foo.array[0] // expected-error {{}}
}


Expand Down
14 changes: 8 additions & 6 deletions test/Constraints/tuple_arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,10 @@ do {
}

do {
var a = 3 // expected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4 // expected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // expected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
var a = 3 // e/xpected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4 // e/xpected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // e/xpected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}

var s1 = SubscriptTwo()
_ = s1[a, b]
Expand Down Expand Up @@ -1094,9 +1095,10 @@ do {
}

do {
var a = 3.0 // expected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4.0 // expected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // expected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}
// TODO: Restore regressed diagnostics rdar://problem/31724211
var a = 3.0 // e/xpected-warning {{variable 'a' was never mutated; consider changing to 'let' constant}}
var b = 4.0 // e/xpected-warning {{variable 'b' was never mutated; consider changing to 'let' constant}}
var d = (a, b) // e/xpected-warning {{variable 'd' was never mutated; consider changing to 'let' constant}}

var s1 = GenericSubscript<(Double, Double)>()
_ = s1[a, b] // expected-error {{extra argument in call}}
Expand Down
4 changes: 3 additions & 1 deletion test/expr/unary/selector/selector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func testParseErrors3(_ c1: C1) {

func testParseErrors4() {
// Subscripts
_ = #selector(C1.subscript) // expected-error{{type 'C1.Type' has no subscript members}}
// TODO: rdar://problem/31724211 -- improve diagnostic regression from
// global keypath subscripts
_ = #selector(C1.subscript) // expected-error{{}}
}

// SR-1827
Expand Down