Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 4eed66b

Browse files
authored
Fixes: dotnet#4957 --- Intellisense for Indexed properties were broken by a recent (dotnet#4958)
* Fixes: dotnet#4957 * remaining codepaths * Rename helper
1 parent 6f7953c commit 4eed66b

File tree

7 files changed

+28
-24
lines changed

7 files changed

+28
-24
lines changed

src/fsharp/ConstraintSolver.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,7 @@ let CodegenWitnessThatTypSupportsTraitConstraint tcVal g amap m (traitInfo:Trait
26042604
| Some sln ->
26052605
match sln with
26062606
| ILMethSln(origTy, extOpt, mref, minst) ->
2607-
let metadataTy = helpEnsureTypeHasMetadata g origTy
2607+
let metadataTy = convertToTypeWithMetadataIfPossible g origTy
26082608
let tcref, _tinst = destAppTy g metadataTy
26092609
let mdef = IL.resolveILMethodRef tcref.ILTyconRawMetadata mref
26102610
let ilMethInfo =

src/fsharp/InfoReader.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ let rec GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTy m
7171
// Tuple types also support the methods get_Item1-8, get_Rest from the compiled tuple type.
7272
// In this case convert to the .NET Tuple type that carries metadata and try again
7373
if isAnyTupleTy g metadataTy then
74-
let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy
74+
let betterMetadataTy = convertToTypeWithMetadataIfPossible g metadataTy
7575
GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTy betterMetadataTy
7676
// Function types support methods FSharpFunc<_,_>.FromConverter and friends from .NET metadata,
7777
// but not instance methods (you can't write "f.Invoke(x)", you have to write "f x")
7878
elif isFunTy g metadataTy then
79-
let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy
79+
let betterMetadataTy = convertToTypeWithMetadataIfPossible g metadataTy
8080
GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTy betterMetadataTy
8181
|> List.filter (fun minfo -> not minfo.IsInstance)
8282
else
@@ -165,7 +165,7 @@ let rec GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTy m
165165
// Tuple types also support the properties Item1-8, Rest from the compiled tuple type
166166
// In this case convert to the .NET Tuple type that carries metadata and try again
167167
if isAnyTupleTy g metadataTy || isFunTy g metadataTy then
168-
let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy
168+
let betterMetadataTy = convertToTypeWithMetadataIfPossible g metadataTy
169169
GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTy betterMetadataTy
170170
else
171171
match tryDestAppTy g metadataTy with
@@ -465,7 +465,7 @@ let rec GetIntrinsicConstructorInfosOfTypeAux (infoReader:InfoReader) m origTy m
465465
// Tuple types also support constructors. In this case convert to the .NET Tuple type that carries metadata and try again
466466
// Function types also support constructors. In this case convert to the FSharpFunc type that carries metadata and try again
467467
if isAnyTupleTy g metadataTy || isFunTy g metadataTy then
468-
let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy
468+
let betterMetadataTy = convertToTypeWithMetadataIfPossible g metadataTy
469469
GetIntrinsicConstructorInfosOfTypeAux infoReader m origTy betterMetadataTy
470470
else
471471
match tryDestAppTy g metadataTy with

src/fsharp/NameResolution.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ let private ResolveObjectConstructorPrim (ncenv:NameResolver) edenv resInfo m ad
18891889
raze (Error(FSComp.SR.nrNoConstructorsAvailableForType(NicePrint.minimalStringOfType edenv typ),m))
18901890
else
18911891
let ctorInfos = ctorInfos |> List.filter (IsMethInfoAccessible amap m ad)
1892-
let metadataTy = helpEnsureTypeHasMetadata g typ
1892+
let metadataTy = convertToTypeWithMetadataIfPossible g typ
18931893
success (resInfo,Item.MakeCtorGroup ((tcrefOfAppTy g metadataTy).LogicalName, (defaultStructCtorInfo@ctorInfos)))
18941894

18951895
/// Perform name resolution for an identifier which must resolve to be an object constructor.

src/fsharp/TastOps.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ let mkInstForAppTy g typ =
795795
let domainOfFunTy g ty = fst (destFunTy g ty)
796796
let rangeOfFunTy g ty = snd (destFunTy g ty)
797797

798-
let helpEnsureTypeHasMetadata g ty =
798+
let convertToTypeWithMetadataIfPossible g ty =
799799
if isAnyTupleTy g ty then
800800
let (tupInfo, tupElemTys) = destAnyTupleTy g ty
801801
mkOuterCompiledTupleTy g (evalTupInfoIsStruct tupInfo) tupElemTys

src/fsharp/TastOps.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ val mkGetTupleItemN : TcGlobals -> range -> int -> ILType -> bool -> Expr -> TTy
252252
val evalTupInfoIsStruct : TupInfo -> bool
253253

254254
/// If it is a tuple type, ensure it's outermost type is a .NET tuple type, otherwise leave unchanged
255-
val helpEnsureTypeHasMetadata : TcGlobals -> TType -> TType
255+
val convertToTypeWithMetadataIfPossible : TcGlobals -> TType -> TType
256256

257257

258258
//-------------------------------------------------------------------------

src/fsharp/TypeChecker.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,7 +4923,7 @@ and TcTypeAndRecover cenv newOk checkCxs occ env tpenv ty =
49234923
TcTypeOrMeasureAndRecover (Some TyparKind.Type) cenv newOk checkCxs occ env tpenv ty
49244924

49254925
and TcNestedTypeApplication cenv newOk checkCxs occ env tpenv mWholeTypeApp typ tyargs =
4926-
let typ = helpEnsureTypeHasMetadata cenv.g typ
4926+
let typ = convertToTypeWithMetadataIfPossible cenv.g typ
49274927
if not (isAppTy cenv.g typ) then error(Error(FSComp.SR.tcTypeHasNoNestedTypes(), mWholeTypeApp))
49284928
match typ with
49294929
| TType_app(tcref, tinst) ->
@@ -13226,7 +13226,7 @@ module MutRecBindingChecking =
1322613226
// Phase2B: typecheck the argument to an 'inherits' call and build the new object expr for the inherit-call
1322713227
| Phase2AInherit (synBaseTy, arg, baseValOpt, m) ->
1322813228
let baseTy, tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurence.Use envInstance tpenv synBaseTy
13229-
let baseTy = baseTy |> helpEnsureTypeHasMetadata cenv.g
13229+
let baseTy = baseTy |> convertToTypeWithMetadataIfPossible cenv.g
1323013230
let inheritsExpr, tpenv = TcNewExpr cenv envInstance tpenv baseTy (Some synBaseTy.Range) true arg m
1323113231
let envInstance = match baseValOpt with Some baseVal -> AddLocalVal cenv.tcSink scopem baseVal envInstance | None -> envInstance
1323213232
let envNonRec = match baseValOpt with Some baseVal -> AddLocalVal cenv.tcSink scopem baseVal envNonRec | None -> envNonRec

src/fsharp/infos.fs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)