提交 0f950137 编写于 作者: C Charles Stoner

Misc.

上级 a27ba8a6
......@@ -592,7 +592,7 @@ private static string GetSpecialTypeName(INamedTypeSymbol symbol)
return null;
}
static bool isNativeInt(INamedTypeSymbol symbol) => symbol is NamedTypeSymbol { IsNativeInt: true };
static bool isNativeInt(INamedTypeSymbol symbol) => symbol.GetSymbol<NamedTypeSymbol>()?.IsNativeInt == true;
}
private void AddTypeKind(INamedTypeSymbol symbol)
......
......@@ -82,9 +82,9 @@ static void verify(CSharpCompilation comp)
var type0 = method.Parameters[0].Type;
var type1 = method.Parameters[1].Type;
Assert.Equal(SpecialType.None, type0.SpecialType);
Assert.False(((NamedTypeSymbol)type0).IsNativeInt);
Assert.False(IsNativeInt(type0));
Assert.Equal(SpecialType.System_UIntPtr, type1.SpecialType);
Assert.True(((NamedTypeSymbol)type1).IsNativeInt);
Assert.True(IsNativeInt(type1));
}
}
......@@ -119,12 +119,17 @@ static void verify(CSharpCompilation comp)
var type0 = method.Parameters[0].Type;
var type1 = method.Parameters[1].Type;
Assert.Equal(SpecialType.System_Int16, type0.SpecialType);
Assert.False(((NamedTypeSymbol)type0).IsNativeInt);
Assert.False(IsNativeInt(type0));
Assert.Equal(SpecialType.System_UIntPtr, type1.SpecialType);
Assert.True(((NamedTypeSymbol)type1).IsNativeInt);
Assert.True(IsNativeInt(type1));
}
}
private static bool IsNativeInt(ITypeSymbol type)
{
return type.GetSymbol<NamedTypeSymbol>()?.IsNativeInt == true;
}
// PROTOTYPE: nint and nuint should be allowed.
[Fact]
public void MemberName()
......
......@@ -7832,7 +7832,7 @@ class B
var method = comp.GetMember<MethodSymbol>("B.F1");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithoutSpecialTypes),
method.ToDisplayParts(formatWithoutSpecialTypes),
"static void F1(IntPtr x, UIntPtr y)",
SymbolDisplayPartKind.Keyword,
SymbolDisplayPartKind.Space,
......@@ -7850,7 +7850,7 @@ class B
SymbolDisplayPartKind.ParameterName,
SymbolDisplayPartKind.Punctuation);
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithSpecialTypes),
method.ToDisplayParts(formatWithSpecialTypes),
"static void F1(nint x, nuint y)",
SymbolDisplayPartKind.Keyword,
SymbolDisplayPartKind.Space,
......@@ -7870,26 +7870,26 @@ class B
method = comp.GetMember<MethodSymbol>("B.F2");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithoutSpecialTypes),
method.ToDisplayParts(formatWithoutSpecialTypes),
"static void F2(IntPtr x, IntPtr y)");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithSpecialTypes),
method.ToDisplayParts(formatWithSpecialTypes),
"static void F2(nint x, IntPtr y)");
method = comp.GetMember<MethodSymbol>("B.F3");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithoutSpecialTypes),
method.ToDisplayParts(formatWithoutSpecialTypes),
"static void F3(IntPtr? x, UIntPtr? y)");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithSpecialTypes),
method.ToDisplayParts(formatWithSpecialTypes),
"static void F3(nint? x, UIntPtr? y)");
method = comp.GetMember<MethodSymbol>("B.F4");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithoutSpecialTypes),
method.ToDisplayParts(formatWithoutSpecialTypes),
"static void F4(IntPtr[] x, A<UIntPtr> y)");
Verify(
SymbolDisplay.ToDisplayParts(method, formatWithSpecialTypes),
method.ToDisplayParts(formatWithSpecialTypes),
"static void F4(nint[] x, A<nuint> y)");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册