@@ -670,7 +670,7 @@ type ILTypeInfo =
670670 member x.ToType = let ( ILTypeInfo ( _ , ty , _ , _ )) = x in 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
675675 member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.ToAppType
676676
@@ -690,7 +690,7 @@ type ILTypeInfo =
690690 if isAnyTupleTy g ty then
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
694694 assert ( isILAppTy g metadataTy)
695695 let metadataTyconRef = tcrefOfAppTy g metadataTy
696696 let ( TILObjectReprData ( scoref , enc , tdef )) = metadataTyconRef.ILTyconInfo
@@ -727,7 +727,7 @@ type ILMethInfo =
727727 member x.ApparentEnclosingType = match x with 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.
733733 member x.ILExtensionMethodDeclaringTyconRef = match x with 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
899899 member x.ApparentEnclosingAppType =
900- match x with
901- | ILMeth(_, ilminfo,_) -> ilminfo.ApparentEnclosingAppType
902- | _ -> x.ApparentEnclosingType
900+ convertToTypeWithMetadataIfPossible x.TcGlobals x.ApparentEnclosingType
903901
904902 member x.ApparentEnclosingTyconRef =
905903 tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType
@@ -1005,7 +1003,8 @@ type MethInfo =
10051003 member x.FormalMethodTypars =
10061004 match x with
10071005 | ILMeth(_, ilmeth,_) -> ilmeth.FormalMethodTypars
1008- | FSMeth( g, typ, vref,_) ->
1006+ | FSMeth( g,_, vref,_) ->
1007+ let typ = x.ApparentEnclosingAppType
10091008 let _ , memberMethodTypars , _ , _ = AnalyzeTypeOfMemberVal x.IsCSharpStyleExtensionMember g ( typ, vref)
10101009 memberMethodTypars
10111010 | DefaultStructCtor _ -> []
@@ -1283,7 +1282,8 @@ type MethInfo =
12831282 match x with
12841283 | ILMeth(_ g, ilminfo,_) ->
12851284 ilminfo.GetCompiledReturnTy( amap, m, minst)
1286- | FSMeth( g, typ, vref,_) ->
1285+ | FSMeth( g,_, vref,_) ->
1286+ let typ = x.ApparentEnclosingAppType
12871287 let inst = GetInstantiationForMemberVal g x.IsCSharpStyleExtensionMember ( typ, vref, minst)
12881288 let _ , _ , retTy , _ = AnalyzeTypeOfMemberVal x.IsCSharpStyleExtensionMember g ( typ, vref)
12891289 retTy |> Option.map ( instType inst)
@@ -1320,8 +1320,9 @@ type MethInfo =
13201320 member x.GetObjArgTypes ( amap , m , minst ) =
13211321 match x with
13221322 | ILMeth(_, ilminfo,_) -> ilminfo.GetObjArgTypes( amap, m, minst)
1323- | FSMeth( g, typ , vref,_) ->
1323+ | FSMeth( g,_ , vref,_) ->
13241324 if x.IsInstance then
1325+ let typ = x.ApparentEnclosingAppType
13251326 // The 'this' pointer of an extension member can depend on the minst
13261327 if x.IsExtensionMember then
13271328 let inst = GetInstantiationForMemberVal g x.IsCSharpStyleExtensionMember ( typ, vref, minst)
@@ -1521,7 +1522,8 @@ type MethInfo =
15211522 match x with
15221523 | ILMeth(_ g, ilminfo,_) ->
15231524 [ ilminfo.GetParamNamesAndTypes( amap, m, minst) ]
1524- | FSMeth( g, typ, vref,_) ->
1525+ | FSMeth( g,_, vref,_) ->
1526+ let typ = x.ApparentEnclosingAppType
15251527 let items = ParamNameAndType.FromMember x.IsCSharpStyleExtensionMember g vref
15261528 let inst = GetInstantiationForMemberVal g x.IsCSharpStyleExtensionMember ( typ, vref, minst)
15271529 items |> ParamNameAndType.InstantiateCurried inst
@@ -1561,7 +1563,8 @@ type MethInfo =
15611563 if x.IsExtensionMember then []
15621564 else
15631565 match x with
1564- | FSMeth( g, typ, vref,_) ->
1566+ | FSMeth( g,_, vref,_) ->
1567+ let typ = x.ApparentEnclosingAppType
15651568 let memberParentTypars , _ , _ , _ = AnalyzeTypeOfMemberVal false g ( typ, vref)
15661569 memberParentTypars
15671570 | _ ->
@@ -1790,7 +1793,7 @@ type ILPropInfo =
17901793 member x.ApparentEnclosingType = match x with 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
17961799 member x.RawMetadata = match x with ILPropInfo(_, pd) -> pd
@@ -2096,8 +2099,9 @@ type PropInfo =
20962099 member x.GetPropertyType ( amap , m ) =
20972100 match x with
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
21012105 let inst = GetInstantiationForPropertyVal g ( typ, vref)
21022106 ReturnTypeOfPropertyVal g vref.Deref |> instType inst
21032107
0 commit comments