diff --git a/compiler/types.nim b/compiler/types.nim index a6694ab26a..bc6de5098b 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1201,17 +1201,19 @@ proc sameChildrenAux(a, b: PType, c: var TSameTypeClosure): bool = if not result: return proc isGenericAlias*(t: PType): bool = - return t.kind == tyGenericInst and t.skipModifier.kind == tyGenericInst + return t.kind == tyGenericInst and t.skipModifier.skipTypes({tyAlias}).kind == tyGenericInst proc genericAliasDepth*(t: PType): int = result = 0 - var it = t + var it = t.skipTypes({tyAlias}) while it.isGenericAlias: - it = it.skipModifier + it = it.skipModifier.skipTypes({tyAlias}) inc result proc skipGenericAlias*(t: PType): PType = - return if t.isGenericAlias: t.skipModifier else: t + result = t.skipTypes({tyAlias}) + if result.isGenericAlias: + result = result.skipModifier.skipTypes({tyAlias}) proc sameFlags*(a, b: PType): bool {.inline.} = result = eqTypeFlags*a.flags == eqTypeFlags*b.flags diff --git a/tests/overload/tgenericalias.nim b/tests/overload/tgenericalias.nim index 50a44bd324..cb3e8985db 100644 --- a/tests/overload/tgenericalias.nim +++ b/tests/overload/tgenericalias.nim @@ -11,3 +11,12 @@ block: # issue #13799 proc works2(): Y[int] = t(X[int, int]) proc works3(): Y[int] = t(Y[int]) proc broken(): Y[int] = s(Y[int]) + +block: # issue #24415 + type GVec2[T] = object + x, y: T + type Uniform[T] = T + proc foo(v: Uniform[GVec2[float32]]): float32 = + result = v.x + let f = GVec2[float32](x: 1.0f, y: 2.0f) + doAssert foo(f) == 1.0f