Skip to content

Commit dbbb9da

Browse files
committed
[flash] add flash.AnyType (closes #8549)
1 parent f380e24 commit dbbb9da

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/generators/genswf9.ml

+6
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ let rec type_id ctx t =
231231
type_path ctx c.cl_path)
232232
| TAbstract ({ a_path = [],"Null"},_) ->
233233
HMPath ([],"Object")
234+
| TAbstract ({ a_path = ["flash"],"AnyType"},_) ->
235+
HMAny
234236
| TAbstract (a,_) when Meta.has Meta.CoreType a.a_meta ->
235237
type_path ctx a.a_path
236238
| TFun _ | TType ({ t_path = ["flash";"utils"],"Function" },[]) ->
@@ -264,6 +266,8 @@ let classify ctx t =
264266
KBool
265267
| TAbstract ({ a_path = [],"Void" },_) | TEnum ({ e_path = [],"Void" },_) ->
266268
KDynamic
269+
| TAbstract ({ a_path = ["flash"],"AnyType" },_) ->
270+
KDynamic
267271
| TEnum ({ e_path = ["flash"],"XmlType"; e_extern = true },_) ->
268272
KType (HMPath ([],"String"))
269273
| TEnum (e,_) ->
@@ -1034,6 +1038,8 @@ let rec gen_type ctx t =
10341038
write ctx (HGetLex t);
10351039
List.iter (gen_type ctx) tl;
10361040
write ctx (HApplyType (List.length tl));
1041+
| HMAny ->
1042+
write ctx (HNull)
10371043
| _ ->
10381044
write ctx (HGetLex t)
10391045

std/flash/AnyType.hx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package flash;
2+
3+
/**
4+
This type represents the Flash `*` type, which is
5+
actually the absense of type. It can be used as a
6+
type parameter for `flash.Vector` to represent the
7+
native `Vector.<*>` type.
8+
**/
9+
@:coreType abstract AnyType from Dynamic to Dynamic {}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package unit.issues;
2+
3+
class Issue8549 extends unit.Test {
4+
#if flash
5+
function test() {
6+
// can be used as a Vector type param, for type checking :-/
7+
var v = new flash.Vector<String>();
8+
var anyVector:Class<flash.Vector<flash.AnyType>> = flash.Vector.typeReference();
9+
t(Std.is(v, anyVector));
10+
11+
// also assignable from/to stuff, similar to Any, just in case...
12+
var v:flash.AnyType = 10;
13+
eq(10, v);
14+
var i:Int = v;
15+
eq(10, i);
16+
}
17+
#end
18+
}

0 commit comments

Comments
 (0)