@@ -389,6 +389,14 @@ export def == (this: &Pattern, other: &Pattern) -> bool {
389389 return false
390390 }
391391 switch this.kind {
392+ case TypeKind::TYPE_DEF
393+ if this.tpe and other.tpe {
394+ return this.tpe == other.tpe
395+ } else if this.name and other.name {
396+ return true
397+ } else {
398+ assert
399+ }
392400 case TypeKind::ARRAY, TypeKind::POINTER, TypeKind::REFERENCE, TypeKind::WEAK_REF
393401 return this.kw == other.kw and this.tpe == other.tpe
394402 case TypeKind::STATIC_ARRAY
@@ -451,7 +459,13 @@ export def generic_to_string(typeref: &TypeRef) -> Str {
451459
452460def generic_to_string(generic: &Pattern) -> Str {
453461 if generic.kind == TypeKind::TYPE_DEF {
454- return "type-def " + generic.name
462+ if generic.tpe {
463+ return "type-def<" + generic_to_string(generic.tpe) + ">"
464+ } else if generic.name {
465+ return "type-def " + generic.name
466+ } else {
467+ return "type-def<?>"
468+ }
455469 } else if generic.kind == TypeKind::REFERENCE {
456470 return "&" + generic_to_string(generic.tpe) // FIXME *let kw
457471 } else if generic.kind == TypeKind::POINTER {
@@ -2341,7 +2355,13 @@ export def convert_type_score(a: &TypeRef, b: &Type, scpe: &scope::Scope, impl:
23412355
23422356export def convert_type_score(a: &Pattern, b: &Type, scpe: &scope::Scope, impl: bool = true) -> int {
23432357 if a.kind == TypeKind::TYPE_DEF {
2344- scope::create_type(scpe, parser::make_identifier(a.name), parser::ShareMarker::NONE, make_type_ref(b.id))
2358+ if a.tpe {
2359+ if convert_type_score(a.tpe, b, scpe, impl) > 0 {
2360+ return 1
2361+ } else { return -1 }
2362+ } else if a.name {
2363+ scope::create_type(scpe, parser::make_identifier(a.name), parser::ShareMarker::NONE, make_type_ref(b.id))
2364+ }
23452365 return 1
23462366 }
23472367
0 commit comments