[Runtime] Handle non-key arguments when substituting from metadata.

Reimplement SubstGenericParametersFromMetadata to cope with non-key
generic parameters, which are counted when referring to generic parameters
from metadata but do not have corresponding generic arguments.
This commit is contained in:
Doug Gregor
2018-09-22 23:23:45 -07:00
parent 5a87435b8e
commit 3ea48770fe
3 changed files with 167 additions and 28 deletions

View File

@@ -1795,4 +1795,41 @@ mirrors.test("SymbolicReferenceInsideType") {
expectEqual(expected, output)
}
protocol P1 { }
protocol P2 { }
protocol P3 { }
struct ConformsToP1: P1 { }
struct ConformsToP2: P2 { }
struct ConformsToP3: P3 { }
struct OuterTwoParams<T: P1, U: P2> {}
struct ConformsToP1AndP2 : P1, P2 { }
extension OuterTwoParams where U == T {
struct InnerEqualParams<V: P3> {
var x: T
var y: U
var z: V
}
}
mirrors.test("GenericNestedWithSameTypeConstraints") {
let value = OuterTwoParams.InnerEqualParams(x: ConformsToP1AndP2(),
y: ConformsToP1AndP2(),
z: ConformsToP3())
var output = ""
dump(value, to: &output)
// FIXME: The generic arguments are in the wrong place
let expected =
"▿ (extension in Mirror):Mirror.OuterTwoParams.InnerEqualParams<Mirror.ConformsToP1AndP2, Mirror.ConformsToP3>\n" +
" - x: Mirror.ConformsToP1AndP2\n" +
" - y: Mirror.ConformsToP1AndP2\n" +
" - z: Mirror.ConformsToP3\n"
expectEqual(expected, output)
}
runAllTests()