From f6a2ff731b8d7288542d8dff93937c68d721edd1 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 30 Aug 2016 11:26:23 +0200 Subject: [PATCH] fixes #4672 --- compiler/sigmatch.nim | 2 +- tests/generics/ttypeclass_to_typeclass.nim | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/generics/ttypeclass_to_typeclass.nim diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 7cdaa197d2..1abfaab693 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1075,7 +1075,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = of tyBuiltInTypeClass: considerPreviousT: let targetKind = f.sons[0].kind - if targetKind == a.skipTypes({tyRange, tyGenericInst}).kind or + if targetKind == a.skipTypes({tyRange, tyGenericInst, tyBuiltInTypeClass}).kind or (targetKind in {tyProc, tyPointer} and a.kind == tyNil): put(c, f, a) return isGeneric diff --git a/tests/generics/ttypeclass_to_typeclass.nim b/tests/generics/ttypeclass_to_typeclass.nim new file mode 100644 index 0000000000..a5f010450f --- /dev/null +++ b/tests/generics/ttypeclass_to_typeclass.nim @@ -0,0 +1,12 @@ +# bug #4672 +type + EnumContainer[T: enum] = object + v: T + SomeEnum {.pure.} = enum + A,B,C + +proc value[T: enum](this: EnumContainer[T]): T = + this.v + +var enumContainer: EnumContainer[SomeEnum] +discard enumContainer.value()