Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Oct 26, 2024
1 parent 0cf7da6 commit 5e2b620
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Draco.Compiler.Tests/Semantics/SymbolResolutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public void FuncOverloadsGlobalVar()
var semanticModel = compilation.GetSemanticModel(tree);
var diagnostics = semanticModel.Diagnostics;

var varSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(varDecl));
var varSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(varDecl));
var funcSym = GetInternalSymbol<FunctionSymbol>(semanticModel.GetDeclaredSymbol(funcDecl));

// Assert
Expand Down Expand Up @@ -465,8 +465,8 @@ public void GlobalVariableDefinedLater()
var compilation = CreateCompilation(tree);
var semanticModel = compilation.GetSemanticModel(tree);

var varRefSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetReferencedSymbol(localVarDecl.Value!.Value));
var varDeclSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(globalVarDecl));
var varRefSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetReferencedSymbol(localVarDecl.Value!.Value));
var varDeclSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(globalVarDecl));

// Assert
Assert.True(ReferenceEquals(varDeclSym, varRefSym));
Expand Down Expand Up @@ -570,7 +570,7 @@ public void GlobalCanNotReferenceGlobal()
var compilation = CreateCompilation(tree);
var semanticModel = compilation.GetSemanticModel(tree);

var xDeclSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xDeclSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xRefSym = semanticModel.GetReferencedSymbol(xRef);

// TODO: Should see it, but should report illegal reference error
Expand Down
10 changes: 5 additions & 5 deletions src/Draco.Compiler.Tests/Semantics/TypeCheckingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void GlobalVariableExplicitlyTyped()
var compilation = CreateCompilation(tree);
var semanticModel = compilation.GetSemanticModel(tree);

var xSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(xDecl));

// Assert
Assert.Empty(semanticModel.Diagnostics);
Expand All @@ -256,7 +256,7 @@ public void GlobalVariableTypeInferredFromValue()
var compilation = CreateCompilation(tree);
var semanticModel = compilation.GetSemanticModel(tree);

var xSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(xDecl));

// Assert
Assert.Empty(semanticModel.Diagnostics);
Expand All @@ -278,7 +278,7 @@ public void GlobalVariableExplicitlyTypedWithoutValue()
var compilation = CreateCompilation(tree);
var semanticModel = compilation.GetSemanticModel(tree);

var xSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(xDecl));

// Assert
Assert.Empty(semanticModel.Diagnostics);
Expand All @@ -301,7 +301,7 @@ public void GlobalVariableTypeCanNotBeInferred()
var semanticModel = compilation.GetSemanticModel(tree);
var diags = semanticModel.Diagnostics;

var xSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(xDecl));

// Assert
Assert.Single(diags);
Expand All @@ -328,7 +328,7 @@ public void GlobalVariableIncompatibleType()
var semanticModel = compilation.GetSemanticModel(tree);
var diags = semanticModel.Diagnostics;

var xSym = GetInternalSymbol<FieldSymbol>(semanticModel.GetDeclaredSymbol(xDecl));
var xSym = GetInternalSymbol<PropertySymbol>(semanticModel.GetDeclaredSymbol(xDecl));

// Assert
Assert.Single(diags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal sealed class AutoPropertyBackingFieldSymbol(
public override bool IsMutable => this.Property.Setter is not null;
public override string Name => $"<{this.Property.Name}>_BackingField";
public override Api.Semantics.Visibility Visibility => Api.Semantics.Visibility.Private;
public override bool IsSpecialName => true;

/// <summary>
/// The property this backing field is for.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal sealed class AutoPropertyGetterSymbol(
public override string Name => $"{this.Property.Name}_Getter";
public override bool IsStatic => this.Property.IsStatic;
public override Api.Semantics.Visibility Visibility => this.Property.Visibility;
public override bool IsSpecialName => true;

public override ImmutableArray<ParameterSymbol> Parameters => ImmutableArray<ParameterSymbol>.Empty;
public override TypeSymbol ReturnType => this.Property.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal sealed class AutoPropertySetterSymbol(
public override string Name => $"{this.Property.Name}_Setter";
public override bool IsStatic => this.Property.IsStatic;
public override Api.Semantics.Visibility Visibility => this.Property.Visibility;
public override bool IsSpecialName => true;

public override ImmutableArray<ParameterSymbol> Parameters => InterlockedUtils.InitializeDefault(ref this.parameters, this.BuildParameters);
private ImmutableArray<ParameterSymbol> parameters;
Expand Down

0 comments on commit 5e2b620

Please sign in to comment.