You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/024-any-dyn-types.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@ By default, a `dyn` interface is subject to the following restrictions, unless l
41
41
1. It must not define any generic methods.
42
42
1. It must not define any mutating methods.
43
43
1. It cannot contain any methods that has a `some IFoo` return type, or has any `some IFoo` parameters.
44
+
1. A `dyn` interface cannot inherit from any interfaces that are not `dyn`.
44
45
1. A `dyn` interface cannot inherit from `IDifferentiable`, and cannot contain any function requirements that are marked as `[Differentiable]`.
45
46
46
47
Any type that conforms to one or more `dyn` interface is subject to these restrictions:
@@ -56,12 +57,12 @@ In addition, such types are subject to these restrictions unless language versio
56
57
57
58
If a variable, a parameter or a struct field is declared to have an interface type or array of interface type, the var decl must be qualified with either the `some` keyword or the `dyn` keyword. If the var decl is not explicitly qualified with `some` or `dyn`, the compiler implicitly qualifieds the type as `some` when language version is 2026 or later, or as `dyn` in language version 2025.
58
59
59
-
The concrete type of a `some` qualified var decl must be compile-time deducible and will never involve in dynamic dispatch. The concrete type of a `dyn` qualified var decl may not be compile-time deducible and may involve in dynamic dispatch.
60
+
The concrete type of a `some` qualified var decl must be compile-time deducible to a proper type and will never involve in dynamic dispatch. The concrete type of a `dyn` qualified var decl might not be compile-time deducible and might involve in dynamic dispatch.
60
61
61
62
The following rules apply to `some` and `dyn` qualifiers on var decls:
62
63
63
64
1. A `some IFoo` type is valid only if `IFoo` is an interface type.
64
-
1. A `some IFoo` type can only be used on a function parameter or a local variable. Struct fields or global variables cannot have a `some` type.
65
+
1. A `some IFoo` type can only be used on a function parameter, a function return value or a local variable. Struct fields or global variables cannot have a `some` type.
65
66
1. A `some IFoo` type cannot appear in any complex type expression. For example, `some IFoo*`, `some IFoo[2]`, `Tuple<some IFoo, some IFoo>` etc. are not allowed.
66
67
1. A local variable of `some IFoo` type cannot be assigned or initialized more than once throughout its lifetime.
67
68
1. If a function returns `some IFoo`, then all return statements must return values of exactly the same type.
0 commit comments