@@ -670,7 +670,7 @@ type ILTypeInfo =
670670member x.ToType = let ( ILTypeInfo ( _ , ty , _ , _ )) = xin ty
671671
672672/// Get the compiled nominal type. In the case of tuple types, this is a .NET tuple type
673- member x.ToAppType = helpEnsureTypeHasMetadata x.TcGlobals x.ToType
673+ member x.ToAppType = convertToTypeWithMetadataIfPossible x.TcGlobals x.ToType
674674
675675member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.ToAppType
676676
@@ -690,7 +690,7 @@ type ILTypeInfo =
690690if isAnyTupleTy g tythen
691691// When getting .NET metadata for the properties and methods
692692// of an F# tuple type, use the compiled nominal type, which is a .NET tuple type
693- let metadataTy = helpEnsureTypeHasMetadata g ty
693+ let metadataTy = convertToTypeWithMetadataIfPossible g ty
694694assert ( isILAppTy g metadataTy)
695695let metadataTyconRef = tcrefOfAppTy g metadataTy
696696let ( TILObjectReprData ( scoref , enc , tdef )) = metadataTyconRef.ILTyconInfo
@@ -727,7 +727,7 @@ type ILMethInfo =
727727member x.ApparentEnclosingType = match xwith ILMethInfo(_, ty,_,_,_) -> ty
728728
729729/// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type
730- member x.ApparentEnclosingAppType = helpEnsureTypeHasMetadata x.TcGlobals x.ApparentEnclosingType
730+ member x.ApparentEnclosingAppType = convertToTypeWithMetadataIfPossible x.TcGlobals x.ApparentEnclosingType
731731
732732/// Get the declaring type associated with an extension member, if any.
733733member x.ILExtensionMethodDeclaringTyconRef = match xwith ILMethInfo(_,_, tcrefOpt,_,_) -> tcrefOpt
@@ -897,9 +897,7 @@ type MethInfo =
897897
898898/// Get the enclosing type of the method info, using a nominal type for tuple types
899899member x.ApparentEnclosingAppType =
900- match xwith
901- | ILMeth(_, ilminfo,_) -> ilminfo.ApparentEnclosingAppType
902- | _ -> x.ApparentEnclosingType
900+ convertToTypeWithMetadataIfPossible x.TcGlobals x.ApparentEnclosingType
903901
904902member x.ApparentEnclosingTyconRef =
905903 tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType
@@ -1005,7 +1003,8 @@ type MethInfo =
10051003member x.FormalMethodTypars =
10061004match xwith
10071005| ILMeth(_, ilmeth,_) -> ilmeth.FormalMethodTypars
1008- | FSMeth( g, typ, vref,_) ->
1006+ | FSMeth( g,_, vref,_) ->
1007+ let typ = x.ApparentEnclosingAppType
10091008let _ , memberMethodTypars , _ , _ = AnalyzeTypeOfMemberVal x.IsCSharpStyleExtensionMember g( typ, vref)
10101009 memberMethodTypars
10111010| DefaultStructCtor_ -> []
@@ -1283,7 +1282,8 @@ type MethInfo =
12831282match xwith
12841283| ILMeth(_ g, ilminfo,_) ->
12851284 ilminfo.GetCompiledReturnTy( amap, m, minst)
1286- | FSMeth( g, typ, vref,_) ->
1285+ | FSMeth( g,_, vref,_) ->
1286+ let typ = x.ApparentEnclosingAppType
12871287let inst = GetInstantiationForMemberVal g x.IsCSharpStyleExtensionMember( typ, vref, minst)
12881288let _ , _ , retTy , _ = AnalyzeTypeOfMemberVal x.IsCSharpStyleExtensionMember g( typ, vref)
12891289 retTy|> Option.map( instType inst)
@@ -1320,8 +1320,9 @@ type MethInfo =
13201320member x.GetObjArgTypes ( amap , m , minst ) =
13211321match xwith
13221322| ILMeth(_, ilminfo,_) -> ilminfo.GetObjArgTypes( amap, m, minst)
1323- | FSMeth( g, typ , vref,_) ->
1323+ | FSMeth( g,_ , vref,_) ->
13241324if x.IsInstancethen
1325+ let typ = x.ApparentEnclosingAppType
13251326// The 'this' pointer of an extension member can depend on the minst
13261327if x.IsExtensionMemberthen
13271328let inst = GetInstantiationForMemberVal g x.IsCSharpStyleExtensionMember( typ, vref, minst)
@@ -1521,7 +1522,8 @@ type MethInfo =
15211522match xwith
15221523| ILMeth(_ g, ilminfo,_) ->
15231524[ ilminfo.GetParamNamesAndTypes( amap, m, minst) ]
1524- | FSMeth( g, typ, vref,_) ->
1525+ | FSMeth( g,_, vref,_) ->
1526+ let typ = x.ApparentEnclosingAppType
15251527let items = ParamNameAndType.FromMember x.IsCSharpStyleExtensionMember g vref
15261528let inst = GetInstantiationForMemberVal g x.IsCSharpStyleExtensionMember( typ, vref, minst)
15271529 items|> ParamNameAndType.InstantiateCurried inst
@@ -1561,7 +1563,8 @@ type MethInfo =
15611563if x.IsExtensionMemberthen []
15621564else
15631565match xwith
1564- | FSMeth( g, typ, vref,_) ->
1566+ | FSMeth( g,_, vref,_) ->
1567+ let typ = x.ApparentEnclosingAppType
15651568let memberParentTypars , _ , _ , _ = AnalyzeTypeOfMemberValfalse g( typ, vref)
15661569 memberParentTypars
15671570| _ ->
@@ -1790,7 +1793,7 @@ type ILPropInfo =
17901793member x.ApparentEnclosingType = match xwith ILPropInfo( tinfo,_) -> tinfo.ToType
17911794
17921795/// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type
1793- member x.ApparentEnclosingAppType = helpEnsureTypeHasMetadata x.TcGlobals x.ApparentEnclosingType
1796+ member x.ApparentEnclosingAppType = convertToTypeWithMetadataIfPossible x.TcGlobals x.ApparentEnclosingType
17941797
17951798/// Get the raw Abstract IL metadata for the IL property
17961799member x.RawMetadata = match xwith ILPropInfo(_, pd) -> pd
@@ -2096,8 +2099,9 @@ type PropInfo =
20962099member x.GetPropertyType ( amap , m ) =
20972100match xwith
20982101| ILProp ilpinfo-> ilpinfo.GetPropertyType( amap, m)
2099- | FSProp( g, typ, Some vref,_)
2100- | FSProp( g, typ,_, Some vref) ->
2102+ | FSProp( g,_, Some vref,_)
2103+ | FSProp( g,_,_, Some vref) ->
2104+ let typ = x.ApparentEnclosingAppType
21012105let inst = GetInstantiationForPropertyVal g( typ, vref)
21022106 ReturnTypeOfPropertyVal g vref.Deref|> instType inst
21032107