diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceThisParameterSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceThisParameterSymbol.cs
index b2494a41f..24797b47b 100644
--- a/src/Draco.Compiler/Internal/Symbols/Source/SourceThisParameterSymbol.cs
+++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceThisParameterSymbol.cs
@@ -1,19 +1,36 @@
+using System;
using System.Collections.Immutable;
+using System.Linq;
using Draco.Compiler.Api.Syntax;
using Draco.Compiler.Internal.Binding;
namespace Draco.Compiler.Internal.Symbols.Source;
-internal sealed class SourceThisParameterSymbol(FunctionSymbol containingSymbol, ThisParameterSyntax syntax) : ParameterSymbol, ISourceSymbol
+///
+/// The 'this' parameter of a function defined in-source.
+///
+internal sealed class SourceThisParameterSymbol : ParameterSymbol, ISourceSymbol
{
public override string Name => "this";
- public override FunctionSymbol ContainingSymbol { get; } = containingSymbol;
+ public override FunctionSymbol ContainingSymbol { get; }
public override bool IsVariadic => false;
public override bool IsThis => true;
- public override ThisParameterSyntax DeclaringSyntax { get; } = syntax;
+ public override ThisParameterSyntax DeclaringSyntax { get; }
public override ImmutableArray Attributes => [];
- public override TypeSymbol Type { get; } = (containingSymbol.ContainingSymbol as TypeSymbol)!;
+ public override TypeSymbol Type { get; }
+
+ public SourceThisParameterSymbol(FunctionSymbol containingSymbol, ThisParameterSyntax syntax)
+ {
+ var containingType = containingSymbol.ContainingSymbol?.AncestorChain
+ .OfType()
+ .FirstOrDefault()
+ ?? throw new ArgumentException("the containing symbol of a source this parameter must be a function within a type");
+
+ this.ContainingSymbol = containingSymbol;
+ this.DeclaringSyntax = syntax;
+ this.Type = containingType;
+ }
public void Bind(IBinderProvider binderProvider) { }
}