forked from apple/swift
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sema: Associated type inference skips witnesses that might trigger a …
…request cycle This implements a structural walk over the TypeRepr to catch situations where we attempt to infer `A` from `func f(_: A)`, which references the concrete `A` that will be synthesized in the conforming type. Fixes: - rdar://34956654 / apple#48680 - rdar://38913692 / apple#49066 - rdar://56672411 - apple#50010 - rdar://81587765 / apple#57355 - rdar://117442510
- Loading branch information
1 parent
b598baf
commit aa909fe
Showing
4 changed files
with
172 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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,44 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
// RUN: %target-swift-frontend -emit-silgen %s -parse-as-library -module-name Test -experimental-lazy-typecheck | ||
|
||
// This file should type check successfully. | ||
|
||
// rdar://117442510 | ||
public protocol P1 { | ||
associatedtype Value | ||
|
||
func makeValue() -> Value | ||
func useProducedValue(_ produceValue: () -> Value) | ||
} | ||
|
||
public struct S1: P1 { | ||
public func makeValue() -> Int { return 1 } | ||
public func useProducedValue(_ produceValue: () -> Value) { | ||
_ = produceValue() | ||
} | ||
} | ||
|
||
// rdar://56672411 | ||
public protocol P2 { | ||
associatedtype X = Int | ||
func foo(_ x: X) | ||
} | ||
|
||
public struct S2: P2 { | ||
public func bar(_ x: X) {} | ||
public func foo(_ x: X) {} | ||
} | ||
|
||
// https://github.com/apple/swift/issues/57355 | ||
public protocol P3 { | ||
associatedtype T | ||
var a: T { get } | ||
var b: T { get } | ||
var c: T { get } | ||
} | ||
|
||
public struct S3: P3 { | ||
public let a: Int | ||
public let b: T | ||
public let c: T | ||
} |
This file contains 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 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