Fix #75941.
* ecore.cs (SimpleNameResolve.DoSimpleNameResolve): Disable
flow-branching for LocalVariableReferences in case we were invoked
from a MemberAccess.
* expression.cs (LocalVariableReference.VerifyAssigned): New.
Carved out of ...
(LocalVariableReference.DoResolveBase): ... this.
(MemberAccess.Resolve): Do the check that was disabled during
SimpleNameResolve.
In tests:
* test-452.cs: New test from #75941.
svn path=/trunk/mcs/; revision=49340
cs1641.cs
cs1666.cs NO ERROR
cs2007.cs
-
-cs0149.cs
-cs0531-2.cs
-cs0571-4.cs
+2005-09-02 Raja R Harinath <rharinath@novell.com>
+
+ Fix #75941.
+ * ecore.cs (SimpleNameResolve.DoSimpleNameResolve): Disable
+ flow-branching for LocalVariableReferences in case we were invoked
+ from a MemberAccess.
+ * expression.cs (LocalVariableReference.VerifyAssigned): New.
+ Carved out of ...
+ (LocalVariableReference.DoResolveBase): ... this.
+ (MemberAccess.Resolve): Do the check that was disabled during
+ SimpleNameResolve.
+
2005-09-01 Atsushi Enomoto <atsushi@ximian.com>
* class.cs :
public override FullNamedExpression ResolveAsTypeStep (EmitContext ec, bool silent)
{
int errors = Report.Errors;
- FullNamedExpression fne=null;
- try {
- fne = ec.DeclSpace.LookupType (Name, loc, /*ignore_cs0104=*/ false);
- } catch {
-
- Console.WriteLine ("Looking up: " + Name);
- }
-
+ FullNamedExpression fne = ec.DeclSpace.LookupType (Name, loc, /*ignore_cs0104=*/ false);
if (fne != null)
return fne;
if (current_block != null){
LocalInfo vi = current_block.GetLocalInfo (Name);
if (vi != null){
- Expression var;
-
- var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
-
- if (right_side != null)
+ LocalVariableReference var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
+ if (right_side != null) {
return var.ResolveLValue (ec, right_side, loc);
- else
- return var.Resolve (ec);
+ } else {
+ ResolveFlags rf = ResolveFlags.VariableOrValue;
+ if (intermediate)
+ rf |= ResolveFlags.DisableFlowAnalysis;
+ return var.Resolve (ec, rf);
+ }
}
ParameterReference pref = current_block.Toplevel.GetParameterReference (Name, loc);
}
}
+ public bool VerifyAssigned (EmitContext ec)
+ {
+ VariableInfo variable_info = local_info.VariableInfo;
+ return variable_info == null || variable_info.IsAssigned (ec, loc);
+ }
+
protected Expression DoResolveBase (EmitContext ec, Expression lvalue_right_side)
{
if (local_info == null) {
return e.Resolve (ec);
}
- if ((variable_info != null) && !variable_info.IsAssigned (ec, loc))
+ if (!VerifyAssigned (ec))
return null;
if (lvalue_right_side == null)
if (member_lookup == null)
return null;
+ if (original != null && !TypeManager.IsValueType (expr_type)) {
+ me = member_lookup as MemberExpr;
+ if (me != null && me.IsInstance) {
+ LocalVariableReference var = new_expr as LocalVariableReference;
+ if (var != null && !var.VerifyAssigned (ec))
+ return null;
+ }
+ }
+
// The following DoResolve/DoResolveLValue will do the definite assignment
// check.
if (right_side != null)
- member_lookup = member_lookup.DoResolveLValue (ec, right_side);
+ return member_lookup.DoResolveLValue (ec, right_side);
else
- member_lookup = member_lookup.DoResolve (ec);
-
- return member_lookup;
+ return member_lookup.DoResolve (ec);
}
public override Expression DoResolve (EmitContext ec)
+2005-09-02 Raja R Harinath <rharinath@novell.com>
+
+ * test-452.cs: New test from #75941.
+
2005-08-30 Atsushi Enomoto <atsushi@ximian.com>
* test-partial-08.cs, test-partial-09.cs :
--- /dev/null
+class Foo
+{
+ static public Foo x;
+}
+
+class Test
+{
+ static void Main ()
+ {
+ Foo Foo;
+ Foo = Foo.x;
+ }
+}