From f8cc28c958e0d1d9701381448c05b6e79dfe4e99 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 7 Jul 2020 13:25:47 -0700 Subject: Add a test case for dynamic dispatch with `This` type in interface decl. (#1431) * Add a test case for dynamic dispatch with `This` type in interface decl. * Update comments * fix typo in comments Co-authored-by: Tim Foley --- source/slang/slang-lower-to-ir.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index a744d9f38..d14fbfed5 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1629,20 +1629,13 @@ struct ValLoweringVisitor : ValVisitor`. - // - // The generic option has the benefit of having a clear solution in the case of - // static members that don't have a `this` parameter, but might still need `This`, - // but we have so far favored the "object-oriented" lowering for code involving - // bare interface types. - // - // For now we punt and emit the `ThisType` of an interface `IFoo` as `IFoo`. + // A `This` type in an interface decl should lower to `IRThisType`, + // while `This` type in a concrete `struct` should lower to the `struct` type + // itself. A `This` type reference in a concrete type is already translated to that + // type in semantics checking in this setting. + // If we see `This` type here, we are dealing with `This` inside an interface decl. + // Therefore, `context->thisType` should have been set to `IRThisType` + // in `visitInterfaceDecl`, and we can just use that value here. // if (context->thisType != nullptr) return LoweredValInfo::simple(context->thisType); -- cgit v1.2.3