Skip to content

Commit 7023da2

Browse files
VladD2someone-with-default-username
authored andcommitted
Add owners to TypeParameter-s.
1 parent 2fb8aad commit 7023da2

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

Nitra/DotNetLang/Type/GenericType.nitra

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@ using SCG = System.Collections.Generic;
1111
namespace DotNet
1212
{
1313

14-
abstract declaration GenericEntity : BindableAst
14+
abstract declaration GenericEntity : BindableAst, Container
1515
{
1616
symbol
1717
{
18-
out TypeParametersCount : int = AstUtils.GetTypeParametersCount(this.FirstDeclarationOrDefault);
19-
out TypeParameters : ImmutableArray[TypeSymbol] = AstUtils.CreateTypeParameters(TypeParametersCount);
18+
in TypeParametersCount : int;
19+
in TypeParameters : ImmutableArray[TypeSymbol];
2020
}
2121

2222

2323
// Local scope. Type parameters can have different names. We should use alias to reflect it.
2424
out TypeParameterAliasesScope : TableScope = TableScope("type parameters");
2525

26-
TypeParameterAliases.TypeParameterSymbols = Symbol.TypeParameters;
27-
TypeParameterAliases.IndexIn = 0;
28-
TypeParameterAliases.ContainingTable = TypeParameterAliasesScope;
29-
TypeParameterAliases.Scope = Scope;
30-
TypeParameterConstraints.Scope = Scope.HideWith(TypeParameterAliasesScope);
26+
Symbol.TypeParametersCount = TypeParameterAliases.Count;
27+
Symbol.TypeParameters = AstUtils.CreateTypeParameters(context, Symbol.MemberTable, TypeParameterAliases);
28+
TypeParameterAliases.TypeParameterSymbols = Symbol.TypeParameters;
29+
TypeParameterAliases.IndexIn = 0;
30+
TypeParameterAliases.ContainingTable = TypeParameterAliasesScope;
31+
TypeParameterAliases.Scope = Scope;
32+
TypeParameterConstraints.Scope = Scope.HideWith(TypeParameterAliasesScope);
3133
TypeParameterConstraints.ConstraintedParameters = SCG.HashSet();
32-
TypeParameterAliases.DeclaringMember = Symbol;
34+
TypeParameterAliases.DeclaringMember = Symbol;
3335

3436
TypeParameterAliases : TypeParameterAlias*;
3537
TypeParameterConstraints : TypeParameterConstraintsClause*;

Nitra/DotNetLang/Utils/AstUtils.n

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,23 @@ namespace DotNet
308308

309309
public NoTypeParameters : array[TypeParameterSymbol] = array(0);
310310

311-
public CreateTypeParameters(count : int) : ImmutableArray[TypeSymbol]
311+
public CreateTypeParameters(context : DependentPropertyEvalContext, table : TableScope, aliases : DotNet.TypeParameterAlias.IAstList) : ImmutableArray[TypeSymbol]
312312
{
313+
def count : int = aliases.Count;
313314
if (count == 0)
314315
ImmutableArray.Empty
315316
else
316317
{
317318
def result = ImmutableArray.CreateBuilder(count);
318319
for (mutable i = 0; i < count; ++i)
319-
result.Add(TypeParameterSymbol());
320+
{
321+
def alias = aliases[i];
322+
def name = Name(alias.Name.Location);
323+
// TODO: Подумать не надо ли собрать все атрибуты, со всех частей вместо использования первого попавшегося alias.Attributes
324+
def decl = TypeParameter(alias.Location, name, alias.Attributes, false);
325+
def symbol = table.Define(decl, context);
326+
result.Add(symbol);
327+
}
320328
result.MoveToImmutable()
321329
}
322330
}

Nitra/Nitra.Grammar/AST/DotNet/CompilationUnit.n

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,12 @@ namespace DotNet
551551
def name = NRB.Name(loc, "#Tuple");
552552
def symbol = ExternalTypeDeclaration.[TypeAliasSymbol](name, realDecl.NemerleTypeInfo).DefineSymbol(declaredIn.MemberTable);
553553
symbol.TypeParametersCount = i;
554-
symbol.TypeParameters = AstUtils.CreateTypeParameters(i);
554+
symbol.TypeParameters = realSymbol.TypeParameters;
555555
symbol.DeclaredIn = declaredIn;
556556
symbol.EvalProperties(context);
557557
}
558558
}
559559

560-
561560
makeTuples();
562561

563562
def res1 = bind(rootNamespace.MemberTable, "Nemerle");

Nitra/Nitra.Runtime/Nitra.Runtime.Stage2.nproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
1212
</PropertyGroup>
1313
<Import Project="..\Nitra.Runtime\Nitra.Runtime.nproj" />
14+
<PropertyGroup>
15+
<RunDebugger>true</RunDebugger>
16+
</PropertyGroup>
1417
</Project>

0 commit comments

Comments
 (0)