Пример #1
0
        public override BoundNode VisitBaseReference(BoundBaseReference node)
        {
            var syntax             = node.Syntax;
            var rewrittenParameter = RewriteParameter(syntax, _targetMethodThisParameter, node);

            var baseType = node.Type;
            HashSet <DiagnosticInfo> unusedUseSiteDiagnostics = null;
            var conversion = _conversions.ClassifyImplicitConversionFromExpression(rewrittenParameter, baseType, ref unusedUseSiteDiagnostics);

            Debug.Assert(unusedUseSiteDiagnostics == null || !conversion.IsValid || unusedUseSiteDiagnostics.All(d => d.Severity < DiagnosticSeverity.Error));

            // It would be nice if we could just call BoundConversion.Synthesized, but it doesn't seem worthwhile to
            // introduce a bunch of new overloads to accommodate isBaseConversion.
            return(new BoundConversion(
                       syntax,
                       rewrittenParameter,
                       conversion,
                       isBaseConversion: true,
                       @checked: false,
                       explicitCastInCode: false,
                       constantValueOpt: null,
                       type: baseType,
                       hasErrors: !conversion.IsValid)
            {
                WasCompilerGenerated = true
            });
        }
Пример #2
0
        public override BoundNode VisitBaseReference(BoundBaseReference node)
        {
            var syntax        = node.Syntax;
            var rewrittenThis = GenerateThisReference(node);
            var baseType      = node.Type;
            CompoundUseSiteInfo <AssemblySymbol> discardedSiteInfo =
#if DEBUG
                default;
#else
                CompoundUseSiteInfo <AssemblySymbol> .Discarded;
#endif
            var conversion = _conversions.ClassifyImplicitConversionFromExpression(rewrittenThis, baseType, ref discardedSiteInfo);
            Debug.Assert(discardedSiteInfo.Diagnostics == null || !conversion.IsValid || discardedSiteInfo.Diagnostics.All(d => d.Severity < DiagnosticSeverity.Error));

            // It would be nice if we could just call BoundConversion.Synthesized, but it doesn't seem worthwhile to
            // introduce a bunch of new overloads to accommodate isBaseConversion.
            return(new BoundConversion(
                       syntax,
                       rewrittenThis,
                       conversion,
                       isBaseConversion: true,
                       @checked: false,
                       explicitCastInCode: false,
                       conversionGroupOpt: null,
                       constantValueOpt: null,
                       type: baseType,
                       hasErrors: !conversion.IsValid)
            {
                WasCompilerGenerated = true
            });
        }
Пример #3
0
 public override BoundNode VisitBaseReference(BoundBaseReference node)
 {
     AddIfCaptured(_topLevelMethod.ThisParameter, node.Syntax);
     return(base.VisitBaseReference(node));
 }
Пример #4
0
        public override BoundNode VisitBaseReference(BoundBaseReference node)
        {
            var syntax = node.Syntax;
            var rewrittenParameter = RewriteParameter(syntax, _targetMethodThisParameter, node);

            var baseType = node.Type;
            HashSet<DiagnosticInfo> unusedUseSiteDiagnostics = null;
            var conversion = _conversions.ClassifyImplicitConversionFromExpression(rewrittenParameter, baseType, ref unusedUseSiteDiagnostics);
            Debug.Assert(unusedUseSiteDiagnostics == null || !conversion.IsValid || unusedUseSiteDiagnostics.All(d => d.Severity < DiagnosticSeverity.Error));

            // It would be nice if we could just call BoundConversion.Synthesized, but it doesn't seem worthwhile to
            // introduce a bunch of new overloads to accommodate isBaseConversion.
            return new BoundConversion(
                syntax,
                rewrittenParameter,
                conversion.Kind,
                conversion.ResultKind,
                isBaseConversion: true,
                symbolOpt: conversion.Method,
                @checked: false,
                explicitCastInCode: false,
                isExtensionMethod: conversion.IsExtensionMethod,
                isArrayIndex: conversion.IsArrayIndex,
                constantValueOpt: null,
                type: baseType,
                hasErrors: !conversion.IsValid)
            { WasCompilerGenerated = true };
        }
Пример #5
0
 internal void Parse(BoundBaseReference boundBaseReference)
 {
     base.Parse(boundBaseReference);
     IsReference = true;
 }
Пример #6
0
 public override object VisitBaseReference(BoundBaseReference node, object arg)
 {
     // TODO: in a struct constructor, "this" is not initially assigned.
     CheckAssigned(ThisSymbol, node.Syntax);
     return(null);
 }