{
Debug.Assert(generatedType == generatedType.GetTypeDefinition());
- if (HasGenericParameters(generatedType))
+ if (generatedType.HasInstantiation)
MapGeneratedTypeTypeParameters(generatedType);
}
}
- /// <summary>
- /// Check if the type itself is generic. The only difference is that
- /// if the type is a nested type, the generic parameters from its
- /// parent type don't count.
- /// </summary>
- static bool HasGenericParameters(MetadataType typeDef)
- {
- if (typeDef.ContainingType == null)
- return typeDef.HasInstantiation;
-
- return typeDef.Instantiation.Length > typeDef.ContainingType.Instantiation.Length;
- }
-
void MapGeneratedTypeTypeParameters(MetadataType generatedType)
{
Debug.Assert(CompilerGeneratedNames.IsGeneratedType(generatedType.Name));
// Now that we have instantiating methods fully filled out, walk the generated types and fill in the attribute
// providers
foreach (var generatedType in generatedTypeToTypeArgs.Keys) {
- if (HasGenericParameters (generatedType)) {
+ if (generatedType.HasGenericParameters) {
MapGeneratedTypeTypeParameters (generatedType, generatedTypeToTypeArgs, _context);
// Finally, add resolved type arguments to the cache
var info = generatedTypeToTypeArgs[generatedType];
return type;
/// <summary>
- /// Check if the type itself is generic. The only difference is that
- /// if the type is a nested type, the generic parameters from its
- /// parent type don't count.
- /// </summary>
- static bool HasGenericParameters (TypeDefinition typeDef)
- {
- if (!typeDef.IsNested)
- return typeDef.HasGenericParameters;
-
- return typeDef.GenericParameters.Count > typeDef.DeclaringType.GenericParameters.Count;
- }
-
- /// <summary>
/// Attempts to reverse the process of the compiler's alpha renaming. So if the original code was
/// something like this:
/// <code>
AsyncCapture ();
AsyncTypeMismatch ();
AsyncInsideClosure ();
+ AsyncInsideClosureNonGeneric ();
AsyncInsideClosureMismatch ();
// Closures
}
}
+ private static void AsyncInsideClosureNonGeneric ()
+ {
+ Outer<string> ();
+ void Outer<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T1> ()
+ {
+ int x = 0;
+ Inner ().Wait ();
+ async Task Inner ()
+ {
+ await Task.Delay (0);
+ x++;
+ _ = typeof (T1).GetMethods ();
+ }
+ }
+ }
+
private static void AsyncInsideClosureMismatch ()
{
Outer<string> ();