Skip to content

Commit

Permalink
2010-05-05 Miguel de Icaza <miguel@novell.com>
Browse files Browse the repository at this point in the history
	* class.cs (TypeContainer.DefineBaseTypes)
	(TypeContainer.CheckRecursiveDefinition): check for the iface not
	being null, as we could have failed resolution and crashed;
	Fixes #442144


svn path=/trunk/mcs/; revision=156759
  • Loading branch information
migueldeicaza committed May 5, 2010
1 parent cb373a0 commit f51cb39
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mcs/errors/cs0246-21.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// CS0246: The type or namespace name `IBase' could not be found. Are you missing a using directive or an assembly reference?
// Line: 155555

namespace Foo {
public interface IBase {
object X { get; }
}
}

public interface IDerived<T> : Foo.IBase {
T X { get; }
}

public class Test<T> {
public class Y : IDerived<T>, IBase
{
public T X { get { return default (T); } }
object Foo.IBase.X {
get { return default (T); }
}
}
}
5 changes: 5 additions & 0 deletions mcs/mcs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
2010-05-05 Miguel de Icaza <miguel@novell.com>

* class.cs (TypeContainer.DefineBaseTypes)
(TypeContainer.CheckRecursiveDefinition): check for the iface not
being null, as we could have failed resolution and crashed;
Fixes #442144

* cs-parser.jay: Productions to catch common mistakes when other
punctuation operators are used instead of comma. Fixes 571702

Expand Down
7 changes: 7 additions & 0 deletions mcs/mcs/class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,10 @@ bool DefineBaseTypes ()

if (iface_exprs != null) {
foreach (TypeExpr iface in iface_exprs) {
// Prevents a crash, the interface might not have been resolved: 442144
if (iface == null)
continue;

var iface_type = iface.Type;

if (!spec.AddInterface (iface_type))
Expand Down Expand Up @@ -1353,6 +1357,9 @@ TypeSpec CheckRecursiveDefinition (TypeContainer tc)

if (iface_exprs != null) {
foreach (TypeExpr iface in iface_exprs) {
// the interface might not have been resolved, prevents a crash, see #442144
if (iface == null)
continue;
var ptc = iface.Type.MemberDefinition as Interface;
if (ptc != null && ptc.CheckRecursiveDefinition (this) != null)
return iface.Type;
Expand Down

0 comments on commit f51cb39

Please sign in to comment.