Generic Subscripting


#1

Hello, swift-dev!

I started diving into the Swift code base in December to see if I could wire together generic subscripts (https://bugs.swift.org/browse/SR-115), but I didn't have the time or know-how to get very far. I jumped back in again this past week and some of my earlier work was made obsolete by Chris's DeclContext plumbing at the end of last year :slight_smile:

Michael Ilseman (cc'd) also started working on this but I don't think he had time to get much farther.

Last weekend I rebased, updated my code, and pushed a branch that seems to satisfy the general lexer:

https://github.com/apple/swift/compare/master...stephencelis:generic-subscripts

I am, however, having a bit of trouble finding my way around the type checker and constraint generator. Trying to compile a simple example fails with this assertion: https://gist.github.com/stephencelis/10f9210a5409ee9bd79b

I know that I need to handle the generic type earlier, but I'm not sure where and I'm not sure where function decls are similarly handled.

I might be biting off more than I can chew, and it's possible that I should dive into some smaller, starter issues to get my feet wet to more gradually understand the code base. If you have the time, though, I'd be grateful for a little push in the right direction!

Stephen


(Michael Ilseman) #2

Hello, swift-dev!

I started diving into the Swift code base in December to see if I could wire together generic subscripts (https://bugs.swift.org/browse/SR-115), but I didn't have the time or know-how to get very far. I jumped back in again this past week and some of my earlier work was made obsolete by Chris's DeclContext plumbing at the end of last year :slight_smile:

Michael Ilseman (cc'd) also started working on this but I don't think he had time to get much farther.

You seem to be caught up to where I left off. Unfortunately, I don’t think I’ll be able to come back around to this anytime soon.

···

On Mar 2, 2016, at 6:17 PM, Stephen Celis <stephen.celis@gmail.com> wrote:

Last weekend I rebased, updated my code, and pushed a branch that seems to satisfy the general lexer:

https://github.com/apple/swift/compare/master...stephencelis:generic-subscripts

I am, however, having a bit of trouble finding my way around the type checker and constraint generator. Trying to compile a simple example fails with this assertion: https://gist.github.com/stephencelis/10f9210a5409ee9bd79b

I know that I need to handle the generic type earlier, but I'm not sure where and I'm not sure where function decls are similarly handled.

I might be biting off more than I can chew, and it's possible that I should dive into some smaller, starter issues to get my feet wet to more gradually understand the code base. If you have the time, though, I'd be grateful for a little push in the right direction!

Stephen


(Douglas Gregor) #3

You need to make sure that ConstraintSystem::getTypeOfMemberReference “opens” the generic type of the subscript. The easiest way might be to make sure that the interface type of a generic subscript operator is a GenericFunctionType.

  - Doug

···

On Mar 2, 2016, at 6:17 PM, Stephen Celis <stephen.celis@gmail.com> wrote:

Hello, swift-dev!

I started diving into the Swift code base in December to see if I could wire together generic subscripts (https://bugs.swift.org/browse/SR-115), but I didn't have the time or know-how to get very far. I jumped back in again this past week and some of my earlier work was made obsolete by Chris's DeclContext plumbing at the end of last year :slight_smile:

Michael Ilseman (cc'd) also started working on this but I don't think he had time to get much farther.

Last weekend I rebased, updated my code, and pushed a branch that seems to satisfy the general lexer:

https://github.com/apple/swift/compare/master...stephencelis:generic-subscripts

I am, however, having a bit of trouble finding my way around the type checker and constraint generator. Trying to compile a simple example fails with this assertion: https://gist.github.com/stephencelis/10f9210a5409ee9bd79b