-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add a couple of regression tests #79910
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
slavapestov
merged 1 commit into
swiftlang:main
from
slavapestov:test-cases-from-failed-attempts
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
// REQUIRES: objc_interop | ||
|
||
import Foundation | ||
import CoreGraphics | ||
|
||
///////////// | ||
|
||
struct G<T> { // expected-note {{arguments to generic parameter 'T' ('CGFloat?' and 'CGFloat') are expected to be equal}} | ||
var t: T | ||
} | ||
|
||
func foo1(x: (x: Int, y: Int)?, y: (Int, Int)) -> G<(x: Int, y: Int)> { | ||
let g = G(t: x ?? y) | ||
return g | ||
} | ||
|
||
func foo2(x: (Int, Int)?, y: (x: Int, y: Int)) -> G<(Int, Int)> { | ||
let g = G(t: x ?? y) | ||
return g | ||
} | ||
|
||
func foo3(x: (@convention(block) () -> ())?, y: @escaping () -> ()) -> G<@convention(block) () -> ()> { | ||
let g = G(t: x ?? y) | ||
return g | ||
} | ||
|
||
func foo4(x: (() -> ())?, y: @escaping @convention(block) () -> ()) -> G<() -> ()> { | ||
let g = G(t: x ?? y) | ||
return g | ||
} | ||
|
||
func foo5(x: CGFloat?, y: Double) -> G<CGFloat> { | ||
let g = G(t: x ?? y) | ||
// FIXME | ||
return g // expected-error {{cannot convert return expression of type 'G<CGFloat?>' to return type 'G<CGFloat>'}} | ||
} | ||
|
||
func foo6(x: Double?, y: CGFloat) -> G<Double> { | ||
let g = G(t: x ?? y) | ||
return g | ||
} | ||
|
||
///////////// | ||
|
||
func id<T>(_: T) -> T {} | ||
|
||
func bar1(x: (x: Int, y: Int)) { | ||
func f(_: (Int, Int)) {} | ||
f(id(x)) | ||
} | ||
|
||
func bar2(x: (Int, Int)) { | ||
func f(_: (x: Int, y: Int)) {} | ||
f(id(x)) | ||
} | ||
|
||
func bar3(x: @escaping () -> ()) { | ||
func f(_: @escaping @convention(block) () -> ()) {} | ||
// FIXME | ||
f(id(x)) // expected-error {{conflicting arguments to generic parameter 'T' ('@convention(block) () -> ()' vs. '() -> ()')}} | ||
} | ||
|
||
func bar4(x: @escaping @convention(block) () -> ()) { | ||
func f(_: @escaping () -> ()) {} | ||
// FIXME | ||
f(id(x)) // expected-error {{conflicting arguments to generic parameter 'T' ('() -> ()' vs. '@convention(block) () -> ()')}} | ||
} | ||
|
||
func bar5(x: Double) { | ||
func f(_: CGFloat) {} | ||
f(id(x)) | ||
} | ||
|
||
func bar6(x: CGFloat) { | ||
func f(_: Double) {} | ||
f(id(x)) | ||
} | ||
|
||
///////////// | ||
|
||
func unwrap<T>(_: T?) -> T {} | ||
|
||
func baz1(x: (x: Int, y: Int)?) { | ||
func f(_: (Int, Int)) {} | ||
f(unwrap(x)) | ||
} | ||
|
||
func baz2(x: (Int, Int)?) { | ||
func f(_: (x: Int, y: Int)) {} | ||
f(unwrap(x)) | ||
} | ||
|
||
func baz3(x: (() -> ())?) { | ||
func f(_: @escaping @convention(block) () -> ()) {} | ||
f(unwrap(x)) | ||
} | ||
|
||
func baz4(x: (@convention(block) () -> ())?) { | ||
func f(_: @escaping () -> ()) {} | ||
f(unwrap(x)) | ||
} | ||
|
||
func baz5(x: Double?) { | ||
func f(_: CGFloat) {} | ||
f(unwrap(x)) | ||
} | ||
|
||
func baz6(x: CGFloat?) { | ||
func f(_: Double) {} | ||
f(unwrap(x)) | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
validation-test/Sema/type_checker_perf/fast/swift_docc.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=2000 | ||
|
||
// We don't use anything from Foundation below, but Foundation adds a | ||
// large number of == overloads. Import it if we can, because it makes | ||
// the problem instance harder. | ||
#if canImport(Foundation) | ||
import Foundation | ||
#endif | ||
|
||
struct Graph { | ||
func nodeWithReference(_: Int) -> Node? { fatalError() } | ||
} | ||
|
||
struct DocumentationContext { | ||
func parents(of: Int) -> [Int] { fatalError() } | ||
var topicGraph: Graph | ||
} | ||
|
||
struct Node { | ||
var reference: Int | ||
var kind: Kind | ||
|
||
enum Kind { | ||
case tutorialTableOfContents | ||
case chapter | ||
case volume | ||
} | ||
} | ||
|
||
func analyze(_ node: Node, context: DocumentationContext) { | ||
_ = context.parents(of: node.reference) | ||
.compactMap({ context.topicGraph.nodeWithReference($0) }) | ||
.first(where: { $0.kind == .tutorialTableOfContents || $0.kind == .chapter || $0.kind == .volume }) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the specific case that regressed with the deep equality change, but if you look at the rest of the file you'll see the general behavior with this sort of thing is quite inconsistent...