Skip to content

Commit

Permalink
Generics details 6: remove facets (#950)
Browse files Browse the repository at this point in the history
There were some concerns about facet types leaking out of generic code in return types. Some initial fixes for this were done in [PR #900](#900), but there remain concerns, for example when associated types are involved.

In particular, given an interface method with return type using an associated type, as in:

```
interface Deref {
  let Result:! Type;
  fn DoDeref[me: Self]() -> Result;
}

class IntHandle {
  impl as Deref {
    let Result:! Type = i32;
    fn DoDeref[me: Self]() -> Result { ... }
  }
}
```

Since `Result` has type `Type`, we had the problem that `IntHandle.DoDeref` would have to return `i32 as Type`, instead of the desired `i32`.

We also think we can simplify the model by eliminating the facet type concept and syntax.

This proposal removes facet types, introduces archetypes in their place, clarifies how associated types work outside of a generic function, and specifies how a generic `let` statement in a function body works.

Co-authored-by: Wolff Dobson <[email protected]>
Co-authored-by: Richard Smith <[email protected]>
  • Loading branch information
3 people authored Jan 6, 2022
1 parent 1534970 commit b333f48
Show file tree
Hide file tree
Showing 5 changed files with 516 additions and 344 deletions.
Loading

0 comments on commit b333f48

Please sign in to comment.