@@ -1062,7 +1062,7 @@ pub enum ComponentDefinedType {
10621062 /// A future type with the specified payload type.
10631063 Future ( Option < ComponentValType > ) ,
10641064 /// A stream type with the specified payload type.
1065- Stream ( ComponentValType ) ,
1065+ Stream ( Option < ComponentValType > ) ,
10661066 /// The error-context type.
10671067 ErrorContext ,
10681068}
@@ -1950,9 +1950,7 @@ impl TypeAlloc {
19501950 }
19511951 }
19521952 }
1953- ComponentDefinedType :: List ( ty)
1954- | ComponentDefinedType :: Option ( ty)
1955- | ComponentDefinedType :: Stream ( ty) => {
1953+ ComponentDefinedType :: List ( ty) | ComponentDefinedType :: Option ( ty) => {
19561954 self . free_variables_valtype ( ty, set) ;
19571955 }
19581956 ComponentDefinedType :: Result { ok, err } => {
@@ -1971,6 +1969,11 @@ impl TypeAlloc {
19711969 self . free_variables_valtype ( ty, set) ;
19721970 }
19731971 }
1972+ ComponentDefinedType :: Stream ( ty) => {
1973+ if let Some ( ty) = ty {
1974+ self . free_variables_valtype ( ty, set) ;
1975+ }
1976+ }
19741977 }
19751978 }
19761979
@@ -2094,9 +2097,9 @@ impl TypeAlloc {
20942097 . map ( |t| self . type_named_valtype ( t, set) )
20952098 . unwrap_or ( true )
20962099 }
2097- ComponentDefinedType :: List ( ty)
2098- | ComponentDefinedType :: Option ( ty)
2099- | ComponentDefinedType :: Stream ( ty ) => self . type_named_valtype ( ty , set ) ,
2100+ ComponentDefinedType :: List ( ty) | ComponentDefinedType :: Option ( ty ) => {
2101+ self . type_named_valtype ( ty, set )
2102+ }
21002103
21012104 // own/borrow themselves don't have to be named, but the resource
21022105 // they refer to must be named.
@@ -2108,6 +2111,11 @@ impl TypeAlloc {
21082111 . as_ref ( )
21092112 . map ( |ty| self . type_named_valtype ( ty, set) )
21102113 . unwrap_or ( true ) ,
2114+
2115+ ComponentDefinedType :: Stream ( ty) => ty
2116+ . as_ref ( )
2117+ . map ( |ty| self . type_named_valtype ( ty, set) )
2118+ . unwrap_or ( true ) ,
21112119 }
21122120 }
21132121
@@ -2277,9 +2285,7 @@ where
22772285 }
22782286 }
22792287 }
2280- ComponentDefinedType :: List ( ty)
2281- | ComponentDefinedType :: Option ( ty)
2282- | ComponentDefinedType :: Stream ( ty) => {
2288+ ComponentDefinedType :: List ( ty) | ComponentDefinedType :: Option ( ty) => {
22832289 any_changed |= self . remap_valtype ( ty, map) ;
22842290 }
22852291 ComponentDefinedType :: Result { ok, err } => {
@@ -2293,7 +2299,7 @@ where
22932299 ComponentDefinedType :: Own ( id) | ComponentDefinedType :: Borrow ( id) => {
22942300 any_changed |= self . remap_resource_id ( id, map) ;
22952301 }
2296- ComponentDefinedType :: Future ( ty) => {
2302+ ComponentDefinedType :: Future ( ty) | ComponentDefinedType :: Stream ( ty ) => {
22972303 if let Some ( ty) = ty {
22982304 any_changed |= self . remap_valtype ( ty, map) ;
22992305 }
@@ -3234,9 +3240,14 @@ impl<'a> SubtypeCx<'a> {
32343240 ( Some ( _) , None ) => bail ! ( offset, "expected future type to not be present" ) ,
32353241 } ,
32363242 ( Future ( _) , b) => bail ! ( offset, "expected {}, found future" , b. desc( ) ) ,
3237- ( Stream ( a) , Stream ( b) ) => self
3238- . component_val_type ( a, b, offset)
3239- . with_context ( || "type mismatch in stream" ) ,
3243+ ( Stream ( a) , Stream ( b) ) => match ( a, b) {
3244+ ( None , None ) => Ok ( ( ) ) ,
3245+ ( Some ( a) , Some ( b) ) => self
3246+ . component_val_type ( a, b, offset)
3247+ . with_context ( || "type mismatch in stream" ) ,
3248+ ( None , Some ( _) ) => bail ! ( offset, "expected stream type, but found none" ) ,
3249+ ( Some ( _) , None ) => bail ! ( offset, "expected stream type to not be present" ) ,
3250+ } ,
32403251 ( Stream ( _) , b) => bail ! ( offset, "expected {}, found stream" , b. desc( ) ) ,
32413252 ( ErrorContext , ErrorContext ) => Ok ( ( ) ) ,
32423253 ( ErrorContext , b) => bail ! ( offset, "expected {}, found error-context" , b. desc( ) ) ,
0 commit comments