Explorar o código

abstract should be either @:coreType or provide an underlying type (fixed issue #1198)

Nicolas Cannasse %!s(int64=12) %!d(string=hai) anos
pai
achega
1d4fa04e16
Modificáronse 6 ficheiros con 16 adicións e 13 borrados
  1. 1 1
      std/Class.hx
  2. 1 1
      std/Enum.hx
  3. 1 1
      std/EnumValue.hx
  4. 4 4
      std/StdTypes.hx
  5. 2 1
      tests/unit/compile.hxml
  6. 7 5
      typeload.ml

+ 1 - 1
std/Class.hx

@@ -24,5 +24,5 @@
 	
 	See [Type] for the haXe Reflection API.
 **/
-@:runtimeValue abstract Class<T> {
+@:coreType @:runtimeValue abstract Class<T> {
 }

+ 1 - 1
std/Enum.hx

@@ -27,5 +27,5 @@
 	
 	See [Type] for the haXe Reflection API.
 **/
-@:runtimeValue abstract Enum<T> {
+@:coreType @:runtimeValue abstract Enum<T> {
 }

+ 1 - 1
std/EnumValue.hx

@@ -24,5 +24,5 @@
 	An abstract type that represents any enum value.
 	See [Type] for the haXe Reflection API.
 **/
-abstract EnumValue {
+@:coreType abstract EnumValue {
 }

+ 4 - 4
std/StdTypes.hx

@@ -24,12 +24,12 @@
 /**
 	The standard Void type. Only [null] values can be of the type [Void].
 **/
-abstract Void { }
+@:coreType abstract Void { }
 
 /**
 	The standard Float type, this is a double-precision IEEE 64bit float.
 **/
-@:notNull @:runtimeValue abstract Float { }
+@:coreType @:notNull @:runtimeValue abstract Float { }
 
 /**
 	The standard Int type. Its precision depends on the platform.
@@ -59,14 +59,14 @@ typedef Null<T> = T
 /**
 	The standard Boolean type is represented as an enum with two choices.
 **/
-@:notNull @:runtimeValue abstract Bool {
+@:coreType @:notNull @:runtimeValue abstract Bool {
 }
 
 /**
 	Dynamic is an internal compiler type which has special behavior.
 	See the haXe language reference for more informations.
 **/
-@:runtimeValue abstract Dynamic<T> {
+@:coreType @:runtimeValue abstract Dynamic<T> {
 }
 
 /**

+ 2 - 1
tests/unit/compile.hxml

@@ -15,6 +15,7 @@
 
 #each
 --next
+-D macro-times
 -D haxe3
 -debug
 -cp ..
@@ -61,7 +62,7 @@ unit.Test
 --next
 -main unit.Test
 -as3 as3
--cmd mxmlc -static-link-runtime-shared-libraries=true -debug as3/__main__.as --output unit9_as3.swf
+#-cmd mxmlc -static-link-runtime-shared-libraries=true -debug as3/__main__.as --output unit9_as3.swf
 
 #cpp
 --next

+ 7 - 5
typeload.ml

@@ -1894,9 +1894,9 @@ let rec init_module_type ctx context_init do_init (decl,p) =
 			let t = load_complex_type ctx p t in
 			if not (Meta.has Meta.CoreType a.a_meta) then begin
 				if !is_type then begin
-					(try type_eq EqStrict a.a_this t with Unify_error _ -> error "You can only declare from/to with your subtype" p);
+					(try type_eq EqStrict a.a_this t with Unify_error _ -> error "You can only declare from/to with your underlying type" p);
 				end else
-					error "Missing subtype declaration or @:coreType declaration" p;
+					error "Missing underlying type declaration or @:coreType declaration" p;
 			end;
 			t
 		in
@@ -1904,13 +1904,15 @@ let rec init_module_type ctx context_init do_init (decl,p) =
 			| AFromType t -> a.a_from <- (load_type t, None) :: a.a_from
 			| AToType t -> a.a_to <- (load_type t, None) :: a.a_to
 			| AIsType t ->
-				if a.a_impl = None then error "Abstracts with subtypes must have an implementation" a.a_pos;
+				if a.a_impl = None then error "Abstracts with underlying type must have an implementation" a.a_pos;
 				let at = load_complex_type ctx p t in
-				(match at with TAbstract(a2,_) when a == a2 -> error "Abstract subtype cannot be recursive" a.a_pos | _ -> ());
+				(match at with TAbstract(a2,_) when a == a2 -> error "Abstract underlying type cannot be recursive" a.a_pos | _ -> ());
 				a.a_this <- at;
 				is_type := true;
 			| APrivAbstract -> ()
-		) d.d_flags
+		) d.d_flags;
+		if not !is_type && (match a.a_impl with Some _ -> true | None -> not (Meta.has Meta.CoreType a.a_meta)) then
+			error "Abstract is missing underlying type declaration" a.a_pos
 
 let type_module ctx m file tdecls p =
 	let m, decls, tdecls = make_module ctx m file tdecls p in