/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionKindExtensions.cs
116 строк
4 KB
AlekseyTs
Initial support for Unions conversions (#81586)
12 дек 2025, 01:09
Не верифицирован
12 дек 2025, 01:09
55514f4
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Roslyn.Utilities; using static Microsoft.CodeAnalysis.CSharp.ConversionKind; namespace Microsoft.CodeAnalysis.CSharp { internal static class ConversionKindExtensions { public static bool IsDynamic(this ConversionKind conversionKind) { return conversionKind == ImplicitDynamic || conversionKind == ExplicitDynamic; } // Is the particular conversion an implicit conversion? public static bool IsImplicitConversion(this ConversionKind conversionKind) { switch (conversionKind) { case NoConversion: case UnsetConversionKind: return false; case Identity: case ImplicitNumeric: case ImplicitTupleLiteral: case ImplicitTuple: case ImplicitEnumeration: case ImplicitThrow: case ImplicitNullable: case NullLiteral: case DefaultLiteral: case ImplicitReference: case Boxing: case ImplicitDynamic: case ImplicitConstant: case ImplicitUserDefined: case Union: case AnonymousFunction: case ConversionKind.MethodGroup: case ConversionKind.FunctionType: case ImplicitPointerToVoid: case ImplicitNullToPointer: case InterpolatedString: case InterpolatedStringHandler: case SwitchExpression: case ConditionalExpression: case Deconstruction: case StackAllocToPointerType: case StackAllocToSpanType: case ImplicitPointer: case ObjectCreation: case InlineArray: case CollectionExpression: case ImplicitSpan: return true; case ExplicitNumeric: case ExplicitTuple: case ExplicitTupleLiteral: case ExplicitEnumeration: case ExplicitNullable: case ExplicitReference: case Unboxing: case ExplicitDynamic: case ExplicitUserDefined: case ExplicitPointerToPointer: case ExplicitPointerToInteger: case ExplicitIntegerToPointer: case IntPtr: case ExplicitSpan: return false; default: throw ExceptionUtilities.UnexpectedValue(conversionKind); } } // Is the particular conversion a used-defined conversion? public static bool IsUserDefinedConversion(this ConversionKind conversionKind) { switch (conversionKind) { case ImplicitUserDefined: case ExplicitUserDefined: return true; default: return false; } } public static bool IsUnionConversion(this ConversionKind conversionKind) { return conversionKind == Union; } public static bool IsPointerConversion(this ConversionKind kind) { switch (kind) { case ImplicitPointerToVoid: case ExplicitPointerToPointer: case ExplicitPointerToInteger: case ExplicitIntegerToPointer: case ImplicitNullToPointer: case ImplicitPointer: return true; default: return false; } } } }