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
| `=` _type_ (The generics parameter has default type)
763
762
764
763
_generics-variance_ ::= (Invariant)
765
764
| `out` (Covariant)
@@ -826,14 +825,27 @@ class PrettyPrint[T < _Output]
826
825
end
827
826
```
828
827
829
-
If a type parameter has an upper bound, the type parameter must be instantiated with types that is a subclass of the upper bound.
828
+
If a type parameter has an upper bound, the type parameter must be instantiated with types that is a subtype of the upper bound.
830
829
831
830
```rbs
832
831
type str_printer = PrettyPrint[String] # OK
833
832
type int_printer = PrettyPrint[Integer] # Type error
834
833
```
835
834
836
-
The upper bound must be one of a class instance type, interface type, or class singleton type.
835
+
The generics type parameter of modules, classes, interfaces, or type aliases can have a default type.
836
+
837
+
```rbs
838
+
interface _Foo[T = untyped]
839
+
end
840
+
841
+
interface _Bar[T, S = untyped]
842
+
end
843
+
844
+
type foo = _Foo # equivalent to _Foo[untyped]
845
+
type bar = _Bar[String] # equivalent to _Bar[String, untyped]
846
+
```
847
+
848
+
Type parameters with default types cannot appear before type parameters without default types. The generic method type parameters cannot have the default types.
0 commit comments