-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Tiny associated type inference fixes #28157
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 5 commits into
swiftlang:master
from
slavapestov:tiny-assoc-type-fixes
Nov 14, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e35a068
Sema: Add test case for https://bugs.swift.org/browse/SR-11392
slavapestov aa62509
Sema: Remove an unnecessary call to isInvalid()
slavapestov 07d87a1
Sema: Simplify TypeResolver::resolveSILBoxType()
slavapestov 686ddd7
Sema: Tighten up getReferencedAssociatedTypes()
slavapestov 04fbcc0
Sema: Look for generic parameters first when inferring an associated …
slavapestov 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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
test/decl/protocol/req/associated_type_inference_valid.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,56 @@ | ||
// RUN: %target-swift-frontend -emit-silgen %s | ||
|
||
// This is a SILGen test to ensure we can completely check these conformances | ||
// and build valid AST. | ||
|
||
protocol P { | ||
associatedtype T : Q = S | ||
typealias Y = T.X | ||
|
||
func foo(_: T.X) | ||
} | ||
|
||
protocol Q { | ||
associatedtype X | ||
} | ||
|
||
struct S : Q { | ||
typealias X = () | ||
} | ||
|
||
struct R : P { | ||
let x: Y? = nil | ||
func foo(_: Y) {} | ||
} | ||
|
||
// SR-8813 | ||
protocol BaseProtocol { | ||
associatedtype Value | ||
typealias Closure = () -> Value | ||
|
||
init(closure: Closure) | ||
} | ||
|
||
struct Base<Value>: BaseProtocol { | ||
private var closure: Closure? | ||
|
||
init(closure: Closure) { | ||
withoutActuallyEscaping(closure) { new in | ||
self.closure = new | ||
} | ||
} | ||
} | ||
|
||
// SR-11407 | ||
protocol _Drivable: AnyObject { | ||
typealias Driver = Self | ||
} | ||
protocol Configurator { | ||
associatedtype Drivable: _Drivable | ||
typealias Driver = Drivable.Driver | ||
func configure(driver: Driver) | ||
} | ||
struct AnyConfigurator<Drivable: _Drivable>: Configurator { | ||
private let thing: Driver? | ||
func configure(driver: AnyConfigurator.Driver) {} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,28 @@ | ||
// RUN: %target-swift-frontend -verify -emit-ir %s | ||
|
||
// Ideally this would type check successfully; we should be able to | ||
// infer that X == Int using the same-type constraint 'A.X == X'. | ||
|
||
protocol P1 { | ||
associatedtype X | ||
// expected-note@-1 {{protocol requires nested type 'X'; do you want to add it?}} | ||
associatedtype A: P2 where A.X == X | ||
} | ||
|
||
protocol P2 { | ||
associatedtype X | ||
} | ||
|
||
struct S {} | ||
|
||
extension S { | ||
struct A: P2 { | ||
typealias X = Int | ||
} | ||
} | ||
|
||
|
||
extension S: P1 {} | ||
// expected-error@-1 {{type 'S' does not conform to protocol 'P1'}} | ||
|
||
print(S.X.self) |
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 goes away in the next PR.