Browse Source

Fix issue #146 regarding polymorphic type parameters

gingerBill 7 years ago
parent
commit
0c06a8d154
2 changed files with 9 additions and 1 deletions
  1. 3 1
      src/check_expr.cpp
  2. 6 0
      src/types.cpp

+ 3 - 1
src/check_expr.cpp

@@ -767,7 +767,9 @@ bool is_polymorphic_type_assignable(Checker *c, Type *poly, Type *source, bool c
 		if (check_type_specialization_to(c, poly, source, compound, modify_type)) {
 		if (check_type_specialization_to(c, poly, source, compound, modify_type)) {
 			return true;
 			return true;
 		}
 		}
-		if (compound) return are_types_identical(poly, source);
+		if (compound || !is_type_generic(poly)) {
+			return are_types_identical(poly, source);
+		}
 		return check_is_assignable_to(c, &o, poly);
 		return check_is_assignable_to(c, &o, poly);
 	}
 	}
 
 

+ 6 - 0
src/types.cpp

@@ -836,6 +836,12 @@ Type *base_array_type(Type *t) {
 	return t;
 	return t;
 }
 }
 
 
+bool is_type_generic(Type *t) {
+	t = base_type(t);
+	return t->kind == Type_Generic;
+}
+
+
 Type *core_array_or_vector_type(Type *t) {
 Type *core_array_or_vector_type(Type *t) {
 	for (;;) {
 	for (;;) {
 		Type *prev = t;
 		Type *prev = t;