Skip to content

Commit

Permalink
[mcs] Missing type forwarded types should not cause type collision. F…
Browse files Browse the repository at this point in the history
…ixes #16196
  • Loading branch information
marek-safar committed Nov 14, 2013
1 parent c0567c5 commit 58d4cd3
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mcs/errors/CS1070-lib.il
Expand Up @@ -14,7 +14,7 @@

.module 'CS1070-lib.dll'

.class extern forwarder E
.class extern forwarder N.E
{
.assembly extern 'CS1070-lib-missing'
}
Expand Down
12 changes: 12 additions & 0 deletions mcs/errors/cs1070-2.cs
@@ -0,0 +1,12 @@
// CS1070: The type `N.E' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `CS1070-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
// Line: 9
// Compiler options: -r:CS1070-lib.dll

using N;

public class D
{
public void Foo (E e)
{
}
}
9 changes: 9 additions & 0 deletions mcs/mcs/namespace.cs
Expand Up @@ -353,11 +353,20 @@ public TypeSpec LookupType (IMemberContext ctx, string name, int arity, LookupMo
}

if (best.MemberDefinition.IsImported && ts.MemberDefinition.IsImported) {
if (ts.Kind == MemberKind.MissingType)
continue;

if (best.Kind == MemberKind.MissingType) {
best = ts;
continue;
}

if (mode == LookupMode.Normal) {
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best);
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts);
ctx.Module.Compiler.Report.Error (433, loc, "The imported type `{0}' is defined multiple times", ts.GetSignatureForError ());
}

break;
}

Expand Down
21 changes: 21 additions & 0 deletions mcs/tests/test-875-2-lib.il
@@ -0,0 +1,21 @@
.assembly extern mscorlib
{
}

.assembly extern 'test-875-lib-missing'
{
}

.assembly 'test-875-2-lib'
{
.hash algorithm 0x00008004
.ver 0:0:0:0
}

.module 'test-875-2-lib'

.class extern forwarder N.Lib
{
.assembly extern 'test-875-lib-missing'
}

8 changes: 8 additions & 0 deletions mcs/tests/test-875-lib.cs
@@ -0,0 +1,8 @@
// Compiler options: -t:library

namespace N
{
public class Lib
{
}
}
11 changes: 11 additions & 0 deletions mcs/tests/test-875.cs
@@ -0,0 +1,11 @@
// Compiler options: -r:test-875-lib.dll -r:test-875-2-lib.dll

using N;

public class Test: Lib
{
public static void Main ()
{
new Test ();
}
}
10 changes: 10 additions & 0 deletions mcs/tests/ver-il-net_4_5.xml
Expand Up @@ -48339,6 +48339,16 @@
</method>
</type>
</test>
<test name="test-875.cs">
<type name="Test">
<method name="Void Main()" attrs="150">
<size>8</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-88.cs">
<type name="X">
<method name="Void f(System.String)" attrs="145">
Expand Down

0 comments on commit 58d4cd3

Please sign in to comment.