Example #1
0
        public override void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression)
        {
            CheckExpression(unaryOperatorExpression);

            if (emitter.Resolver.ResolveNode(unaryOperatorExpression) is OperatorResolveResult rr && rr.UserDefinedOperatorMethod != null)
            {
                foreach (var typeArgument in rr.UserDefinedOperatorMethod.DeclaringType.TypeArguments)
                {
                    if (Helpers.HasTypeParameters(typeArgument))
                    {
                        var ivar = new TypeVariable(typeArgument);
                        if (!_usedVariables.Contains(ivar))
                        {
                            _usedVariables.Add(ivar);
                        }
                    }
                }
            }

            base.VisitUnaryOperatorExpression(unaryOperatorExpression);
        }
Example #2
0
        public override void VisitInvocationExpression(InvocationExpression invocationExpression)
        {
            CheckExpression(invocationExpression);


            if (emitter.Resolver.ResolveNode(invocationExpression) is InvocationResolveResult rr)
            {
                foreach (var argument in rr.Arguments)
                {
                    if (argument.Type != null && Helpers.HasTypeParameters(argument.Type))
                    {
                        var ivar = new TypeVariable(argument.Type);
                        if (!_usedVariables.Contains(ivar))
                        {
                            _usedVariables.Add(ivar);
                        }
                    }
                }
            }

            base.VisitInvocationExpression(invocationExpression);
        }
Example #3
0
        public override void VisitIndexerExpression(IndexerExpression indexerExpression)
        {
            CheckExpression(indexerExpression);

            if (_usedVariables.Count == 0)
            {
                var rr     = emitter.Resolver.ResolveNode(indexerExpression);
                var member = rr as MemberResolveResult;

                bool isInterface      = member != null && member.Member.DeclaringTypeDefinition != null && member.Member.DeclaringTypeDefinition.Kind == TypeKind.Interface;
                var  hasTypeParemeter = isInterface && Helpers.IsTypeParameterType(member.Member.DeclaringType);
                if (isInterface && hasTypeParemeter)
                {
                    var ivar = new TypeVariable(member.Member.DeclaringType);
                    if (!_usedVariables.Contains(ivar))
                    {
                        _usedVariables.Add(ivar);
                    }
                }
            }

            base.VisitIndexerExpression(indexerExpression);
        }