Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mcs/class/corlib/System/ChangeLog5
-rw-r--r--mcs/class/corlib/System/String.cs6
-rw-r--r--mcs/errors/gcs0019-3.cs12
-rw-r--r--mcs/gmcs/ChangeLog9
-rw-r--r--mcs/gmcs/ecore.cs3
-rw-r--r--mcs/gmcs/generic.cs65
-rw-r--r--mcs/tests/gtest-142.cs22
-rwxr-xr-xmcs/tests/gtest-252.cs20
-rwxr-xr-xmcs/tests/gtest-253.cs45
-rwxr-xr-xmcs/tests/gtest-254.cs31
10 files changed, 184 insertions, 34 deletions
diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog
index 9160a4323ff..d1ae0c29cb4 100644
--- a/mcs/class/corlib/System/ChangeLog
+++ b/mcs/class/corlib/System/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-07 Martin Baulig <martin@ximian.com>
+
+ * String.cs (String.FormatHelper): Try getting an `ICustomFormatter'
+ from the `provider' if possible.
+
2006-02-15 Martin Baulig <martin@ximian.com>
* Type.cs (Type.IsGenericInstance): Removed.
diff --git a/mcs/class/corlib/System/String.cs b/mcs/class/corlib/System/String.cs
index 822a6803a6a..4562a75da80 100644
--- a/mcs/class/corlib/System/String.cs
+++ b/mcs/class/corlib/System/String.cs
@@ -1128,8 +1128,14 @@ namespace System
object arg = args[n];
string str;
+ ICustomFormatter formatter = null;
+ if (provider != null)
+ formatter = provider.GetFormat (typeof (ICustomFormatter))
+ as ICustomFormatter;
if (arg == null)
str = "";
+ else if (formatter != null)
+ str = formatter.Format (arg_format, arg, provider);
else if (arg is IFormattable)
str = ((IFormattable)arg).ToString (arg_format, provider);
else
diff --git a/mcs/errors/gcs0019-3.cs b/mcs/errors/gcs0019-3.cs
new file mode 100644
index 00000000000..ad101cfe669
--- /dev/null
+++ b/mcs/errors/gcs0019-3.cs
@@ -0,0 +1,12 @@
+// CS0019: Operator '&&' cannot be applied to operands of type 'bool?' and 'bool?'
+// Line: 10
+using System;
+
+class X
+{
+ static void Main ()
+ {
+ bool? a = false, b = false;
+ Console.WriteLine (a && b);
+ }
+}
diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog
index 573b6a11aa7..dbdb2d2c141 100644
--- a/mcs/gmcs/ChangeLog
+++ b/mcs/gmcs/ChangeLog
@@ -1,3 +1,12 @@
+2006-03-09 Martin Baulig <martin@ximian.com>
+
+ * ecore.cs (FieldExpr.AddressOf): Don't emit the instance if the
+ `prepared' flag is set.
+
+ * generic.cs (LiftedBinaryOperator): Don't allow `||' or `&&' anymore.
+ (LiftedBinaryOperator, LiftedUnaryMutator): Fix a few nullable
+ issues; see gtest-254.cs.
+
2006-03-07 Martin Baulig <martin@ximian.com>
* generic.cs (TypeManager.InferType): Allow infering
diff --git a/mcs/gmcs/ecore.cs b/mcs/gmcs/ecore.cs
index fa7452cbe25..7ac0acb4cec 100644
--- a/mcs/gmcs/ecore.cs
+++ b/mcs/gmcs/ecore.cs
@@ -3381,7 +3381,8 @@ namespace Mono.CSharp {
if (FieldInfo.IsStatic){
ig.Emit (OpCodes.Ldsflda, FieldInfo);
} else {
- EmitInstance (ec, false);
+ if (!prepared)
+ EmitInstance (ec, false);
ig.Emit (OpCodes.Ldflda, FieldInfo);
}
}
diff --git a/mcs/gmcs/generic.cs b/mcs/gmcs/generic.cs
index 3dcc14bfbde..8d0c4b03d8b 100644
--- a/mcs/gmcs/generic.cs
+++ b/mcs/gmcs/generic.cs
@@ -2691,8 +2691,7 @@ namespace Mono.CSharp {
if (expr == null)
return null;
- if (!(expr is IMemoryLocation))
- temp = new LocalTemporary (ec, expr.Type);
+ temp = new LocalTemporary (ec, expr.Type);
info = new NullableInfo (expr.Type);
type = info.UnderlyingType;
@@ -2712,6 +2711,11 @@ namespace Mono.CSharp {
ec.ig.EmitCall (OpCodes.Call, info.HasValue, null);
}
+ public void Store (EmitContext ec)
+ {
+ create_temp (ec);
+ }
+
void create_temp (EmitContext ec)
{
if ((temp != null) && !has_temp) {
@@ -2746,14 +2750,35 @@ namespace Mono.CSharp {
public void EmitAssign (EmitContext ec, Expression source,
bool leave_copy, bool prepare_for_load)
{
- source.Emit (ec);
- ec.ig.Emit (OpCodes.Newobj, info.Constructor);
+ InternalWrap wrap = new InternalWrap (source, info, loc);
+ ((IAssignMethod) expr).EmitAssign (ec, wrap, leave_copy, false);
+ }
- if (leave_copy)
- ec.ig.Emit (OpCodes.Dup);
+ protected class InternalWrap : Expression
+ {
+ public Expression expr;
+ public NullableInfo info;
+
+ public InternalWrap (Expression expr, NullableInfo info, Location loc)
+ {
+ this.expr = expr;
+ this.info = info;
+ this.loc = loc;
- Expression empty = new EmptyExpression (expr.Type);
- ((IAssignMethod) expr).EmitAssign (ec, empty, false, prepare_for_load);
+ type = info.Type;
+ eclass = ExprClass.Value;
+ }
+
+ public override Expression DoResolve (EmitContext ec)
+ {
+ return this;
+ }
+
+ public override void Emit (EmitContext ec)
+ {
+ expr.Emit (ec);
+ ec.ig.Emit (OpCodes.Newobj, info.Constructor);
+ }
}
}
@@ -2957,7 +2982,8 @@ namespace Mono.CSharp {
{
public readonly Binary.Operator Oper;
- Expression left, right, underlying, null_value, bool_wrap;
+ Expression left, right, original_left, original_right;
+ Expression underlying, null_value, bool_wrap;
Unwrap left_unwrap, right_unwrap;
bool is_equality, is_comparision, is_boolean;
@@ -2965,8 +2991,8 @@ namespace Mono.CSharp {
Location loc)
{
this.Oper = op;
- this.left = left;
- this.right = right;
+ this.left = original_left = left;
+ this.right = original_right = right;
this.loc = loc;
}
@@ -2986,8 +3012,16 @@ namespace Mono.CSharp {
return null;
}
- if (((Oper == Binary.Operator.BitwiseAnd) || (Oper == Binary.Operator.BitwiseOr) ||
- (Oper == Binary.Operator.LogicalAnd) || (Oper == Binary.Operator.LogicalOr)) &&
+ if ((Oper == Binary.Operator.LogicalAnd) ||
+ (Oper == Binary.Operator.LogicalOr)) {
+ Binary.Error_OperatorCannotBeApplied (
+ loc, Binary.OperName (Oper),
+ original_left.GetSignatureForError (),
+ original_right.GetSignatureForError ());
+ return null;
+ }
+
+ if (((Oper == Binary.Operator.BitwiseAnd) || (Oper == Binary.Operator.BitwiseOr)) &&
((left.Type == TypeManager.bool_type) && (right.Type == TypeManager.bool_type))) {
Expression empty = new EmptyExpression (TypeManager.bool_type);
bool_wrap = new Wrap (empty, loc).Resolve (ec);
@@ -3220,6 +3254,11 @@ namespace Mono.CSharp {
public override void Emit (EmitContext ec)
{
+ if (left_unwrap != null)
+ left_unwrap.Store (ec);
+ if (right_unwrap != null)
+ right_unwrap.Store (ec);
+
if (is_boolean) {
EmitBoolean (ec);
return;
diff --git a/mcs/tests/gtest-142.cs b/mcs/tests/gtest-142.cs
index d875ad667cc..1347905dcfa 100644
--- a/mcs/tests/gtest-142.cs
+++ b/mcs/tests/gtest-142.cs
@@ -27,12 +27,14 @@ public static class Assert
}
public static void IsNull<T> (string text, Nullable<T> nullable)
+ where T : struct
{
if (nullable.HasValue)
Error ("IsNull", text);
}
public static void IsNotNull<T> (string text, Nullable<T> nullable)
+ where T : struct
{
if (!nullable.HasValue)
Error ("IsNotNull", text);
@@ -89,26 +91,6 @@ class X
Assert.IsTrue ("f | b", f | b);
Assert.IsTrue ("f | c", f | c);
- Assert.IsNull ("d && a", d && a);
- Assert.IsFalse ("d && b", d && b);
- Assert.IsNull ("d && c", d && c);
- Assert.IsFalse ("e && a", e && a);
- Assert.IsFalse ("e && b", e && b);
- Assert.IsFalse ("e && c", e && c);
- Assert.IsNull ("f && a", f && a);
- Assert.IsFalse ("f && b", f && b);
- Assert.IsTrue ("f && c", f && c);
-
- Assert.IsNull ("d || a", d || a);
- Assert.IsNull ("d || b", d || b);
- Assert.IsTrue ("d || c", d || c);
- Assert.IsNull ("e || a", e || a);
- Assert.IsFalse ("e || b", e || b);
- Assert.IsTrue ("e || c", e || c);
- Assert.IsTrue ("f || a", f || a);
- Assert.IsTrue ("f || b", f || b);
- Assert.IsTrue ("f || c", f || c);
-
int? g = 3, h = null, i = 3, j = null;
Assert.IsFalse ("g == null", g == null);
diff --git a/mcs/tests/gtest-252.cs b/mcs/tests/gtest-252.cs
new file mode 100755
index 00000000000..ddfb29f932f
--- /dev/null
+++ b/mcs/tests/gtest-252.cs
@@ -0,0 +1,20 @@
+using System;
+
+public static class EqualityComparer<T>
+{
+ readonly static Type sequencedequalityComparer = typeof (SequencedEqualityComparer<,>);
+
+ public static void Test ()
+ { }
+}
+
+public class SequencedEqualityComparer<T,W>
+{ }
+
+class X
+{
+ static void Main ()
+ {
+ EqualityComparer<int>.Test ();
+ }
+}
diff --git a/mcs/tests/gtest-253.cs b/mcs/tests/gtest-253.cs
new file mode 100755
index 00000000000..658dea9cbad
--- /dev/null
+++ b/mcs/tests/gtest-253.cs
@@ -0,0 +1,45 @@
+using System;
+using SCG = System.Collections.Generic;
+
+public interface IExtensible<T>
+{
+ void AddAll<U> (SCG.IEnumerable<U> items)
+ where U : T;
+}
+
+public abstract class CollectionValueTester<R,S>
+ where R : IExtensible<S>
+{
+ protected R collection;
+}
+
+public class ExtensibleTester<U> : CollectionValueTester<U,int>
+ where U : IExtensible<int>
+{
+ public ExtensibleTester (U u)
+ {
+ this.collection = u;
+ }
+
+ public void Direct()
+ {
+ collection.AddAll<int> (new int[] { });
+ }
+}
+
+public class Extensible<V> : IExtensible<V>
+{
+ public void AddAll<W> (SCG.IEnumerable<W> items)
+ where W : V
+ { }
+}
+
+class X
+{
+ static void Main ()
+ {
+ Extensible<int> ext = new Extensible<int> ();
+ ExtensibleTester<Extensible<int>> tester = new ExtensibleTester<Extensible<int>> (ext);
+ tester.Direct ();
+ }
+}
diff --git a/mcs/tests/gtest-254.cs b/mcs/tests/gtest-254.cs
new file mode 100755
index 00000000000..0a78b9bc97d
--- /dev/null
+++ b/mcs/tests/gtest-254.cs
@@ -0,0 +1,31 @@
+using System;
+
+public class HashedLinkedList<T>
+{
+ public int? Offset;
+
+ public static HashedLinkedList<T> GetList ()
+ {
+ return new HashedLinkedList<T> ();
+ }
+
+ public static void Test (int added)
+ {
+ GetList ().Offset += added;
+ }
+
+ public void Test (HashedLinkedList<T> view)
+ {
+ view.Offset--;
+ }
+}
+
+class X
+{
+ static void Main ()
+ {
+ HashedLinkedList<int>.Test (5);
+ HashedLinkedList<long> list = new HashedLinkedList<long> ();
+ list.Test (list);
+ }
+}