diff --git a/src/compiler/hxb/hxbReader.ml b/src/compiler/hxb/hxbReader.ml index 31487c15b48..bc2c0c18cd6 100644 --- a/src/compiler/hxb/hxbReader.ml +++ b/src/compiler/hxb/hxbReader.ml @@ -744,6 +744,9 @@ class hxb_reader local_type_parameters.(k).ttp_type | 4 -> t_dynamic + | 5 -> + let path = self#read_path in + (mk_type_param { null_class with cl_path = path } TPHUnbound None None).ttp_type | 10 -> let c = self#read_class_ref in c.cl_type diff --git a/src/compiler/hxb/hxbWriter.ml b/src/compiler/hxb/hxbWriter.ml index 621be76a395..68c8c7863fc 100644 --- a/src/compiler/hxb/hxbWriter.ml +++ b/src/compiler/hxb/hxbWriter.ml @@ -1096,6 +1096,8 @@ module HxbWriter = struct writer.wrote_local_type_param <- true; Chunk.write_u8 writer.chunk 3; Chunk.write_uleb128 writer.chunk index; + | TPHUnbound -> + raise Not_found end with Not_found -> (try ignore(IdentityPool.get writer.unbound_ttp ttp) with Not_found -> begin ignore(IdentityPool.add writer.unbound_ttp ttp ()); @@ -1103,7 +1105,9 @@ module HxbWriter = struct let msg = Printf.sprintf "Unbound type parameter %s" (s_type_path ttp.ttp_class.cl_path) in writer.warn WUnboundTypeParameter msg p end); - Chunk.write_u8 writer.chunk 4; (* TDynamic None *) + writer.wrote_local_type_param <- true; + Chunk.write_u8 writer.chunk 5; + write_path writer ttp.ttp_class.cl_path; end (* @@ -1661,6 +1665,7 @@ module HxbWriter = struct | TPHEnumConstructor -> 3 | TPHAnonField -> 4 | TPHLocal -> 5 + | TPHUnbound -> 6 in Chunk.write_u8 writer.chunk i in diff --git a/src/core/tPrinting.ml b/src/core/tPrinting.ml index c868a97ed21..b9083a51e27 100644 --- a/src/core/tPrinting.ml +++ b/src/core/tPrinting.ml @@ -461,6 +461,7 @@ module Printer = struct | TPHEnumConstructor -> "TPHEnumConstructor" | TPHAnonField -> "TPHAnonField" | TPHLocal -> "TPHLocal" + | TPHUnbound -> "TPHUnbound" let s_type_param tabs ttp = s_record_fields tabs [ diff --git a/src/core/tType.ml b/src/core/tType.ml index eaef3eeca82..28723f09615 100644 --- a/src/core/tType.ml +++ b/src/core/tType.ml @@ -54,6 +54,7 @@ type type_param_host = | TPHEnumConstructor | TPHAnonField | TPHLocal + | TPHUnbound type cache_bound_object = | Resource of string * string diff --git a/src/typing/typeload.ml b/src/typing/typeload.ml index 642de0acbb0..1d1f3bc8da6 100644 --- a/src/typing/typeload.ml +++ b/src/typing/typeload.ml @@ -761,7 +761,8 @@ and type_type_params ctx host path p tpl = | TPHMethod | TPHEnumConstructor | TPHAnonField - | TPHLocal -> + | TPHLocal + | TPHUnbound -> display_error ctx.com "Default type parameters are only supported on types" (pos ct) end; check_param_constraints ctx t (fun t -> t) ttp (pos ct);