From f114c377f2cb7458fb8555151752f21d4d824e49 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Sun, 21 Jan 2018 18:03:35 -0800 Subject: A hacky fix for specializing methods from extensions If we don't find the generic we expect in the first pass during IR specialization, then we check for the special case where we are trying to specialize something from a generic extension, using the type being extended. We assume that the generic parameter lists match (that part is the huge hack), and collect the arguments as if they were for the extension instead of the type. This will break when/if we ever have generic extensions with parameter lists that don't match the type being extended. --- source/slang/ir.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/slang/ir.cpp') diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 1d3c91979..b965f908c 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -4510,6 +4510,19 @@ namespace Slang } } + if( !newGenericDecl ) + { + if(auto gd = dynamic_cast(newDecl)) + { + if( auto ed = gd->inner.As() ) + { + // TODO: we should confirm that it is an extension for the correct type... + + newGenericDecl = gd; + } + } + } + SLANG_ASSERT(newGenericDecl); RefPtr newSubst = new GenericSubstitution(); -- cgit v1.2.3