--- /dev/null
+.assembly extern mscorlib
+{
+}
+
+.assembly extern 'CS0012-lib-missing'
+{
+}
+
+.assembly 'CS0012-16-lib'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+
+.module 'CS0012-16-lib.dll'
+
+.class public auto ansi beforefieldinit B
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig static void Foo(object o) cil managed
+ {
+ ret
+ }
+
+ .method public hidebysig static void Foo(class ['CS0012-lib-missing']AA t) cil managed
+ {
+ ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ ret
+ }
+
+}
$(wildcard dlls/second/*.cs)
TEST_SUPPORT_FILES = \
- CS0012-lib.dll CS0012-2-lib.dll CS0012-3-lib.dll CS0012-4-lib.dll CS0012-5-lib.dll CS0012-6-lib.dll CS0012-9-lib.dll CS0012-10-lib.dll CS0012-11-lib.dll CS0012-12-lib.dll CS0012-13-lib.dll CS0012-14-lib.dll CS0012-15-lib.dll CS0029-26-lib.dll \
+ CS0012-lib.dll CS0012-2-lib.dll CS0012-3-lib.dll CS0012-4-lib.dll CS0012-5-lib.dll CS0012-6-lib.dll CS0012-9-lib.dll CS0012-10-lib.dll CS0012-11-lib.dll CS0012-12-lib.dll CS0012-13-lib.dll CS0012-14-lib.dll CS0012-15-lib.dll CS0012-16-lib.dll CS0029-26-lib.dll \
CS0103-2-lib.dll CS0118-2-lib.dll CS0122-10-lib.dll CS0122-14-lib.dll CS0122-15-lib.dll CS0122-19-lib.dll CS0122-35-lib.dll CS0122-36-lib.dll CS0143-lib.dll CS0144-3-lib.dll CS0165-19-lib.dll \
CS0205-3-lib.dll CS0229-3-lib.dll CS0229-4-lib.dll CS0266-25-lib.dll \
CS0315-2-lib.dll \
-// CS0012: The type `A1' is defined in an assembly that is not referenced. Consider adding a reference to assembly `CS0012-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
+// CS0012: The type `AA' is defined in an assembly that is not referenced. Consider adding a reference to assembly `CS0012-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
// Line: 9
// Compiler options: -r:CS0012-14-lib.dll
{
public static void Main ()
{
- B.Foo (null);
+ B.Foo (new Test ());
}
}
--- /dev/null
+// CS0012: The type `AA' is defined in an assembly that is not referenced. Consider adding a reference to assembly `CS0012-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
+// Line: 9
+// Compiler options: -r:CS0012-16-lib.dll
+
+class Test
+{
+ public static void Main ()
+ {
+ B.Foo (new Test ());
+ }
+}
--- /dev/null
+// CS0453: The type `dynamic' must be a non-nullable value type in order to use it as type parameter `T' in the generic type or method `Tester.Foo<T>(T)'
+// Line: 10
+
+class Tester
+{
+ static void Foo<T> (T t) where T : struct
+ {
+ }
+
+ public static int Main ()
+ {
+ dynamic d = 1;
+ Foo<dynamic>(d);
+ return 0;
+ }
+}
GenericTask = 1 << 22
}
+ //
+ // Some flags can be copied directly from other member
+ //
+ protected const StateFlags SharedStateFlags =
+ StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected |
+ StateFlags.Obsolete | StateFlags.Obsolete_Undetected |
+ StateFlags.MissingDependency | StateFlags.MissingDependency_Undetected |
+ StateFlags.HasDynamicElement;
+
protected Modifiers modifiers;
public StateFlags state;
protected IMemberDefinition definition;
//
// A return value rates candidate method compatibility,
// 0 = the best, int.MaxValue = the worst
+ // -1 = fatal error
//
int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref MemberSpec candidate, IParametersMember pm, ref bool params_expanded_form, ref bool dynamicArgument, ref TypeSpec returnType)
{
arg_count = arguments.Count;
}
+ //
+ // Don't do any expensive checks when the candidate cannot succeed
+ //
+ if (arg_count != param_count && !cpd.HasParams)
+ return (param_count - arg_count) * 2 + 1;
+
+ var dep = candidate.GetMissingDependencies ();
+ if (dep != null) {
+ ImportedTypeDefinition.Error_MissingDependency (ec, dep, loc);
+ return -1;
+ }
+
//
// 1. Handle generic method using type arguments when specified or type inference
//
// How does it score compare to others
//
if (candidate_rate < best_candidate_rate) {
+
+ // Fatal error (missing dependency), cannot continue
+ if (candidate_rate < 0)
+ return null;
+
best_candidate_rate = candidate_rate;
best_candidate = member;
best_candidate_args = candidate_args;
if (oa != null && !rc.IsObsolete)
AttributeTester.Report_ObsoleteMessage (oa, best_candidate.GetSignatureForError (), loc, rc.Report);
- var dep = best_candidate.GetMissingDependencies ();
- if (dep != null) {
- ImportedTypeDefinition.Error_MissingDependency (rc, dep, loc);
- }
-
best_candidate.MemberDefinition.SetIsUsed ();
args = best_candidate_args;
if (targs == null)
throw new ArgumentNullException ("targs");
-// this.state = openType.state;
+ this.state &= ~SharedStateFlags;
+ this.state |= (openType.state & SharedStateFlags);
+
this.context = context;
this.open_type = openType;
this.targs = targs;
// Check the class constraint
//
if (tparam.HasTypeConstraint) {
- var dep = tparam.BaseType.GetMissingDependencies ();
- if (dep != null) {
- if (mc == null)
- return false;
-
- ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc);
- ok = false;
- }
-
if (!CheckConversion (mc, context, atype, tparam, tparam.BaseType, loc)) {
if (mc == null)
return false;
//
if (tparam.Interfaces != null) {
foreach (TypeSpec iface in tparam.Interfaces) {
- var dep = iface.GetMissingDependencies ();
- if (dep != null) {
- if (mc == null)
- return false;
-
- ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc);
- ok = false;
-
- // return immediately to avoid duplicate errors because we are scanning
- // expanded interface list
- return false;
- }
-
if (!CheckConversion (mc, context, atype, tparam, iface, loc)) {
if (mc == null)
return false;
// or referenced from the user core in which case compilation error has to
// be reported because compiler cannot continue anyway
//
- foreach (var t in types) {
+ for (int i = 0; i < types.Count; ++i) {
+ var t = types [i];
+
+ //
+ // Report missing types only once per type
+ //
+ if (i > 0 && types.IndexOf (t) < i)
+ continue;
+
string name = t.GetSignatureForError ();
if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) {
missing.AddRange (m);
}
+ if (Arity > 0) {
+ foreach (var tp in GenericDefinition.TypeParameters) {
+ var m = tp.GetMissingDependencies ();
+
+ if (m == null)
+ continue;
+
+ if (missing == null)
+ missing = new List<TypeSpec> ();
+
+ missing.AddRange (m);
+ }
+ }
+
return missing;
}
}
}
+ if (MemberDefinition.TypeParametersCount > 0) {
+ foreach (var tp in MemberDefinition.TypeParameters) {
+ var tp_missing = tp.GetMissingDependencies ();
+ if (tp_missing != null) {
+ if (missing == null)
+ missing = new List<TypeSpec> ();
+
+ missing.AddRange (tp_missing);
+ }
+ }
+ }
+
if (missing != null || BaseType == null)
return missing;
cache = MemberCache.Empty;
// Make all internal types CLS-compliant, non-obsolete
- state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected)) | StateFlags.CLSCompliant;
+ state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant;
}
#region Properties
{
this.Element = element;
- // Some flags can be copied directly from the element
- const StateFlags shared_flags = StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected
- | StateFlags.Obsolete | StateFlags.Obsolete_Undetected | StateFlags.HasDynamicElement;
- state &= ~shared_flags;
- state |= (element.state & shared_flags);
+ state &= ~SharedStateFlags;
+ state |= (element.state & SharedStateFlags);
if (element.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
state |= StateFlags.HasDynamicElement;