From 11effc0afb864f356b9e43f09c99db1a75d4ffcc Mon Sep 17 00:00:00 2001 From: dsyme Date: Wed, 29 Nov 2017 17:57:30 +0000 Subject: [PATCH 01/17] make tuples support Item* with warning --- src/fsharp/AccessibilityLogic.fs | 4 +- src/fsharp/AttributeChecking.fs | 10 ++- src/fsharp/FSComp.txt | 1 + src/fsharp/InfoReader.fs | 56 +++++++++---- src/fsharp/NameResolution.fs | 4 + src/fsharp/TypeChecker.fs | 4 + src/fsharp/infos.fs | 105 ++++++++++++++++-------- src/fsharp/symbols/SymbolHelpers.fs | 10 +-- src/fsharp/symbols/Symbols.fs | 14 ++-- src/fsharp/vs/service.fs | 4 +- tests/fsharp/core/csext/test.fsx | 108 +++++++++++++++++++++++++ tests/fsharp/typecheck/sigs/neg101.bsl | 74 ++++++++++++++++- tests/fsharp/typecheck/sigs/neg101.fs | 41 ++++++++++ tests/fsharp/typecheck/sigs/pos28.fs | 2 + 14 files changed, 369 insertions(+), 68 deletions(-) diff --git a/src/fsharp/AccessibilityLogic.fs b/src/fsharp/AccessibilityLogic.fs index c69d00cd0a0..759b60bd0fd 100644 --- a/src/fsharp/AccessibilityLogic.fs +++ b/src/fsharp/AccessibilityLogic.fs @@ -165,8 +165,8 @@ let private IsILTypeInfoAccessible amap m ad (tcrefOfViewedItem : TyconRef) = check None (enc @ [tdef]) /// Indicates if an IL member associated with the given ILType is accessible -let private IsILTypeAndMemberAccessible g amap m adType ad (ILTypeInfo(tcrefOfViewedItem, _, _, _)) access = - IsILTypeInfoAccessible amap m adType tcrefOfViewedItem && IsILMemberAccessible g amap m tcrefOfViewedItem ad access +let private IsILTypeAndMemberAccessible g amap m adType ad (typ: ILTypeInfo) access = + IsILTypeInfoAccessible amap m adType typ.TyconRefOfRawMetadata && IsILMemberAccessible g amap m typ.TyconRefOfRawMetadata ad access /// Indicates if an entity is accessible let IsEntityAccessible amap m ad (tcref:TyconRef) = diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index d3902075119..84545798e25 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -460,13 +460,19 @@ let MethInfoIsUnseen g m typ minfo = typ |> ignore false #endif - isUnseenByObsoleteAttrib || isUnseenByHidingAttribute + + let isUnseenByBeingTupleMethod = isAnyTupleTy g typ + + isUnseenByObsoleteAttrib || isUnseenByHidingAttribute || isUnseenByBeingTupleMethod /// Indicate if a property has 'Obsolete' or 'CompilerMessageAttribute'. /// Used to suppress the item in intellisense. let PropInfoIsUnseen m pinfo = match pinfo with - | ILProp (g,ILPropInfo(_,pdef)) -> CheckILAttributesForUnseen g pdef.CustomAttrs m + | ILProp (g,(ILPropInfo(_,pdef) as ilpinfo)) -> + // Properties on tuple types are resolvable but unseen + isAnyTupleTy g ilpinfo.ILTypeInfo.ToType || + CheckILAttributesForUnseen g pdef.CustomAttrs m | FSProp (g,_,Some vref,_) | FSProp (g,_,_,Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs m | FSProp _ -> failwith "CheckPropInfoAttributes: unreachable" diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index deeb8d5daf0..697a3d25b24 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1422,3 +1422,4 @@ notAFunctionButMaybeIndexer,"This expression is not a function and cannot be app notAFunctionButMaybeDeclaration,"This value is not a function and cannot be applied. Did you forget to terminate a declaration?" 3218,ArgumentsInSigAndImplMismatch,"The argument names in the signature '%s' and implementation '%s' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling." 3219,pickleUnexpectedNonZero,"An error occurred while reading the F# metadata of assembly '%s'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct." +3220,tcTupleMemberNotNormallyUsed,"This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead" diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index c6f8a7629ce..cf2300d6c2e 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -47,9 +47,7 @@ let TrySelectMemberVal g optFilter typ pri _membInfo (vref:ValRef) = else None -/// Query the immediate methods of an F# type, not taking into account inherited methods. The optFilter -/// parameter is an optional name to restrict the set of properties returned. -let GetImmediateIntrinsicMethInfosOfType (optFilter,ad) g amap m typ = +let rec GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTyp typ = let minfos = match metadataOfTy g typ with @@ -65,15 +63,27 @@ let GetImmediateIntrinsicMethInfosOfType (optFilter,ad) g amap m typ = | ILTypeMetadata (TILObjectReprData(_,_,tdef)) -> let mdefs = tdef.Methods let mdefs = (match optFilter with None -> mdefs.AsList | Some nm -> mdefs.FindByName nm) - mdefs |> List.map (fun mdef -> MethInfo.CreateILMeth(amap, m, typ, mdef)) + mdefs |> List.map (fun mdef -> MethInfo.CreateILMeth(amap, m, origTyp, mdef)) + | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> - match tryDestAppTy g typ with - | None -> [] - | Some tcref -> - SelectImmediateMemberVals g optFilter (TrySelectMemberVal g optFilter typ None) tcref + // Tuple types also support the properties Item1-8, Rest from the compiled tuple type + if isAnyTupleTy g typ then + let (tupInfo, args) = destAnyTupleTy g typ + let compiledTy = mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args + GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTyp compiledTy + else + match tryDestAppTy g typ with + | None -> [] + | Some tcref -> + SelectImmediateMemberVals g optFilter (TrySelectMemberVal g optFilter typ None) tcref let minfos = minfos |> List.filter (IsMethInfoAccessible amap m ad) minfos +/// Query the immediate methods of an F# type, not taking into account inherited methods. The optFilter +/// parameter is an optional name to restrict the set of properties returned. +let GetImmediateIntrinsicMethInfosOfType (optFilter,ad) g amap m typ = + GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m typ typ + /// A helper type to help collect properties. /// /// Join up getters and setters which are not associated in the F# data structure @@ -86,7 +96,9 @@ type PropertyCollector(g,amap,m,typ,optFilter,ad) = pinfo1.IsStatic = pinfo2.IsStatic && PropInfosEquivByNameAndPartialSig EraseNone g amap m pinfo1 pinfo2 && pinfo1.IsDefiniteFSharpOverride = pinfo2.IsDefiniteFSharpOverride ) + let props = new System.Collections.Generic.Dictionary(hashIdentity) + let add pinfo = if props.ContainsKey(pinfo) then match props.[pinfo], pinfo with @@ -116,11 +128,9 @@ type PropertyCollector(g,amap,m,typ,optFilter,ad) = member x.Close() = [ for KeyValue(_,pinfo) in props -> pinfo ] -/// Query the immediate properties of an F# type, not taking into account inherited properties. The optFilter -/// parameter is an optional name to restrict the set of properties returned. -let GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ = - let pinfos = +let rec GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTyp typ = + let pinfos = match metadataOfTy g typ with #if !NO_EXTENSIONTYPING | ProvidedTypeMetadata info -> @@ -137,14 +147,23 @@ let GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ = |> Seq.map(fun pi -> ProvidedProp(amap,pi,m)) |> List.ofSeq #endif + | ILTypeMetadata (TILObjectReprData(_,_,tdef)) -> - let tinfo = ILTypeInfo.FromType g typ + let tinfo = ILTypeInfo.FromType g origTyp let pdefs = tdef.Properties let pdefs = match optFilter with None -> pdefs.AsList | Some nm -> pdefs.LookupByName nm pdefs |> List.map (fun pd -> ILProp(g,ILPropInfo(tinfo,pd))) + | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> + match tryDestAppTy g typ with - | None -> [] + | None -> + // Tuple types also support the properties Item1-8, Rest from the compiled tuple type + if isAnyTupleTy g typ then + let (tupInfo, args) = destAnyTupleTy g typ + GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m typ (mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args) + else + [] | Some tcref -> let propCollector = new PropertyCollector(g,amap,m,typ,optFilter,ad) SelectImmediateMemberVals g None @@ -155,6 +174,11 @@ let GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ = let pinfos = pinfos |> List.filter (IsPropInfoAccessible g amap m ad) pinfos +/// Query the immediate properties of an F# type, not taking into account inherited properties. The optFilter +/// parameter is an optional name to restrict the set of properties returned. +let rec GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ = + GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m typ typ + // Checks whether the given type has an indexer property. let IsIndexerType g amap typ = isArray1DTy g typ || @@ -162,7 +186,7 @@ let IsIndexerType g amap typ = match tryDestAppTy g typ with | Some tcref -> let _, entityTy = generalizeTyconRef tcref - let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) g amap range0 entityTy + let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) g amap range0 entityTy props |> List.exists (fun x -> x.PropertyName = "Item") | _ -> false @@ -284,7 +308,7 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = let optFilter = Some nm FoldPrimaryHierarchyOfType (fun typ acc -> let minfos = GetImmediateIntrinsicMethInfosOfType (optFilter,ad) g amap m typ - let pinfos = GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ + let pinfos = GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ let finfos = GetImmediateIntrinsicILFieldsOfType (optFilter,ad) m typ let einfos = ComputeImmediateIntrinsicEventsOfType (optFilter,ad) m typ let rfinfos = GetImmediateIntrinsicRecdOrClassFieldsOfType (optFilter,ad) m typ diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index a80ddbf1df6..4e86c677043 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -3461,6 +3461,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso not x.IsSpecialName && x.IsStatic = statics && IsILFieldInfoAccessible g amap m ad x) + let pinfosIncludingUnseen = AllPropInfosOfTypeInScope ncenv.InfoReader nenv (None,ad) PreferOverrides m typ |> List.filter (fun x -> @@ -3499,6 +3500,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso match completionTargets with | ResolveCompletionTargets.All x -> x | _ -> failwith "internal error: expected completionTargets = ResolveCompletionTargets.All" + // Only show the Finalize, MemberwiseClose etc. methods on System.Object for values whose static type really is // System.Object. Few of these are typically used from F#. // @@ -3523,6 +3525,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso | _ -> // filter out self methods of obj type isObjTy g minfo.EnclosingType + let result = not isUnseenDueToBasicObjRules && not minfo.IsInstance = statics && @@ -3534,6 +3537,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso not (minfo.LogicalName = ".ctor") && isApplicableMeth minfo typ && not (suppressedMethNames.Contains minfo.LogicalName) + result let pinfoItems = diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index c193ce6fc86..e07ba653563 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -173,6 +173,10 @@ let MethInfoChecks g amap isInstance tyargsOpt objArgs ad m (minfo:MethInfo) = if not (IsTypeAndMethInfoAccessible amap m adOriginal ad minfo) then error (Error (FSComp.SR.tcMethodNotAccessible(minfo.LogicalName), m)) + + if isAnyTupleTy g minfo.EnclosingType then + warning (Error (FSComp.SR.tcTupleMemberNotNormallyUsed(), m)) + CheckMethInfoAttributes g m tyargsOpt minfo |> CommitOperationResult diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 5ac157c8d42..c9624dcd9f3 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -663,30 +663,49 @@ let ArbitraryMethodInfoOfPropertyInfo (pi:Tainted) m = [] type ILTypeInfo = /// ILTypeInfo (tyconRef, ilTypeRef, typeArgs, ilTypeDef). - | ILTypeInfo of TyconRef * ILTypeRef * TypeInst * ILTypeDef + | ILTypeInfo of TcGlobals * TType * ILTypeRef * ILTypeDef + + member x.TcGlobals = let (ILTypeInfo(g,_,_,_)) = x in g + member x.ILTypeRef = let (ILTypeInfo(_,_,tref,_)) = x in tref + + member x.RawType = + let (ILTypeInfo(g,ty,_,_)) = x + if isAnyTupleTy g ty then + let (tupInfo, args) = destAnyTupleTy g ty + mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args + else ty + + member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.RawType + member x.TypeInstOfRawMetadata = argsOfAppTy x.TcGlobals x.RawType - member x.TyconRef = let (ILTypeInfo(tcref,_,_,_)) = x in tcref - member x.ILTypeRef = let (ILTypeInfo(_,tref,_,_)) = x in tref - member x.TypeInst = let (ILTypeInfo(_,_,tinst,_)) = x in tinst member x.RawMetadata = let (ILTypeInfo(_,_,_,tdef)) = x in tdef - member x.ToType = TType_app(x.TyconRef,x.TypeInst) + member x.ToType = let (ILTypeInfo(_,ty,_,_)) = x in ty member x.ILScopeRef = x.ILTypeRef.Scope member x.Name = x.ILTypeRef.Name member x.IsValueType = x.RawMetadata.IsStructOrEnum member x.Instantiate inst = - let (ILTypeInfo(tcref,tref,tinst,tdef)) = x - ILTypeInfo(tcref,tref,instTypes inst tinst,tdef) + let (ILTypeInfo(g,ty,tref,tdef)) = x + ILTypeInfo(g,instType inst ty,tref,tdef) - member x.FormalTypars m = x.TyconRef.Typars m + //member x.FormalTypars m = x.TyconRef.Typars m static member FromType g ty = - if isILAppTy g ty then - let tcref,tinst = destAppTy g ty + if isAnyTupleTy g ty then + let (tupInfo, args) = destAnyTupleTy g ty + let compiledTy = mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args + assert (isILAppTy g compiledTy) + let compiledTyconRef = tcrefOfAppTy g compiledTy + let (TILObjectReprData(scoref,enc,tdef)) = compiledTyconRef.ILTyconInfo + let compiledILTypeRef = mkRefForNestedILTypeDef scoref (enc,tdef) + ILTypeInfo(g,ty,compiledILTypeRef,tdef) + + elif isILAppTy g ty then + let tcref = tcrefOfAppTy g ty let (TILObjectReprData(scoref,enc,tdef)) = tcref.ILTyconInfo let tref = mkRefForNestedILTypeDef scoref (enc,tdef) - ILTypeInfo(tcref,tref,tinst,tdef) + ILTypeInfo(g,ty,tref,tdef) else - failwith "ILTypeInfo.FromType" + failwith "ILTypeInfo.FromType - no IL metadata for type" //------------------------------------------------------------------------- // ILMethInfo @@ -706,10 +725,19 @@ type ILMethInfo = member x.TcGlobals = match x with ILMethInfo(g,_,_,_,_) -> g /// Get the apparent declaring type of the method as an F# type. - /// If this is an C#-style extension method then this is the type which the method + /// If this is a C#-style extension method then this is the type which the method /// appears to extend. This may be a variable type. member x.ApparentEnclosingType = match x with ILMethInfo(_,ty,_,_,_) -> ty + /// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type + member x.ApparentEnclosingAppType = + let g = x.TcGlobals + let enclTy = x.ApparentEnclosingType + if isAnyTupleTy g enclTy then + let (tupInfo, args) = destAnyTupleTy g enclTy + mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args + else enclTy + /// Get the declaring type associated with an extension member, if any. member x.DeclaringTyconRefOption = match x with ILMethInfo(_,_,tcrefOpt,_,_) -> tcrefOpt @@ -730,13 +758,14 @@ type ILMethInfo = member x.DeclaringTyconRef = match x.DeclaringTyconRefOption with | Some tcref -> tcref - | None -> tcrefOfAppTy x.TcGlobals x.ApparentEnclosingType + | None -> tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the instantiation of the declaring type of the method. /// If this is an C#-style extension method then this is empty because extension members /// are never in generic classes. member x.DeclaringTypeInst = - if x.IsILExtensionMethod then [] else argsOfAppTy x.TcGlobals x.ApparentEnclosingType + if x.IsILExtensionMethod then [] + else argsOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the Abstract IL scope information associated with interpreting the Abstract IL metadata that backs this method. member x.MetadataScope = x.DeclaringTyconRef.CompiledRepresentationForNamedType.Scope @@ -873,14 +902,20 @@ type MethInfo = /// This may be a variable type. member x.EnclosingType = match x with - | ILMeth(_g,ilminfo,_) -> ilminfo.ApparentEnclosingType - | FSMeth(_g,typ,_,_) -> typ - | DefaultStructCtor(_g,typ) -> typ + | ILMeth(_,ilminfo,_) -> ilminfo.ApparentEnclosingType + | FSMeth(_,typ,_,_) -> typ + | DefaultStructCtor(_,typ) -> typ #if !NO_EXTENSIONTYPING | ProvidedMeth(amap,mi,_,m) -> Import.ImportProvidedType amap m (mi.PApply((fun mi -> mi.DeclaringType),m)) #endif + /// Get the enclosing type of the method info, using a nominal type for tuple types + member x.EnclosingAppType = + match x with + | ILMeth(_,ilminfo,_) -> ilminfo.ApparentEnclosingAppType + | _ -> x.EnclosingType + /// Get the declaring type or module holding the method. If this is an C#-style extension method then this is the type /// holding the static member that is the extension method. If this is an F#-style extension method it is the logical module /// holding the value for the extension method. @@ -888,7 +923,7 @@ type MethInfo = match x with | ILMeth(_,ilminfo,_) when x.IsExtensionMember -> ilminfo.DeclaringTyconRef | FSMeth(_,_,vref,_) when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent - | _ -> tcrefOfAppTy x.TcGlobals x.EnclosingType + | _ -> tcrefOfAppTy x.TcGlobals x.EnclosingAppType /// Get the information about provided static parameters, if any member x.ProvidedStaticParameterInfo = @@ -964,7 +999,7 @@ type MethInfo = /// /// For extension members this is empty (the instantiation of the declaring type). member x.DeclaringTypeInst = - if x.IsExtensionMember then [] else argsOfAppTy x.TcGlobals x.EnclosingType + if x.IsExtensionMember then [] else argsOfAppTy x.TcGlobals x.EnclosingAppType /// Get the TcGlobals value that governs the method declaration member x.TcGlobals = @@ -1177,7 +1212,7 @@ type MethInfo = // but is compiled as a generic methods with two type arguments // Map<'T,'U>(this: List<'T>, f : 'T -> 'U) member x.AdjustUserTypeInstForFSharpStyleIndexedExtensionMembers(tyargs) = - (if x.IsFSharpStyleExtensionMember then argsOfAppTy x.TcGlobals x.EnclosingType else []) @ tyargs + (if x.IsFSharpStyleExtensionMember then argsOfAppTy x.TcGlobals x.EnclosingAppType else []) @ tyargs /// Indicates if this method is a generated method associated with an F# CLIEvent property compiled as a .NET event member x.IsFSharpEventPropertyMethod = @@ -1200,8 +1235,8 @@ type MethInfo = /// Build IL method infos. static member CreateILMeth (amap:Import.ImportMap, m, typ:TType, md: ILMethodDef) = let tinfo = ILTypeInfo.FromType amap.g typ - let mtps = Import.ImportILGenericParameters (fun () -> amap) m tinfo.ILScopeRef tinfo.TypeInst md.GenericParams - ILMeth (amap.g,ILMethInfo(amap.g,tinfo.ToType,None,md,mtps),None) + let mtps = Import.ImportILGenericParameters (fun () -> amap) m tinfo.ILScopeRef tinfo.TypeInstOfRawMetadata md.GenericParams + ILMeth (amap.g,ILMethInfo(amap.g, typ, None, md, mtps),None) /// Build IL method infos for a C#-style extension method static member CreateILExtensionMeth (amap, m, apparentTy:TType, declaringTyconRef:TyconRef, extMethPri, md: ILMethodDef) = @@ -1452,7 +1487,7 @@ type MethInfo = // happens to make the return type 'unit' (i.e. it was originally a variable type // then that does not correspond to a slotsig compiled as a 'void' return type. // REVIEW: should we copy down attributes to slot params? - let tcref = tcrefOfAppTy g x.EnclosingType + let tcref = tcrefOfAppTy g x.EnclosingAppType let formalEnclosingTyparsOrig = tcref.Typars(m) let formalEnclosingTypars = copyTypars formalEnclosingTyparsOrig let _,formalEnclosingTyparTys = FixupNewTypars m [] [] formalEnclosingTyparsOrig formalEnclosingTypars @@ -1462,10 +1497,10 @@ type MethInfo = match x with | ILMeth(_,ilminfo,_) -> let ftinfo = ILTypeInfo.FromType g (TType_app(tcref,formalEnclosingTyparTys)) - let formalRetTy = ImportReturnTypeFromMetaData amap m ilminfo.RawMetadata.Return.Type ftinfo.ILScopeRef ftinfo.TypeInst formalMethTyparTys + let formalRetTy = ImportReturnTypeFromMetaData amap m ilminfo.RawMetadata.Return.Type ftinfo.ILScopeRef ftinfo.TypeInstOfRawMetadata formalMethTyparTys let formalParams = [ [ for p in ilminfo.RawMetadata.Parameters do - let paramType = ImportILTypeFromMetadata amap m ftinfo.ILScopeRef ftinfo.TypeInst formalMethTyparTys p.Type + let paramType = ImportILTypeFromMetadata amap m ftinfo.ILScopeRef ftinfo.TypeInstOfRawMetadata formalMethTyparTys p.Type yield TSlotParam(p.Name, paramType, p.IsIn, p.IsOut, p.IsOptional, []) ] ] formalRetTy, formalParams #if !NO_EXTENSIONTYPING @@ -1540,7 +1575,7 @@ type MethInfo = (tcrefOfAppTy g typ).Typars(m) #if !NO_EXTENSIONTYPING | ProvidedMeth (amap,_,_,_) -> - (tcrefOfAppTy amap.g x.EnclosingType).Typars(m) + (tcrefOfAppTy amap.g x.EnclosingAppType).Typars(m) #endif //------------------------------------------------------------------------- @@ -1576,10 +1611,10 @@ type ILFieldInfo = /// Get the scope used to interpret IL metadata member x.ScopeRef = x.ILTypeRef.Scope - /// Get the type instantiation of the declaring type of the field + /// Get the type instantiation of the declaring type of the field member x.TypeInst = match x with - | ILFieldInfo(tinfo,_) -> tinfo.TypeInst + | ILFieldInfo(tinfo,_) -> tinfo.TypeInstOfRawMetadata #if !NO_EXTENSIONTYPING | ProvidedField _ -> [] /// GENERIC TYPE PROVIDERS #endif @@ -1647,7 +1682,7 @@ type ILFieldInfo = /// Get the type of the field as an F# type member x.FieldType(amap,m) = match x with - | ILFieldInfo (tinfo,fdef) -> ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] fdef.Type + | ILFieldInfo (tinfo,fdef) -> ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInstOfRawMetadata [] fdef.Type #if !NO_EXTENSIONTYPING | ProvidedField(amap,fi,m) -> Import.ImportProvidedType amap m (fi.PApply((fun fi -> fi.FieldType),m)) #endif @@ -1780,21 +1815,21 @@ type ILPropInfo = /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetParamNamesAndTypes(amap,m) = let (ILPropInfo (tinfo,pdef)) = x - pdef.Args |> List.map (fun ty -> ParamNameAndType(None, ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] ty) ) + pdef.Args |> List.map (fun ty -> ParamNameAndType(None, ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInstOfRawMetadata [] ty) ) /// Get the types of the indexer arguments associated with the IL property. /// /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetParamTypes(amap,m) = let (ILPropInfo (tinfo,pdef)) = x - pdef.Args |> List.map (fun ty -> ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] ty) + pdef.Args |> List.map (fun ty -> ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInstOfRawMetadata [] ty) /// Get the return type of the IL property. /// /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetPropertyType (amap,m) = let (ILPropInfo (tinfo,pdef)) = x - ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] pdef.Type + ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInstOfRawMetadata [] pdef.Type override x.ToString() = x.ILTypeInfo.ToString() + "::" + x.PropertyName @@ -2295,7 +2330,7 @@ type EventInfo = // Get the delegate type associated with an IL event, taking into account the instantiation of the // declaring type. if Option.isNone edef.Type then error (nonStandardEventError x.EventName m) - ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] edef.Type.Value + ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInstOfRawMetadata [] edef.Type.Value | FSEvent(g,p,_,_) -> FindDelegateTypeOfPropertyEvent g amap x.EventName m (p.GetPropertyType(amap,m)) @@ -2345,7 +2380,7 @@ let CompiledSigOfMeth g amap m (minfo:MethInfo) = // of the enclosing type. For example, they may have constraints involving the _formal_ type parameters // of the enclosing type. This instantiations can be used to interpret those type parameters let fmtpinst = - let parentTyArgs = argsOfAppTy g minfo.EnclosingType + let parentTyArgs = argsOfAppTy g minfo.EnclosingAppType let memberParentTypars = minfo.GetFormalTyparsOfDeclaringType m mkTyparInst memberParentTypars parentTyArgs diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index e95870cb976..e08584a6090 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -586,7 +586,7 @@ module internal SymbolHelpers = | None -> None | Some vref -> GetXmlDocSigOfScopedValRef g tcref vref | ILProp(g, (ILPropInfo(tinfo, pdef))) -> - let tcref = tinfo.TyconRef + let tcref = tinfo.TyconRefOfRawMetadata match metaInfoOfEntityRef infoReader m tcref with | Some (ccuFileName, formalTypars, formalTypeInfo) -> let filpinfo = ILPropInfo(formalTypeInfo, pdef) @@ -597,7 +597,7 @@ module internal SymbolHelpers = match einfo with | ILEvent(_, ilEventInfo) -> let tinfo = ilEventInfo.ILTypeInfo - let tcref = tinfo.TyconRef + let tcref = tinfo.TyconRefOfRawMetadata match metaInfoOfEntityRef infoReader m tcref with | Some (ccuFileName, _, formalTypeInfo) -> Some(ccuFileName, "E:"+formalTypeInfo.ILTypeRef.FullName+"."+einfo.EventName) @@ -1336,7 +1336,7 @@ module internal SymbolHelpers = | Item.ILField finfo -> match finfo with | ILFieldInfo(tinfo, fdef) -> - (tinfo.TyconRef |> ticksAndArgCountTextOfTyconRef)+"."+fdef.Name |> Some + (tinfo.TyconRefOfRawMetadata |> ticksAndArgCountTextOfTyconRef)+"."+fdef.Name |> Some #if !NO_EXTENSIONTYPING | ProvidedField _ -> None #endif @@ -1388,7 +1388,7 @@ module internal SymbolHelpers = | ParentNone -> None | ILProp(_, (ILPropInfo(tinfo, pdef))) -> - let tcref = tinfo.TyconRef + let tcref = tinfo.TyconRefOfRawMetadata (tcref |> ticksAndArgCountTextOfTyconRef)+"."+pdef.Name |> Some | FSProp _ -> None #if !NO_EXTENSIONTYPING @@ -1400,7 +1400,7 @@ module internal SymbolHelpers = match einfo with | ILEvent(_, ilEventInfo) -> let tinfo = ilEventInfo.ILTypeInfo - let tcref = tinfo.TyconRef + let tcref = tinfo.TyconRefOfRawMetadata (tcref |> ticksAndArgCountTextOfTyconRef)+"."+einfo.EventName |> Some | FSEvent(_, pinfo, _, _) -> match pinfo.ArbitraryValRef with diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index c97b62e9d48..acfa6a5eabd 100644 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -492,7 +492,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = else for minfo in GetImmediateIntrinsicMethInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy do yield createMember minfo - let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy + let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy let events = cenv.infoReader.GetImmediateIntrinsicEventsOfType (None, AccessibleFromSomeFSharpCode, range0, entityTy) for pinfo in props do yield FSharpMemberOrFunctionOrValue(cenv, P pinfo, Item.Property (pinfo.PropertyName, [pinfo])) @@ -1432,7 +1432,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = let eventName = m.LogicalName.[4..] let entityTy = generalizedTyconRef m.DeclaringEntityRef not (isNil (cenv.infoReader.GetImmediateIntrinsicEventsOfType (Some eventName, AccessibleFromSomeFSharpCode, range0, entityTy))) || - match GetImmediateIntrinsicPropInfosOfType(Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 (generalizedTyconRef m.DeclaringEntityRef) with + let declaringTy = generalizedTyconRef m.DeclaringEntityRef + match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with | pinfo :: _ -> pinfo.IsFSharpEventProperty | _ -> false @@ -1445,7 +1446,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = let eventName = m.LogicalName.[7..] let entityTy = generalizedTyconRef m.DeclaringEntityRef not (isNil (cenv.infoReader.GetImmediateIntrinsicEventsOfType (Some eventName, AccessibleFromSomeFSharpCode, range0, entityTy))) || - match GetImmediateIntrinsicPropInfosOfType(Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 (generalizedTyconRef m.DeclaringEntityRef) with + let declaringTy = generalizedTyconRef m.DeclaringEntityRef + match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with | pinfo :: _ -> pinfo.IsFSharpEventProperty | _ -> false | _ -> false @@ -1469,7 +1471,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match d with | M m when m.LogicalName.StartsWith("get_") -> let propName = PrettyNaming.ChopPropertyName(m.LogicalName) - not (isNil (GetImmediateIntrinsicPropInfosOfType(Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 (generalizedTyconRef m.DeclaringEntityRef))) + let declaringTy = generalizedTyconRef m.DeclaringEntityRef + not (isNil (GetImmediateIntrinsicPropInfosOfType (Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy)) | V v -> v.IsPropertyGetterMethod | _ -> false @@ -1479,7 +1482,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = // Look for a matching property with the right name. | M m when m.LogicalName.StartsWith("set_") -> let propName = PrettyNaming.ChopPropertyName(m.LogicalName) - not (isNil (GetImmediateIntrinsicPropInfosOfType(Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 (generalizedTyconRef m.DeclaringEntityRef))) + let declaringTy = generalizedTyconRef m.DeclaringEntityRef + not (isNil (GetImmediateIntrinsicPropInfosOfType (Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy)) | V v -> v.IsPropertySetterMethod | _ -> false diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index f40cc61dc46..a559ae021fd 100644 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -1174,14 +1174,14 @@ type TypeCheckInfo | _ -> None | None -> None - | Item.ILField (ILFieldInfo (ILTypeInfo (tr, _, _, _) & typeInfo, fieldDef)) when not tr.IsLocalRef -> + | Item.ILField (ILFieldInfo (typeInfo, fieldDef)) when not typeInfo.TyconRefOfRawMetadata.IsLocalRef -> match typeInfo.ILScopeRef with | ILScopeRef.Assembly assref -> let externalSym = ExternalSymbol.Field (typeInfo.ILTypeRef.FullName, fieldDef.Name) Some (FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) | _ -> None - | Item.Event (ILEvent (_, ILEventInfo (ILTypeInfo (tr, _, _, _) & typeInfo, eventDef))) when not tr.IsLocalRef -> + | Item.Event (ILEvent (_, ILEventInfo (typeInfo, eventDef))) when not typeInfo.TyconRefOfRawMetadata.IsLocalRef -> match typeInfo.ILScopeRef with | ILScopeRef.Assembly assref -> let externalSym = ExternalSymbol.Event (typeInfo.ILTypeRef.FullName, eventDef.Name) diff --git a/tests/fsharp/core/csext/test.fsx b/tests/fsharp/core/csext/test.fsx index 16a8da62e7c..0fde4fd0d7b 100644 --- a/tests/fsharp/core/csext/test.fsx +++ b/tests/fsharp/core/csext/test.fsx @@ -53,6 +53,114 @@ type Struct(i:int) = static member BlueStruct = blueStruct +#nowarn "3220" + +module TestsExplicitUseOfTupleProperties = + // all give a warning, suppressed in this file + let x1 = + [ (1,2).Item1 + (1,2).Item2 + (1,2,3).Item1 + (1,2,3).Item2 + (1,2,3).Item3 + (1,2,3,4).Item1 + (1,2,3,4).Item2 + (1,2,3,4).Item3 + (1,2,3,4).Item4 + (1,2,3,4,5).Item1 + (1,2,3,4,5).Item2 + (1,2,3,4,5).Item3 + (1,2,3,4,5).Item4 + (1,2,3,4,5).Item5 + (1,2,3,4,5,6).Item1 + (1,2,3,4,5,6).Item2 + (1,2,3,4,5,6).Item3 + (1,2,3,4,5,6).Item4 + (1,2,3,4,5,6).Item5 + (1,2,3,4,5,6).Item6 + (1,2,3,4,5,6,7).Item1 + (1,2,3,4,5,6,7).Item2 + (1,2,3,4,5,6,7).Item3 + (1,2,3,4,5,6,7).Item4 + (1,2,3,4,5,6,7).Item5 + (1,2,3,4,5,6,7).Item6 + (1,2,3,4,5,6,7).Item7 + (1,2,3,4,5,6,7,8).Item1 + (1,2,3,4,5,6,7,8).Item2 + (1,2,3,4,5,6,7,8).Item3 + (1,2,3,4,5,6,7,8).Item4 + (1,2,3,4,5,6,7,8).Item5 + (1,2,3,4,5,6,7,8).Item6 + (1,2,3,4,5,6,7,8).Item7 + (1,2,3,4,5,6,7,8,9).Item1 + (1,2,3,4,5,6,7,8,9).Item2 + (1,2,3,4,5,6,7,8,9).Item3 + (1,2,3,4,5,6,7,8,9).Item4 + (1,2,3,4,5,6,7,8,9).Item5 + (1,2,3,4,5,6,7,8,9).Item6 + (1,2,3,4,5,6,7,8,9).Item7 + (1,2).get_Item1() + (1,2).get_Item2() + (1,2,3).get_Item1() + (1,2,3).get_Item2() + (1,2,3).get_Item3() + (1,2,3,4).get_Item1() + (1,2,3,4).get_Item2() + (1,2,3,4).get_Item3() + (1,2,3,4).get_Item4() + (1,2,3,4,5).get_Item1() + (1,2,3,4,5).get_Item2() + (1,2,3,4,5).get_Item3() + (1,2,3,4,5).get_Item4() + (1,2,3,4,5).get_Item5() + (1,2,3,4,5,6).get_Item1() + (1,2,3,4,5,6).get_Item2() + (1,2,3,4,5,6).get_Item3() + (1,2,3,4,5,6).get_Item4() + (1,2,3,4,5,6).get_Item5() + (1,2,3,4,5,6).get_Item6() + (1,2,3,4,5,6,7).get_Item1() + (1,2,3,4,5,6,7).get_Item2() + (1,2,3,4,5,6,7).get_Item3() + (1,2,3,4,5,6,7).get_Item4() + (1,2,3,4,5,6,7).get_Item5() + (1,2,3,4,5,6,7).get_Item6() + (1,2,3,4,5,6,7).get_Item7() + (1,2,3,4,5,6,7,8).get_Item1() + (1,2,3,4,5,6,7,8).get_Item2() + (1,2,3,4,5,6,7,8).get_Item3() + (1,2,3,4,5,6,7,8).get_Item4() + (1,2,3,4,5,6,7,8).get_Item5() + (1,2,3,4,5,6,7,8).get_Item6() + (1,2,3,4,5,6,7,8).get_Item7() + (1,2,3,4,5,6,7,8,9).get_Item1() + (1,2,3,4,5,6,7,8,9).get_Item2() + (1,2,3,4,5,6,7,8,9).get_Item3() + (1,2,3,4,5,6,7,8,9).get_Item4() + (1,2,3,4,5,6,7,8,9).get_Item5() + (1,2,3,4,5,6,7,8,9).get_Item6() + (1,2,3,4,5,6,7,8,9).get_Item7() ] + + printfn "x1 = %A" x1 + check "vwhnwrvep01" x1 [1; 2; 1; 2; 3; 1; 2; 3; 4; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 6; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; + 1; 2; 1; 2; 3; 1; 2; 3; 4; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 6; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7] + + let x2 = (1,2,3,4,5,6,7,8).Rest // gives a warning, suppressed in this file + printfn "x2 = %A" x2 + check "vwhnwrvep02" x2 (System.Tuple(8)) + + let x3 = (1,2,3,4,5,6,7,8,9).Rest // gives a warning, suppressed in this file + printfn "x3 = %A" x3 + check "vwhnwrvep03" x3 (unbox (box (8,9))) + + // check a quotation of these + let tup = (1,2) + let x4 = <@ tup.Item1 @> + + let text = sprintf "%A" x4 + printfn "%s" text + check "vewjwervwver" text "PropertyGet (Some (PropertyGet (None, tup, [])), Item1, [])" + (*--------------------*) #if TESTS_AS_APP diff --git a/tests/fsharp/typecheck/sigs/neg101.bsl b/tests/fsharp/typecheck/sigs/neg101.bsl index 65e8cf1fd44..fedfd09ffcd 100644 --- a/tests/fsharp/typecheck/sigs/neg101.bsl +++ b/tests/fsharp/typecheck/sigs/neg101.bsl @@ -1,2 +1,74 @@ -neg101.fs(7,11,7,14): typecheck error FS0039: The field, constructor or member 'Foo' is not defined. \ No newline at end of file +neg101.fs(7,11,7,14): typecheck error FS0039: The field, constructor or member 'Foo' is not defined. + +neg101.fs(14,6,14,17): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(15,6,15,17): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(16,6,16,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(17,6,17,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(18,6,18,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(19,6,19,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(20,6,20,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(21,6,21,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(22,6,22,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(23,6,23,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(24,6,24,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(25,6,25,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(26,6,26,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(27,6,27,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(28,6,28,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(29,6,29,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(30,6,30,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(31,6,31,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(32,6,32,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(33,6,33,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(34,6,34,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(35,6,35,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(36,6,36,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(37,6,37,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(38,6,38,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(39,6,39,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(40,6,40,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(41,6,41,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(42,6,42,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(43,6,43,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(44,6,44,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(45,6,45,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(46,6,46,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(47,6,47,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(49,10,49,32): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + +neg101.fs(50,16,50,20): typecheck error FS0039: The field, constructor or member 'Rest' is not defined. diff --git a/tests/fsharp/typecheck/sigs/neg101.fs b/tests/fsharp/typecheck/sigs/neg101.fs index 482d68a2f40..76785bd35a4 100644 --- a/tests/fsharp/typecheck/sigs/neg101.fs +++ b/tests/fsharp/typecheck/sigs/neg101.fs @@ -7,3 +7,44 @@ let x: int = 1 let y = x.Foo let f1 z = z.Foo let f2 (z: MyRec) = z.Foo + + +// all give a warning +let x1 = + [ (1,2).Item1 + (1,2).Item2 + (1,2,3).Item1 + (1,2,3).Item2 + (1,2,3).Item3 + (1,2,3,4).Item1 + (1,2,3,4).Item2 + (1,2,3,4).Item3 + (1,2,3,4).Item4 + (1,2,3,4,5).Item1 + (1,2,3,4,5).Item2 + (1,2,3,4,5).Item3 + (1,2,3,4,5).Item4 + (1,2,3,4,5).Item5 + (1,2,3,4,5,6).Item1 + (1,2,3,4,5,6).Item2 + (1,2,3,4,5,6).Item3 + (1,2,3,4,5,6).Item4 + (1,2,3,4,5,6).Item5 + (1,2,3,4,5,6).Item6 + (1,2,3,4,5,6,7).Item1 + (1,2,3,4,5,6,7).Item2 + (1,2,3,4,5,6,7).Item3 + (1,2,3,4,5,6,7).Item4 + (1,2,3,4,5,6,7).Item5 + (1,2,3,4,5,6,7).Item6 + (1,2,3,4,5,6,7).Item7 + (1,2,3,4,5,6,7,8).Item1 + (1,2,3,4,5,6,7,8).Item2 + (1,2,3,4,5,6,7,8).Item3 + (1,2,3,4,5,6,7,8).Item4 + (1,2,3,4,5,6,7,8).Item5 + (1,2,3,4,5,6,7,8).Item6 + (1,2,3,4,5,6,7,8).Item7 ] + +let x2 = (1,2,3,4,5,6,7,8).Rest // gives a warning +let x3 = (1,2).Rest // gives an actual error \ No newline at end of file diff --git a/tests/fsharp/typecheck/sigs/pos28.fs b/tests/fsharp/typecheck/sigs/pos28.fs index 2fded70c6fa..ae383989f47 100644 --- a/tests/fsharp/typecheck/sigs/pos28.fs +++ b/tests/fsharp/typecheck/sigs/pos28.fs @@ -23,3 +23,5 @@ module Test2 = let p1 = &&point.x NativePtr.read p1 + + \ No newline at end of file From 80039c378c2c4e1f39fa3dc11f0a60d759cb9220 Mon Sep 17 00:00:00 2001 From: dsyme Date: Wed, 29 Nov 2017 18:04:39 +0000 Subject: [PATCH 02/17] add deactivated tests for struct tuple --- tests/fsharp/core/csext/test.fsx | 110 +++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/tests/fsharp/core/csext/test.fsx b/tests/fsharp/core/csext/test.fsx index 0fde4fd0d7b..f0844d7d563 100644 --- a/tests/fsharp/core/csext/test.fsx +++ b/tests/fsharp/core/csext/test.fsx @@ -55,6 +55,7 @@ type Struct(i:int) = #nowarn "3220" +// See https://github.com/Microsoft/visualfsharp/pull/3729 module TestsExplicitUseOfTupleProperties = // all give a warning, suppressed in this file let x1 = @@ -161,6 +162,115 @@ module TestsExplicitUseOfTupleProperties = printfn "%s" text check "vewjwervwver" text "PropertyGet (Some (PropertyGet (None, tup, [])), Item1, [])" +(* +// See https://github.com/Microsoft/visualfsharp/pull/3729, struct tuple access to Item* and Rest* are not supported +module TestsExplicitUseOfStructTupleProperties = + // all give a warning, suppressed in this file + let x1 = + [ (struct (1,2)).Item1 + (struct (1,2)).Item2 + (struct (1,2,3)).Item1 + (struct (1,2,3)).Item2 + (struct (1,2,3)).Item3 + (struct (1,2,3,4)).Item1 + (struct (1,2,3,4)).Item2 + (struct (1,2,3,4)).Item3 + (struct (1,2,3,4)).Item4 + (struct (1,2,3,4,5)).Item1 + (struct (1,2,3,4,5)).Item2 + (struct (1,2,3,4,5)).Item3 + (struct (1,2,3,4,5)).Item4 + (struct (1,2,3,4,5)).Item5 + (struct (1,2,3,4,5,6)).Item1 + (struct (1,2,3,4,5,6)).Item2 + (struct (1,2,3,4,5,6)).Item3 + (struct (1,2,3,4,5,6)).Item4 + (struct (1,2,3,4,5,6)).Item5 + (struct (1,2,3,4,5,6)).Item6 + (struct (1,2,3,4,5,6,7)).Item1 + (struct (1,2,3,4,5,6,7)).Item2 + (struct (1,2,3,4,5,6,7)).Item3 + (struct (1,2,3,4,5,6,7)).Item4 + (struct (1,2,3,4,5,6,7)).Item5 + (struct (1,2,3,4,5,6,7)).Item6 + (struct (1,2,3,4,5,6,7)).Item7 + (struct (1,2,3,4,5,6,7,8)).Item1 + (struct (1,2,3,4,5,6,7,8)).Item2 + (struct (1,2,3,4,5,6,7,8)).Item3 + (struct (1,2,3,4,5,6,7,8)).Item4 + (struct (1,2,3,4,5,6,7,8)).Item5 + (struct (1,2,3,4,5,6,7,8)).Item6 + (struct (1,2,3,4,5,6,7,8)).Item7 + (struct (1,2,3,4,5,6,7,8,9)).Item1 + (struct (1,2,3,4,5,6,7,8,9)).Item2 + (struct (1,2,3,4,5,6,7,8,9)).Item3 + (struct (1,2,3,4,5,6,7,8,9)).Item4 + (struct (1,2,3,4,5,6,7,8,9)).Item5 + (struct (1,2,3,4,5,6,7,8,9)).Item6 + (struct (1,2,3,4,5,6,7,8,9)).Item7 + (struct (1,2)).get_Item1() + (struct (1,2)).get_Item2() + (struct (1,2,3)).get_Item1() + (struct (1,2,3)).get_Item2() + (struct (1,2,3)).get_Item3() + (struct (1,2,3,4)).get_Item1() + (struct (1,2,3,4)).get_Item2() + (struct (1,2,3,4)).get_Item3() + (struct (1,2,3,4)).get_Item4() + (struct (1,2,3,4,5)).get_Item1() + (struct (1,2,3,4,5)).get_Item2() + (struct (1,2,3,4,5)).get_Item3() + (struct (1,2,3,4,5)).get_Item4() + (struct (1,2,3,4,5)).get_Item5() + (struct (1,2,3,4,5,6)).get_Item1() + (struct (1,2,3,4,5,6)).get_Item2() + (struct (1,2,3,4,5,6)).get_Item3() + (struct (1,2,3,4,5,6)).get_Item4() + (struct (1,2,3,4,5,6)).get_Item5() + (struct (1,2,3,4,5,6)).get_Item6() + (struct (1,2,3,4,5,6,7)).get_Item1() + (struct (1,2,3,4,5,6,7)).get_Item2() + (struct (1,2,3,4,5,6,7)).get_Item3() + (struct (1,2,3,4,5,6,7)).get_Item4() + (struct (1,2,3,4,5,6,7)).get_Item5() + (struct (1,2,3,4,5,6,7)).get_Item6() + (struct (1,2,3,4,5,6,7)).get_Item7() + (struct (1,2,3,4,5,6,7,8)).get_Item1() + (struct (1,2,3,4,5,6,7,8)).get_Item2() + (struct (1,2,3,4,5,6,7,8)).get_Item3() + (struct (1,2,3,4,5,6,7,8)).get_Item4() + (struct (1,2,3,4,5,6,7,8)).get_Item5() + (struct (1,2,3,4,5,6,7,8)).get_Item6() + (struct (1,2,3,4,5,6,7,8)).get_Item7() + (struct (1,2,3,4,5,6,7,8,9)).get_Item1() + (struct (1,2,3,4,5,6,7,8,9)).get_Item2() + (struct (1,2,3,4,5,6,7,8,9)).get_Item3() + (struct (1,2,3,4,5,6,7,8,9)).get_Item4() + (struct (1,2,3,4,5,6,7,8,9)).get_Item5() + (struct (1,2,3,4,5,6,7,8,9)).get_Item6() + (struct (1,2,3,4,5,6,7,8,9)).get_Item7() ] + + printfn "x1 = %A" x1 + check "vwhnwrvep01" x1 [1; 2; 1; 2; 3; 1; 2; 3; 4; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 6; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; + 1; 2; 1; 2; 3; 1; 2; 3; 4; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 6; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7] + + let x2 = (struct (1,2,3,4,5,6,7,8)).Rest // gives a warning, suppressed in this file + printfn "x2 = %A" x2 + check "vwhnwrvep02" x2 (System.Tuple(8)) + + let x3 = (struct (1,2,3,4,5,6,7,8,9)).Rest // gives a warning, suppressed in this file + printfn "x3 = %A" x3 + check "vwhnwrvep03" x3 (unbox (box (struct (8,9)))) + + // check a quotation of these + let tup = (struct (1,2)) + let x4 = <@ tup.Item1 @> + + let text = sprintf "%A" x4 + printfn "%s" text + check "vewjwervwver" text "PropertyGet (Some (PropertyGet (None, tup, [])), Item1, [])" +*) + (*--------------------*) #if TESTS_AS_APP From f32f9882d05661604582322a56709bf1033a0331 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 8 Dec 2017 19:56:42 +0000 Subject: [PATCH 03/17] proper return types for Rest, prototype ctors --- src/fsharp/InfoReader.fs | 141 ++++++++++++++------------ src/fsharp/NameResolution.fs | 5 +- src/fsharp/TastOps.fs | 38 +++++-- src/fsharp/TastOps.fsi | 20 ++++ src/fsharp/TcGlobals.fs | 28 +++-- src/fsharp/TypeChecker.fs | 2 +- src/fsharp/infos.fs | 36 +++---- src/fsharp/xlf/FSComp.txt.cs.xlf | 5 + src/fsharp/xlf/FSComp.txt.de.xlf | 5 + src/fsharp/xlf/FSComp.txt.en.xlf | 5 + src/fsharp/xlf/FSComp.txt.es.xlf | 5 + src/fsharp/xlf/FSComp.txt.fr.xlf | 5 + src/fsharp/xlf/FSComp.txt.it.xlf | 5 + src/fsharp/xlf/FSComp.txt.ja.xlf | 5 + src/fsharp/xlf/FSComp.txt.ko.xlf | 5 + src/fsharp/xlf/FSComp.txt.pl.xlf | 5 + src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 5 + src/fsharp/xlf/FSComp.txt.ru.xlf | 5 + src/fsharp/xlf/FSComp.txt.tr.xlf | 5 + src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 5 + tests/fsharp/core/csext/test.fsx | 33 ++++++ 22 files changed, 268 insertions(+), 105 deletions(-) diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index cf2300d6c2e..027c54a9044 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -4,6 +4,8 @@ /// Select members from a type by name, searching the type hierarchy if needed module internal Microsoft.FSharp.Compiler.InfoReader +open System.Collections.Generic + open Microsoft.FSharp.Compiler.AbstractIL.IL open Microsoft.FSharp.Compiler.AbstractIL.Internal open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library @@ -47,10 +49,10 @@ let TrySelectMemberVal g optFilter typ pri _membInfo (vref:ValRef) = else None -let rec GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTyp typ = - let minfos = +let rec GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTy metadataTy = - match metadataOfTy g typ with + let minfos = + match metadataOfTy g metadataTy with #if !NO_EXTENSIONTYPING | ProvidedTypeMetadata info -> let st = info.ProvidedType @@ -58,24 +60,25 @@ let rec GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTyp match optFilter with | Some name -> st.PApplyArray ((fun st -> st.GetMethods() |> Array.filter (fun mi -> mi.Name = name) ), "GetMethods", m) | None -> st.PApplyArray ((fun st -> st.GetMethods()), "GetMethods", m) - [ for mi in meths -> ProvidedMeth(amap,mi.Coerce(m),None,m) ] + [ for mi in meths -> ProvidedMeth(amap, mi.Coerce(m), None, m) ] #endif - | ILTypeMetadata (TILObjectReprData(_,_,tdef)) -> - let mdefs = tdef.Methods - let mdefs = (match optFilter with None -> mdefs.AsList | Some nm -> mdefs.FindByName nm) - mdefs |> List.map (fun mdef -> MethInfo.CreateILMeth(amap, m, origTyp, mdef)) + | ILTypeMetadata _ -> + let tinfo = ILTypeInfo.FromType g origTy + let mdefs = tinfo.RawMetadata.Methods + let mdefs = match optFilter with None -> mdefs.AsList | Some nm -> mdefs.FindByName nm + mdefs |> List.map (fun mdef -> MethInfo.CreateILMeth(amap, m, origTy, mdef)) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> // Tuple types also support the properties Item1-8, Rest from the compiled tuple type - if isAnyTupleTy g typ then - let (tupInfo, args) = destAnyTupleTy g typ - let compiledTy = mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args - GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTyp compiledTy + // In this case convert to the .NET Tuple type that carries metadata and try again + if isAnyTupleTy g metadataTy then + let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy + GetImmediateIntrinsicMethInfosOfTypeAux (optFilter,ad) g amap m origTy betterMetadataTy else - match tryDestAppTy g typ with + match tryDestAppTy g metadataTy with | None -> [] | Some tcref -> - SelectImmediateMemberVals g optFilter (TrySelectMemberVal g optFilter typ None) tcref + SelectImmediateMemberVals g optFilter (TrySelectMemberVal g optFilter origTy None) tcref let minfos = minfos |> List.filter (IsMethInfoAccessible amap m ad) minfos @@ -87,17 +90,17 @@ let GetImmediateIntrinsicMethInfosOfType (optFilter,ad) g amap m typ = /// A helper type to help collect properties. /// /// Join up getters and setters which are not associated in the F# data structure -type PropertyCollector(g,amap,m,typ,optFilter,ad) = +type PropertyCollector(g, amap, m, typ, optFilter, ad) = let hashIdentity = - Microsoft.FSharp.Collections.HashIdentity.FromFunctions + HashIdentity.FromFunctions (fun (pinfo:PropInfo) -> hash pinfo.PropertyName) (fun pinfo1 pinfo2 -> pinfo1.IsStatic = pinfo2.IsStatic && PropInfosEquivByNameAndPartialSig EraseNone g amap m pinfo1 pinfo2 && pinfo1.IsDefiniteFSharpOverride = pinfo2.IsDefiniteFSharpOverride ) - let props = new System.Collections.Generic.Dictionary(hashIdentity) + let props = new Dictionary(hashIdentity) let add pinfo = if props.ContainsKey(pinfo) then @@ -128,10 +131,10 @@ type PropertyCollector(g,amap,m,typ,optFilter,ad) = member x.Close() = [ for KeyValue(_,pinfo) in props -> pinfo ] -let rec GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTyp typ = +let rec GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTy metadataTy = let pinfos = - match metadataOfTy g typ with + match metadataOfTy g metadataTy with #if !NO_EXTENSIONTYPING | ProvidedTypeMetadata info -> let st = info.ProvidedType @@ -144,32 +147,29 @@ let rec GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTyp | None -> st.PApplyArray((fun st -> st.GetProperties()), "GetProperties", m) matchingProps - |> Seq.map(fun pi -> ProvidedProp(amap,pi,m)) + |> Seq.map(fun pi -> ProvidedProp(amap, pi, m)) |> List.ofSeq #endif - | ILTypeMetadata (TILObjectReprData(_,_,tdef)) -> - let tinfo = ILTypeInfo.FromType g origTyp - let pdefs = tdef.Properties + | ILTypeMetadata _ -> + let tinfo = ILTypeInfo.FromType g origTy + let pdefs = tinfo.RawMetadata.Properties let pdefs = match optFilter with None -> pdefs.AsList | Some nm -> pdefs.LookupByName nm - pdefs |> List.map (fun pd -> ILProp(g,ILPropInfo(tinfo,pd))) + pdefs |> List.map (fun pdef -> ILProp(g,ILPropInfo(tinfo, pdef))) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> - - match tryDestAppTy g typ with - | None -> - // Tuple types also support the properties Item1-8, Rest from the compiled tuple type - if isAnyTupleTy g typ then - let (tupInfo, args) = destAnyTupleTy g typ - GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m typ (mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args) - else - [] - | Some tcref -> - let propCollector = new PropertyCollector(g,amap,m,typ,optFilter,ad) - SelectImmediateMemberVals g None - (fun membInfo vref -> propCollector.Collect(membInfo,vref); None) - tcref |> ignore - propCollector.Close() + // Tuple types also support the properties Item1-8, Rest from the compiled tuple type + // In this case convert to the .NET Tuple type that carries metadata and try again + if isAnyTupleTy g metadataTy then + let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy + GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTy betterMetadataTy + else + match tryDestAppTy g metadataTy with + | None -> [] + | Some tcref -> + let propCollector = new PropertyCollector(g, amap, m, origTy, optFilter, ad) + SelectImmediateMemberVals g None (fun membInfo vref -> propCollector.Collect(membInfo, vref); None) tcref |> ignore + propCollector.Close() let pinfos = pinfos |> List.filter (IsPropInfoAccessible g amap m ad) pinfos @@ -188,7 +188,7 @@ let IsIndexerType g amap typ = let _, entityTy = generalizeTyconRef tcref let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) g amap range0 entityTy props |> List.exists (fun x -> x.PropertyName = "Item") - | _ -> false + | None -> false /// Sets of methods up the hierarchy, ignoring duplicates by name and sig. @@ -203,10 +203,10 @@ type HierarchyItem = /// An InfoReader is an object to help us read and cache infos. /// We create one of these for each file we typecheck. -type InfoReader(g:TcGlobals, amap:Import.ImportMap) = +type InfoReader(g: TcGlobals, amap: Import.ImportMap) = /// Get the declared IL fields of a type, not including inherited fields - let GetImmediateIntrinsicILFieldsOfType (optFilter,ad) m typ = + let GetImmediateIntrinsicILFieldsOfType (optFilter, ad) m typ = let infos = match metadataOfTy g typ with #if !NO_EXTENSIONTYPING @@ -220,9 +220,9 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = | Tainted.Null -> [] | fi -> [ ProvidedField(amap,fi,m) ] #endif - | ILTypeMetadata (TILObjectReprData(_,_,tdef)) -> + | ILTypeMetadata _ -> let tinfo = ILTypeInfo.FromType g typ - let fdefs = tdef.Fields + let fdefs = tinfo.RawMetadata.Fields let fdefs = match optFilter with None -> fdefs.AsList | Some nm -> fdefs.LookupByName nm fdefs |> List.map (fun pd -> ILFieldInfo(tinfo,pd)) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> @@ -230,8 +230,8 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = let infos = infos |> List.filter (IsILFieldInfoAccessible g amap m ad) infos - /// Get the declared events of a type, not including inherited events - let ComputeImmediateIntrinsicEventsOfType (optFilter,ad) m typ = + /// Get the declared events of a type, not including inherited events, and not including F#-declared CLIEvents + let ComputeImmediateIntrinsicEventsOfType (optFilter, ad) m typ = let infos = match metadataOfTy g typ with #if !NO_EXTENSIONTYPING @@ -245,9 +245,9 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = | Tainted.Null -> [] | ei -> [ ProvidedEvent(amap,ei,m) ] #endif - | ILTypeMetadata (TILObjectReprData(_,_,tdef)) -> + | ILTypeMetadata _ -> let tinfo = ILTypeInfo.FromType g typ - let edefs = tdef.Events + let edefs = tinfo.RawMetadata.Events let edefs = match optFilter with None -> edefs.AsList | Some nm -> edefs.LookupByName nm [ for edef in edefs do let einfo = ILEventInfo(tinfo,edef) @@ -262,7 +262,7 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = RecdFieldInfo(argsOfAppTy g typ,tcref.MakeNestedRecdFieldRef fspec) /// Get the F#-declared record fields or class 'val' fields of a type - let GetImmediateIntrinsicRecdOrClassFieldsOfType (optFilter,_ad) _m typ = + let GetImmediateIntrinsicRecdOrClassFieldsOfType (optFilter, _ad) _m typ = match tryDestAppTy g typ with | None -> [] | Some tcref -> @@ -439,17 +439,13 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = primaryTypeHierarchyCache.Apply((allowMultiIntfInst,m,typ)) -//------------------------------------------------------------------------- -// Constructor infos - - /// Get the declared constructors of any F# type -let GetIntrinsicConstructorInfosOfType (infoReader:InfoReader) m ty = +let rec GetIntrinsicConstructorInfosOfTypeAux (infoReader:InfoReader) m origTy metadataTy = protectAssemblyExploration [] (fun () -> let g = infoReader.g let amap = infoReader.amap - if isAppTy g ty then - match metadataOfTy g ty with + if isAppTy g metadataTy then + match metadataOfTy g metadataTy with #if !NO_EXTENSIONTYPING | ProvidedTypeMetadata info -> let st = info.ProvidedType @@ -457,23 +453,36 @@ let GetIntrinsicConstructorInfosOfType (infoReader:InfoReader) m ty = yield ProvidedMeth(amap,ci.Coerce(m),None,m) ] #endif | ILTypeMetadata _ -> - let tinfo = ILTypeInfo.FromType g ty + let tinfo = ILTypeInfo.FromType g origTy tinfo.RawMetadata.Methods.FindByName ".ctor" |> List.filter (fun md -> match md.mdKind with MethodKind.Ctor -> true | _ -> false) - |> List.map (fun mdef -> MethInfo.CreateILMeth (amap, m, ty, mdef)) + |> List.map (fun mdef -> MethInfo.CreateILMeth (amap, m, origTy, mdef)) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> - let tcref = tcrefOfAppTy g ty - tcref.MembersOfFSharpTyconByName - |> NameMultiMap.find ".ctor" - |> List.choose(fun vref -> - match vref.MemberInfo with - | Some membInfo when (membInfo.MemberFlags.MemberKind = MemberKind.Constructor) -> Some vref - | _ -> None) - |> List.map (fun x -> FSMeth(g,ty,x,None)) + // Tuple types also support the properties Item1-8, Rest from the compiled tuple type + // In this case convert to the .NET Tuple type that carries metadata and try again + if isAnyTupleTy g metadataTy then + let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy + GetIntrinsicConstructorInfosOfTypeAux infoReader m origTy betterMetadataTy + else + match tryDestAppTy g metadataTy with + | None -> [] + | Some tcref -> + tcref.MembersOfFSharpTyconByName + |> NameMultiMap.find ".ctor" + |> List.choose(fun vref -> + match vref.MemberInfo with + | Some membInfo when (membInfo.MemberFlags.MemberKind = MemberKind.Constructor) -> Some vref + | _ -> None) + |> List.map (fun x -> FSMeth(g, origTy, x, None)) else [] ) +let GetIntrinsicConstructorInfosOfType infoReader m typ = + GetIntrinsicConstructorInfosOfTypeAux infoReader m typ typ + + + //------------------------------------------------------------------------- // Collecting methods and properties taking into account hiding rules in the hierarchy diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 6707b93dcab..e5ba3017d97 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -1841,11 +1841,12 @@ let private ResolveObjectConstructorPrim (ncenv:NameResolver) edenv resInfo m ad then [DefaultStructCtor(g,typ)] else [] - if (isNil defaultStructCtorInfo && isNil ctorInfos) || not (isAppTy g typ) then + if (isNil defaultStructCtorInfo && isNil ctorInfos) || (not (isAppTy g typ) && not (isAnyTupleTy g typ)) then raze (Error(FSComp.SR.nrNoConstructorsAvailableForType(NicePrint.minimalStringOfType edenv typ),m)) else let ctorInfos = ctorInfos |> List.filter (IsMethInfoAccessible amap m ad) - success (resInfo,Item.MakeCtorGroup ((tcrefOfAppTy g typ).LogicalName, (defaultStructCtorInfo@ctorInfos))) + let metadataTy = helpEnsureTypeHasMetadata g typ + success (resInfo,Item.MakeCtorGroup ((tcrefOfAppTy g metadataTy).LogicalName, (defaultStructCtorInfo@ctorInfos))) /// Perform name resolution for an identifier which must resolve to be an object constructor. let ResolveObjectConstructor (ncenv:NameResolver) edenv m ad typ = diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index d2d378508de..39bae69e436 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -601,13 +601,32 @@ let mkCompiledTupleTyconRef (g:TcGlobals) isStruct n = elif n = 8 then (if isStruct then g.struct_tuple8_tcr else g.ref_tuple8_tcr) else failwithf "mkCompiledTupleTyconRef, n = %d" n -let rec mkCompiledTupleTy g isStruct tys = - let n = List.length tys - if n < maxTuple then TType_app (mkCompiledTupleTyconRef g isStruct n, tys) +/// Convert from F# tuple types to .NET tuple types +let rec mkCompiledTupleTy g isStruct tupElemTys = + let n = List.length tupElemTys + if n < maxTuple then + TType_app (mkCompiledTupleTyconRef g isStruct n, tupElemTys) else - let tysA, tysB = List.splitAfter goodTupleFields tys + let tysA, tysB = List.splitAfter goodTupleFields tupElemTys TType_app ((if isStruct then g.struct_tuple8_tcr else g.ref_tuple8_tcr), tysA@[mkCompiledTupleTy g isStruct tysB]) +/// Convert from F# tuple types to .NET tuple types, but only the outermost level +let mkOuterCompiledTupleTy g isStruct tupElemTys = + let n = List.length tupElemTys + if n < maxTuple then + TType_app (mkCompiledTupleTyconRef g isStruct n, tupElemTys) + else + let tysA, tysB = List.splitAfter goodTupleFields tupElemTys + let tcref = (if isStruct then g.struct_tuple8_tcr else g.ref_tuple8_tcr) + // In the case of an 8-tuple we add the Tuple<_> marker. For other sizes we keep the type + // as a regular F# tuple type. + match tysB with + | [ tyB ] -> + let marker = TType_app (mkCompiledTupleTyconRef g isStruct 1, [tyB]) + TType_app (tcref, tysA@[marker]) + | _ -> + TType_app (tcref, tysA@[TType_tuple (TupInfo.Const isStruct, tysB)]) + //--------------------------------------------------------------------------- // Remove inference equations and abbreviations from types //--------------------------------------------------------------------------- @@ -768,8 +787,15 @@ let mkInstForAppTy g typ = | AppTy g (tcref, tinst) -> mkTyconRefInst tcref tinst | _ -> [] -let domainOfFunTy g ty = fst(destFunTy g ty) -let rangeOfFunTy g ty = snd(destFunTy g ty) +let domainOfFunTy g ty = fst (destFunTy g ty) +let rangeOfFunTy g ty = snd (destFunTy g ty) + +let helpEnsureTypeHasMetadata g ty = + if isAnyTupleTy g ty then + let (tupInfo, tupElemTys) = destAnyTupleTy g ty + mkOuterCompiledTupleTy g (evalTupInfoIsStruct tupInfo) tupElemTys + else ty + //--------------------------------------------------------------------------- // Equivalence of types up to alpha-equivalence diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index 04410eae1c1..467be96cddd 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -224,16 +224,36 @@ val mkArrayElemAddress : TcGlobals -> ILReadonly * bool * ILArrayShape * TType * // Compiled view of tuples //------------------------------------------------------------------------- +/// The largest tuple before we start encoding, i.e. 7 val maxTuple : int + +/// The number of fields in the largest tuple before we start encoding, i.e. 7 val goodTupleFields : int + +/// Check if a TyconRef is for a .NET tuple type. Currently this includes Tuple`1 even though +/// that' not really part of the target set of TyconRef used to represent F# tuples. val isCompiledTupleTyconRef : TcGlobals -> TyconRef -> bool + +/// Get a TyconRef for a .NET tuple type val mkCompiledTupleTyconRef : TcGlobals -> bool -> int -> TyconRef + +/// Convert from F# tuple types to .NET tuple types. val mkCompiledTupleTy : TcGlobals -> bool -> TTypes -> TType + +/// Convert from F# tuple creation expression to .NET tuple creation expressions val mkCompiledTuple : TcGlobals -> bool -> TTypes * Exprs * range -> TyconRef * TTypes * Exprs * range + +/// Make a TAST expression representing getting an item fromm a tuple val mkGetTupleItemN : TcGlobals -> range -> int -> ILType -> bool -> Expr -> TType -> Expr +/// Evaluate the TupInfo to work out if it is a struct or a ref. Currently this is very simple +/// but TupInfo may later be used carry variables that infer structness. val evalTupInfoIsStruct : TupInfo -> bool +/// If it is a tuple type, ensure it's outermost type is a .NET tuple type, otherwise leave unchanged +val helpEnsureTypeHasMetadata : TcGlobals -> TType -> TType + + //------------------------------------------------------------------------- // Take the address of an expression, or force it into a mutable local. Any allocated // mutable local may need to be kept alive over a larger expression, hence we return diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index 0e126f3469b..10e3cd31a74 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -463,17 +463,29 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d yield nleref.LastItemMangledName, ERefNonLocal nleref ] - let decodeTupleTy tupInfo l = + let tryDecodeTupleTy tupInfo l = match l with | [t1;t2;t3;t4;t5;t6;t7;marker] -> match marker with - | TType_app(tcref, [t8]) when tyconRefEq tcref v_ref_tuple1_tcr -> mkRawRefTupleTy [t1;t2;t3;t4;t5;t6;t7;t8] - | TType_app(tcref, [t8]) when tyconRefEq tcref v_struct_tuple1_tcr -> mkRawStructTupleTy [t1;t2;t3;t4;t5;t6;t7;t8] - | TType_tuple (_structness2, t8plus) -> TType_tuple (tupInfo, [t1;t2;t3;t4;t5;t6;t7] @ t8plus) - | _ -> TType_tuple (tupInfo, l) - | _ -> TType_tuple (tupInfo, l) + | TType_app(tcref, [t8]) when tyconRefEq tcref v_ref_tuple1_tcr -> mkRawRefTupleTy [t1;t2;t3;t4;t5;t6;t7;t8] |> Some + | TType_app(tcref, [t8]) when tyconRefEq tcref v_struct_tuple1_tcr -> mkRawStructTupleTy [t1;t2;t3;t4;t5;t6;t7;t8] |> Some + | TType_tuple (_structness2, t8plus) -> TType_tuple (tupInfo, [t1;t2;t3;t4;t5;t6;t7] @ t8plus) |> Some + | _ -> None + | [] -> None + | [_] -> None + | _ -> TType_tuple (tupInfo, l) |> Some + let decodeTupleTy tupInfo l = + match tryDecodeTupleTy tupInfo l with + | Some ty -> ty + | None -> failwith "couldn't decode tuple ty" + + let decodeTupleTyIfPossible tcref tupInfo l = + match tryDecodeTupleTy tupInfo l with + | Some ty -> ty + | None -> TType_app(tcref, l) + let mk_MFCore_attrib nm : BuiltinAttribInfo = AttribInfo(mkILTyRef(IlxSettings.ilxFsharpCoreLibScopeRef (), FSharpLib.Core + "." + nm), mk_MFCore_tcref fslibCcu nm) @@ -705,14 +717,14 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d "Tuple`5" , v_ref_tuple5_tcr , decodeTupleTy tupInfoRef "Tuple`6" , v_ref_tuple6_tcr , decodeTupleTy tupInfoRef "Tuple`7" , v_ref_tuple7_tcr , decodeTupleTy tupInfoRef - "Tuple`8" , v_ref_tuple8_tcr , decodeTupleTy tupInfoRef + "Tuple`8" , v_ref_tuple8_tcr , decodeTupleTyIfPossible v_ref_tuple8_tcr tupInfoRef "ValueTuple`2" , v_struct_tuple2_tcr , decodeTupleTy tupInfoStruct "ValueTuple`3" , v_struct_tuple3_tcr , decodeTupleTy tupInfoStruct "ValueTuple`4" , v_struct_tuple4_tcr , decodeTupleTy tupInfoStruct "ValueTuple`5" , v_struct_tuple5_tcr , decodeTupleTy tupInfoStruct "ValueTuple`6" , v_struct_tuple6_tcr , decodeTupleTy tupInfoStruct "ValueTuple`7" , v_struct_tuple7_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`8" , v_struct_tuple8_tcr , decodeTupleTy tupInfoStruct |] + "ValueTuple`8" , v_struct_tuple8_tcr , decodeTupleTyIfPossible v_struct_tuple8_tcr tupInfoStruct |] // Build a map that uses the "canonical" F# type names and TyconRef's for these // in preference to the .NET type names. Doing this normalization is a fairly performance critical diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index e15e31e22c9..dd34af48ce8 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -6258,7 +6258,7 @@ and TcNewExpr cenv env tpenv objTy mObjTyOpt superInit arg mWholeExprOrObjTy = mkCallCreateInstance cenv.g mWholeExprOrObjTy objTy , tpenv else - if not (isAppTy cenv.g objTy) then error(Error(FSComp.SR.tcNamedTypeRequired(if superInit then "inherit" else "new"), mWholeExprOrObjTy)) + if not (isAppTy cenv.g objTy) && not (isAnyTupleTy cenv.g objTy) then error(Error(FSComp.SR.tcNamedTypeRequired(if superInit then "inherit" else "new"), mWholeExprOrObjTy)) let item = ForceRaise (ResolveObjectConstructor cenv.nameResolver env.DisplayEnv mWholeExprOrObjTy ad objTy) TcCtorCall false cenv env tpenv objTy objTy mObjTyOpt item superInit [arg] mWholeExprOrObjTy [] None diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index c9624dcd9f3..5a3eab6abf9 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -668,12 +668,10 @@ type ILTypeInfo = member x.TcGlobals = let (ILTypeInfo(g,_,_,_)) = x in g member x.ILTypeRef = let (ILTypeInfo(_,_,tref,_)) = x in tref + /// Get the compiled nominal type. In the case of tuple types, this is a .NET tuple type member x.RawType = - let (ILTypeInfo(g,ty,_,_)) = x - if isAnyTupleTy g ty then - let (tupInfo, args) = destAnyTupleTy g ty - mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args - else ty + let (ILTypeInfo(g, ty, _, _)) = x + helpEnsureTypeHasMetadata g ty member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.RawType member x.TypeInstOfRawMetadata = argsOfAppTy x.TcGlobals x.RawType @@ -687,23 +685,21 @@ type ILTypeInfo = let (ILTypeInfo(g,ty,tref,tdef)) = x ILTypeInfo(g,instType inst ty,tref,tdef) - //member x.FormalTypars m = x.TyconRef.Typars m - static member FromType g ty = if isAnyTupleTy g ty then - let (tupInfo, args) = destAnyTupleTy g ty - let compiledTy = mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args - assert (isILAppTy g compiledTy) - let compiledTyconRef = tcrefOfAppTy g compiledTy - let (TILObjectReprData(scoref,enc,tdef)) = compiledTyconRef.ILTyconInfo - let compiledILTypeRef = mkRefForNestedILTypeDef scoref (enc,tdef) - ILTypeInfo(g,ty,compiledILTypeRef,tdef) - + // When getting .NET metadata for the properties and methods + // of an F# tuple type, use the compiled nominal type, which is a .NET tuple type + let metadataTy = helpEnsureTypeHasMetadata g ty + assert (isILAppTy g metadataTy) + let metadataTyconRef = tcrefOfAppTy g metadataTy + let (TILObjectReprData(scoref, enc, tdef)) = metadataTyconRef.ILTyconInfo + let metadataILTypeRef = mkRefForNestedILTypeDef scoref (enc,tdef) + ILTypeInfo(g, ty, metadataILTypeRef, tdef) elif isILAppTy g ty then let tcref = tcrefOfAppTy g ty - let (TILObjectReprData(scoref,enc,tdef)) = tcref.ILTyconInfo + let (TILObjectReprData(scoref, enc, tdef)) = tcref.ILTyconInfo let tref = mkRefForNestedILTypeDef scoref (enc,tdef) - ILTypeInfo(g,ty,tref,tdef) + ILTypeInfo(g, ty, tref, tdef) else failwith "ILTypeInfo.FromType - no IL metadata for type" @@ -731,12 +727,8 @@ type ILMethInfo = /// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type member x.ApparentEnclosingAppType = - let g = x.TcGlobals let enclTy = x.ApparentEnclosingType - if isAnyTupleTy g enclTy then - let (tupInfo, args) = destAnyTupleTy g enclTy - mkCompiledTupleTy g (evalTupInfoIsStruct tupInfo) args - else enclTy + helpEnsureTypeHasMetadata x.TcGlobals enclTy /// Get the declaring type associated with an extension member, if any. member x.DeclaringTyconRefOption = match x with ILMethInfo(_,_,tcrefOpt,_,_) -> tcrefOpt diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index de8bf468100..78dcb548db5 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -6972,6 +6972,11 @@ Při čtení metadat jazyka F# sestavení {0} došlo k chybě. Byl použit rezervovaný konstruktor. Je možné, že budete muset upgradovat kompilátor jazyka F# nebo použít dřívější verzi sestavení, ve které se nevyužívá konkrétní konstruktor. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 3a13f33959c..3fc1034614e 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -6972,6 +6972,11 @@ Fehler beim Lesen der F#-Metadaten der Assembly "{0}". Es wurde ein reserviertes Konstrukt verwendet. Möglicherweise müssen Sie Ihren F#-Compiler aktualisieren oder eine frühere Version der Assembly verwenden, die dieses spezielle Konstrukt nicht verwendet. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.en.xlf b/src/fsharp/xlf/FSComp.txt.en.xlf index f5c18a3b87b..a276aa47c9b 100644 --- a/src/fsharp/xlf/FSComp.txt.en.xlf +++ b/src/fsharp/xlf/FSComp.txt.en.xlf @@ -6972,6 +6972,11 @@ An error occurred while reading the F# metadata of assembly '{0}'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index afaf6c1ebfe..96ae04ba8ed 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -6972,6 +6972,11 @@ Se produjo un error al leer los metadatos de F# del ensamblado "{0}". Se utilizó una construcción reservada. Puede que deba actualizar su compilador de F# o usar una versión anterior del ensamblado que no haga uso de una construcción específica. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index ebdba5245de..d672068051c 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -6972,6 +6972,11 @@ Une erreur s'est produite durant la lecture des métadonnées F# de l'assembly '{0}'. Une construction réservée a été utilisée. Vous devrez peut-être mettre à niveau votre compilateur F# ou utiliser une version antérieure de l'assembly qui ne fait pas appel à une construction spécifique. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index 1e0008d8c36..5ae73d1a685 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -6972,6 +6972,11 @@ Si è verificato un errore durante la lettura dei metadati F# dell'assembly '{0}'. È stato utilizzato un costrutto riservato. Potrebbe essere necessario aggiornare il compilatore F# o usare una versione precedente dell'assembly che non usa un costrutto specifico. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 7ee529aa044..f6adf03d258 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -6972,6 +6972,11 @@ アセンブリ '{0}' の F# メタデータ の読み取り中にエラーが発生しました。予約済みのコンストラクトが使用されました。F# コンパイラをアップグレードするか、特定のコンストラクトを使用しない以前のバージョンのアセンブリを使用しなければならない場合があります。 + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index 6a34595756d..0502c70e49b 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -6972,6 +6972,11 @@ '{0}' 어셈블리의 F# 메타데이터를 읽는 동안 오류가 발생했습니다. 예약 구문이 활용되었습니다. F# 컴파일러를 업그레이드하거나 특정 구문을 사용하지 않는 이전 버전의 어셈블리를 사용해야 할 수 있습니다. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index 79bf19d683b..dd4b7e09cdf 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -6972,6 +6972,11 @@ Wystąpił błąd podczas odczytu metadanych języka F# z zestawu „{0}”. Została wykorzystana zarezerwowana konstrukcja. Może być konieczne uaktualnienie kompilatora języka F# lub użycie wcześniejszej wersji zestawu, która nie wykorzystuje określonej konstrukcji. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index 715e740ab55..080954e8dee 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -6972,6 +6972,11 @@ Ocorreu um erro ao ler os metadados F# do assembly '{0}'. Foi utilizada um constructo reservado. Talvez seja necessário atualizar seu compilador F# ou usar uma versão anterior do assembly que não faça uso de um constructo específico. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 90e2725ef11..fabe259d330 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -6972,6 +6972,11 @@ Произошла ошибка при чтении метаданных F# сборки "{0}". Использовалась зарезервированная конструкция. Попробуйте обновить компилятор F# или применить более раннюю версию сборки, где конкретная конструкция не используется. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index 89d204b8abf..1a11b56767f 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -6972,6 +6972,11 @@ '{0}' bütünleştirilmiş kodunun F# meta verileri okunurken bir hata oluştu. Ayrılmış bir yapı kullanıldı. F# derleyicinizi yükseltmeniz veya bütünleştirilmiş kodun belirli bir yapıyı kullanmayan daha eski bir sürümünü kullanmanız gerekebilir. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 4a4016667fc..e033c2b7f8e 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -6972,6 +6972,11 @@ 读取程序集“{0}”的 F# 元数据时出错。使用了保留的构造。可能需要升级 F# 编译器或使用不用特定构造的较早版本的程序集。 + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 5fb95d7efab..1518b939718 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -6972,6 +6972,11 @@ 讀取組件 '{0}' 的 F# 中繼資料時發生錯誤。已使用保留的建構。建議您升級 F# 編譯器,或使用不會用特定建構的舊版組件。 + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + + \ No newline at end of file diff --git a/tests/fsharp/core/csext/test.fsx b/tests/fsharp/core/csext/test.fsx index f0844d7d563..5fe3fe2bce6 100644 --- a/tests/fsharp/core/csext/test.fsx +++ b/tests/fsharp/core/csext/test.fsx @@ -271,6 +271,39 @@ module TestsExplicitUseOfStructTupleProperties = check "vewjwervwver" text "PropertyGet (Some (PropertyGet (None, tup, [])), Item1, [])" *) +(* +module TupleCtors = + let t1 x = new System.Tuple<_>(x) + let t2 (x1,x2) = new System.Tuple<_,_>(x1,x2) + let t3 (x1,x2,x3) = new System.Tuple<_,_,_>(x1,x2,x3) + let t4 (x1,x2,x3,x4) = new System.Tuple<_,_,_,_>(x1,x2,x3,x4) + let t5 (x1,x2,x3,x4,x5) = new System.Tuple<_,_,_,_,_>(x1,x2,x3,x4,x5) + let t6 (x1,x2,x3,x4,x5,x6) = new System.Tuple<_,_,_,_,_,_>(x1,x2,x3,x4,x5,x6) + let t7 (x1,x2,x3,x4,x5,x6,x7) = new System.Tuple<_,_,_,_,_,_,_>(x1,x2,x3,x4,x5,x6,x7) + let cp (x1,x2,x3,x4,x5,x6,x7) t = new System.Tuple<_,_,_,_,_,_,_,_>(x1,x2,x3,x4,x5,x6,x7, t) + +module TupleSRTP = + let t1 x = new System.Tuple<_>(x) + let t2 (x1,x2) = new System.Tuple<_,_>(x1,x2) + let t3 (x1,x2,x3) = new System.Tuple<_,_,_>(x1,x2,x3) + let t4 (x1,x2,x3,x4) = new System.Tuple<_,_,_,_>(x1,x2,x3,x4) + let t5 (x1,x2,x3,x4,x5) = new System.Tuple<_,_,_,_,_>(x1,x2,x3,x4,x5) + let t6 (x1,x2,x3,x4,x5,x6) = new System.Tuple<_,_,_,_,_,_>(x1,x2,x3,x4,x5,x6) + let t7 (x1,x2,x3,x4,x5,x6,x7) = new System.Tuple<_,_,_,_,_,_,_>(x1,x2,x3,x4,x5,x6,x7) + let cp (x1,x2,x3,x4,x5,x6,x7) t = new System.Tuple<_,_,_,_,_,_,_,_>(x1,x2,x3,x4,x5,x6,x7, t) + + type T = T with + static member inline ($) (T, t:System.Tuple<_,_,_,_,_,_,_,'rst>) = fun x -> cp (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5,t.Item6) ((T $ t.Rest) t.Item7) + static member ($) (T, ()) = fun x -> t1 (x) + static member ($) (T, t:System.Tuple<_>) = fun x -> t2 (x,t.Item1) + static member ($) (T, t:System.Tuple<_,_>) = fun x -> t3 (x,t.Item1, t.Item2) + static member ($) (T, t:System.Tuple<_,_,_>) = fun x -> t4 (x,t.Item1, t.Item2,t.Item3) + static member ($) (T, t:System.Tuple<_,_,_,_>) = fun x -> t5 (x,t.Item1, t.Item2,t.Item3,t.Item4) + static member ($) (T, t:System.Tuple<_,_,_,_,_>) = fun x -> t6 (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5) + static member ($) (T, t:System.Tuple<_,_,_,_,_,_>) = fun x -> t7 (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5,t.Item6) + static member ($) (T, t:System.Tuple<_,_,_,_,_,_,_>) = fun x -> cp (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5,t.Item6) (t1(t.Item7)) +*) + (*--------------------*) #if TESTS_AS_APP From 03523a1c51496a3db05da6ebe11f081dace335f0 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 8 Dec 2017 21:38:33 +0000 Subject: [PATCH 04/17] fix SRTP --- .../FSharp.Compiler.Private/FSComp.fs | 4 ++ .../FSharp.Compiler.Private/FSComp.resx | 3 + src/fsharp/ConstraintSolver.fs | 9 +-- src/fsharp/InfoReader.fs | 58 +++++++++---------- src/fsharp/NameResolution.fs | 5 +- src/fsharp/TcGlobals.fs | 7 +++ src/fsharp/TypeChecker.fs | 7 +-- tests/fsharp/core/csext/test.fsx | 17 ++++-- 8 files changed, 65 insertions(+), 45 deletions(-) diff --git a/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs b/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs index abc321272d5..9f35b8006a9 100644 --- a/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs +++ b/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs @@ -4300,6 +4300,9 @@ type internal SR private() = /// An error occurred while reading the F# metadata of assembly '%s'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct. /// (Originally from ..\FSComp.txt:1424) static member pickleUnexpectedNonZero(a0 : System.String) = (3219, GetStringFunc("pickleUnexpectedNonZero",",,,%s,,,") a0) + /// This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + /// (Originally from ..\FSComp.txt:1425) + static member tcTupleMemberNotNormallyUsed() = (3220, GetStringFunc("tcTupleMemberNotNormallyUsed",",,,") ) /// Call this method once to validate that all known resources are valid; throws if not static member RunStartupValidation() = @@ -5698,4 +5701,5 @@ type internal SR private() = ignore(GetString("notAFunctionButMaybeDeclaration")) ignore(GetString("ArgumentsInSigAndImplMismatch")) ignore(GetString("pickleUnexpectedNonZero")) + ignore(GetString("tcTupleMemberNotNormallyUsed")) () diff --git a/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx b/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx index 71f965fc9fa..9a392ccdc11 100644 --- a/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx +++ b/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx @@ -4303,4 +4303,7 @@ An error occurred while reading the F# metadata of assembly '{0}'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct. + + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + \ No newline at end of file diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index 0ec8f9f832a..afe3a33c909 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -2606,15 +2606,16 @@ let CodegenWitnessThatTypSupportsTraitConstraint tcVal g amap m (traitInfo:Trait | None -> Choice4Of4() | Some sln -> match sln with - | ILMethSln(typ, extOpt, mref, minst) -> - let tcref, _tinst = destAppTy g typ + | ILMethSln(origTy, extOpt, mref, minst) -> + let metadataTy = helpEnsureTypeHasMetadata g origTy + let tcref, _tinst = destAppTy g metadataTy let mdef = IL.resolveILMethodRef tcref.ILTyconRawMetadata mref let ilMethInfo = match extOpt with - | None -> MethInfo.CreateILMeth(amap, m, typ, mdef) + | None -> MethInfo.CreateILMeth(amap, m, origTy, mdef) | Some ilActualTypeRef -> let actualTyconRef = Import.ImportILTypeRef amap m ilActualTypeRef - MethInfo.CreateILExtensionMeth(amap, m, typ, actualTyconRef, None, mdef) + MethInfo.CreateILExtensionMeth(amap, m, origTy, actualTyconRef, None, mdef) Choice1Of4 (ilMethInfo, minst) | FSMethSln(typ, vref, minst) -> Choice1Of4 (FSMeth(g, typ, vref, None), minst) diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index 027c54a9044..52fe48d0cd7 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -444,38 +444,36 @@ let rec GetIntrinsicConstructorInfosOfTypeAux (infoReader:InfoReader) m origTy m protectAssemblyExploration [] (fun () -> let g = infoReader.g let amap = infoReader.amap - if isAppTy g metadataTy then - match metadataOfTy g metadataTy with + match metadataOfTy g metadataTy with #if !NO_EXTENSIONTYPING - | ProvidedTypeMetadata info -> - let st = info.ProvidedType - [ for ci in st.PApplyArray((fun st -> st.GetConstructors()), "GetConstructors", m) do - yield ProvidedMeth(amap,ci.Coerce(m),None,m) ] + | ProvidedTypeMetadata info -> + let st = info.ProvidedType + [ for ci in st.PApplyArray((fun st -> st.GetConstructors()), "GetConstructors", m) do + yield ProvidedMeth(amap,ci.Coerce(m),None,m) ] #endif - | ILTypeMetadata _ -> - let tinfo = ILTypeInfo.FromType g origTy - tinfo.RawMetadata.Methods.FindByName ".ctor" - |> List.filter (fun md -> match md.mdKind with MethodKind.Ctor -> true | _ -> false) - |> List.map (fun mdef -> MethInfo.CreateILMeth (amap, m, origTy, mdef)) - - | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> - // Tuple types also support the properties Item1-8, Rest from the compiled tuple type - // In this case convert to the .NET Tuple type that carries metadata and try again - if isAnyTupleTy g metadataTy then - let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy - GetIntrinsicConstructorInfosOfTypeAux infoReader m origTy betterMetadataTy - else - match tryDestAppTy g metadataTy with - | None -> [] - | Some tcref -> - tcref.MembersOfFSharpTyconByName - |> NameMultiMap.find ".ctor" - |> List.choose(fun vref -> - match vref.MemberInfo with - | Some membInfo when (membInfo.MemberFlags.MemberKind = MemberKind.Constructor) -> Some vref - | _ -> None) - |> List.map (fun x -> FSMeth(g, origTy, x, None)) - else [] + | ILTypeMetadata _ -> + let tinfo = ILTypeInfo.FromType g origTy + tinfo.RawMetadata.Methods.FindByName ".ctor" + |> List.filter (fun md -> match md.mdKind with MethodKind.Ctor -> true | _ -> false) + |> List.map (fun mdef -> MethInfo.CreateILMeth (amap, m, origTy, mdef)) + + | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> + // Tuple types also support the properties Item1-8, Rest from the compiled tuple type + // In this case convert to the .NET Tuple type that carries metadata and try again + if isAnyTupleTy g metadataTy then + let betterMetadataTy = helpEnsureTypeHasMetadata g metadataTy + GetIntrinsicConstructorInfosOfTypeAux infoReader m origTy betterMetadataTy + else + match tryDestAppTy g metadataTy with + | None -> [] + | Some tcref -> + tcref.MembersOfFSharpTyconByName + |> NameMultiMap.find ".ctor" + |> List.choose(fun vref -> + match vref.MemberInfo with + | Some membInfo when (membInfo.MemberFlags.MemberKind = MemberKind.Constructor) -> Some vref + | _ -> None) + |> List.map (fun x -> FSMeth(g, origTy, x, None)) ) let GetIntrinsicConstructorInfosOfType infoReader m typ = diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index e5ba3017d97..278291ce758 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -855,7 +855,8 @@ let AddDeclaredTyparsToNameEnv check nenv typars = /// a fresh set of inference type variables for the type parameters of the union type. let FreshenTycon (ncenv: NameResolver) m (tcref:TyconRef) = let tinst = ncenv.InstantiationGenerator m (tcref.Typars m) - TType_app(tcref,tinst) + let improvedTy = ncenv.g.decompileType tcref tinst + improvedTy /// Convert a reference to a union case into a UnionCaseInfo that includes /// a fresh set of inference type variables for the type parameters of the union type. @@ -2229,7 +2230,7 @@ let rec ResolveExprLongIdentInModuleOrNamespace (ncenv:NameResolver) nenv (typeN match typeNameResInfo.ResolutionFlag with | ResolveTypeNamesToTypeRefs -> success [ for (resInfo,tcref) in tcrefs do - let typ = FreshenTycon ncenv m tcref + let typ = FreshenTycon ncenv m tcref let item = (resInfo,Item.Types(id.idText,[typ]),[]) yield item ] | ResolveTypeNamesToCtors -> diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index 10e3cd31a74..f60e3b0f720 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -1066,6 +1066,13 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d member __.betterTyconRefMap = betterTyconRefMapper member __.decodeTyconRefMap = decodeTyconRefMapper + + member g.decompileType tcref argtys = + let decode = if g.compilingFslib then None else g.decodeTyconRefMap tcref argtys + match decode with + | Some res -> res + | None -> TType_app (tcref, argtys) + member __.new_decimal_info = v_new_decimal_info member __.seq_info = v_seq_info member val seq_vref = (ValRefForIntrinsic v_seq_info) diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index dd34af48ce8..b10312c3cdc 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -4953,11 +4953,7 @@ and TcTypeApp cenv newOk checkCxs occ env tpenv m tcref pathTypeArgs (synArgTys: List.iter2 (UnifyTypes cenv env m) tinst actualArgTys // Try to decode System.Tuple --> F~ tuple types etc. - let ty = - let decode = if cenv.g.compilingFslib then None else cenv.g.decodeTyconRefMap tcref actualArgTys - match decode with - | Some res -> res - | None -> mkAppTy tcref actualArgTys + let ty = cenv.g.decompileType tcref actualArgTys ty, tpenv @@ -4978,6 +4974,7 @@ and TcTypeAndRecover cenv newOk checkCxs occ env tpenv ty = TcTypeOrMeasureAndRecover (Some TyparKind.Type) cenv newOk checkCxs occ env tpenv ty and TcNestedTypeApplication cenv newOk checkCxs occ env tpenv mWholeTypeApp typ tyargs = + let typ = helpEnsureTypeHasMetadata cenv.g typ if not (isAppTy cenv.g typ) then error(Error(FSComp.SR.tcTypeHasNoNestedTypes(), mWholeTypeApp)) match typ with | TType_app(tcref, tinst) -> diff --git a/tests/fsharp/core/csext/test.fsx b/tests/fsharp/core/csext/test.fsx index 5fe3fe2bce6..cfe0ec3759f 100644 --- a/tests/fsharp/core/csext/test.fsx +++ b/tests/fsharp/core/csext/test.fsx @@ -146,11 +146,11 @@ module TestsExplicitUseOfTupleProperties = check "vwhnwrvep01" x1 [1; 2; 1; 2; 3; 1; 2; 3; 4; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 6; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 1; 2; 3; 1; 2; 3; 4; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 6; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7; 1; 2; 3; 4; 5; 6; 7] - let x2 = (1,2,3,4,5,6,7,8).Rest // gives a warning, suppressed in this file + let x2 : System.Tuple = (1,2,3,4,5,6,7,8).Rest // gives a warning, suppressed in this file printfn "x2 = %A" x2 check "vwhnwrvep02" x2 (System.Tuple(8)) - let x3 = (1,2,3,4,5,6,7,8,9).Rest // gives a warning, suppressed in this file + let x3 : (int * int) = (1,2,3,4,5,6,7,8,9).Rest // gives a warning, suppressed in this file printfn "x3 = %A" x3 check "vwhnwrvep03" x3 (unbox (box (8,9))) @@ -271,7 +271,6 @@ module TestsExplicitUseOfStructTupleProperties = check "vewjwervwver" text "PropertyGet (Some (PropertyGet (None, tup, [])), Item1, [])" *) -(* module TupleCtors = let t1 x = new System.Tuple<_>(x) let t2 (x1,x2) = new System.Tuple<_,_>(x1,x2) @@ -302,7 +301,17 @@ module TupleSRTP = static member ($) (T, t:System.Tuple<_,_,_,_,_>) = fun x -> t6 (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5) static member ($) (T, t:System.Tuple<_,_,_,_,_,_>) = fun x -> t7 (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5,t.Item6) static member ($) (T, t:System.Tuple<_,_,_,_,_,_,_>) = fun x -> cp (x,t.Item1, t.Item2,t.Item3,t.Item4,t.Item5,t.Item6) (t1(t.Item7)) -*) + + + let v1 = (^T : (member get_Item1 : unit -> _ ) (new System.Tuple(1,3))) + let v2 = (^T : (member get_Item1 : unit -> _ ) (System.Tuple(1,3))) + let v3 = (^T : (member get_Item1 : unit -> _ ) ((1,3))) + + + + let v1b = (^T : (member get_Item2 : unit -> _ ) (new System.Tuple(1,3))) + let v2b = (^T : (member get_Item2 : unit -> _ ) (System.Tuple(1,3))) + let v3b = (^T : (member get_Item2 : unit -> _ ) ((1,3))) (*--------------------*) From 8519a1524f67a6d99fe28a086233a9551c93c597 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sat, 9 Dec 2017 00:58:06 +0000 Subject: [PATCH 05/17] fix tests --- src/fsharp/MethodOverrides.fs | 2 +- .../TypeExtensions/basic/GenericExtensions.fs | 58 +++++++++---------- .../basic/GenericExtensionsCSLib.cs | 16 ++--- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index a326248b553..1833422a6ed 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -84,7 +84,7 @@ module DispatchSlotChecking = let (CompiledSig (argTys,retTy,fmtps,ttpinst)) = CompiledSigOfMeth g amap m minfo let isFakeEventProperty = minfo.IsFSharpEventPropertyMethod - Override(parentType,tcrefOfAppTy g minfo.EnclosingType,mkSynId m nm, (fmtps,ttpinst),argTys,retTy,isFakeEventProperty,false) + Override(parentType,tcrefOfAppTy g minfo.EnclosingAppType,mkSynId m nm, (fmtps,ttpinst),argTys,retTy,isFakeEventProperty,false) /// Get the override info for a value being used to implement a dispatch slot. let GetTypeMemberOverrideInfo g reqdTy (overrideBy:ValRef) = diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensions.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensions.fs index b11f3d396af..f58407e2753 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensions.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensions.fs @@ -47,13 +47,13 @@ module UseCSharpExtensionsMethodsWithVariableThisTy = let x3 : DateTime = dateTime1.ExtendGenericUnconstrainedOneArg(dateTime1) let x4 : (int -> int) = func1.ExtendGenericUnconstrainedOneArg(func1) let x5 : (int * int) = tup2.ExtendGenericUnconstrainedOneArg(tup2) - let x6 : int = tup3.Item1() - let x7 : int = tup4.Item1() - let x8 : int = tup5.Item1() - let x9 : int = tup6.Item1() - let x10 : int = tup7.Item1() - let x11 : int = tup8.Item1() - let x12 : int = tup9.Item1() + let x6 : int = tup3.GItem1() + let x7 : int = tup4.GItem1() + let x8 : int = tup5.GItem1() + let x9 : int = tup6.GItem1() + let x10 : int = tup7.GItem1() + let x11 : int = tup8.GItem1() + let x12 : int = tup9.GItem1() let y2 : int list = intList1.ExtendGenericConstrainedNoArg() let y3 : int list = intList1.ExtendGenericConstrainedOneArg(intList2) @@ -84,14 +84,14 @@ module UseFSharpDefinedILExtensionsMethods = type CSharpStyleExtensionMethodsInFSharp () = [] static member ExtendGenericUnconstrainedNoArg(s1: 'T) = s1 [] static member ExtendGenericUnconstrainedOneArg(s1: 'T, s2: 'T) = s1 - [] static member Item1((a,b)) = a - [] static member Item1((a,b,c)) = a - [] static member Item1((a,b,c,d)) = a - [] static member Item1((a,b,c,d,e)) = a - [] static member Item1((a,b,c,d,e,f)) = a - [] static member Item1((a,b,c,d,e,f,g)) = a - [] static member Item1((a,b,c,d,e,f,g,h)) = a - [] static member Item1((a,b,c,d,e,f,g,h,i)) = a + [] static member GItem1((a,b)) = a + [] static member GItem1((a,b,c)) = a + [] static member GItem1((a,b,c,d)) = a + [] static member GItem1((a,b,c,d,e)) = a + [] static member GItem1((a,b,c,d,e,f)) = a + [] static member GItem1((a,b,c,d,e,f,g)) = a + [] static member GItem1((a,b,c,d,e,f,g,h)) = a + [] static member GItem1((a,b,c,d,e,f,g,h,i)) = a [] static member ExtendGenericConstrainedNoArg(s1: 'T when 'T :> System.IComparable) = s1 [] static member ExtendGenericConstrainedOneArg(s1 : 'T, s2 : 'T when 'T :> System.IComparable) = s1 [] static member ExtendGenericConstrainedTightNoArg(s1 : 'T when 'T :> System.IComparable) = s1 @@ -125,13 +125,13 @@ module UseFSharpDefinedILExtensionsMethods = let w2 = s1.ExtendGenericUnconstrainedNoArg() let w3 = ob.ExtendGenericUnconstrainedOneArg(ob) let w4 = s1.ExtendGenericUnconstrainedOneArg(s1) - let w5 = tup2.Item1() - let w6 = tup3.Item1() - let w7 = tup4.Item1() - let w8 = tup5.Item1() - let w9 = tup6.Item1() - let w10 = tup7.Item1() - let w11 = tup8.Item1() + let w5 = tup2.GItem1() + let w6 = tup3.GItem1() + let w7 = tup4.GItem1() + let w8 = tup5.GItem1() + let w9 = tup6.GItem1() + let w10 = tup7.GItem1() + let w11 = tup8.GItem1() let base0 = gclist1.ExtendCollListIgnore(3) let base0b = gclist1.ExtendCollListIgnore(3) @@ -153,13 +153,13 @@ module UseFSharpDefinedILExtensionsMethods = let x3 : DateTime = dateTime1.ExtendGenericUnconstrainedOneArg(dateTime1) let x4 : (int -> int) = func1.ExtendGenericUnconstrainedOneArg(func1) let x5 : (int * int) = tup2.ExtendGenericUnconstrainedOneArg(tup2) - let x6 : int = tup3.Item1() - let x7 : int = tup4.Item1() - let x8 : int = tup5.Item1() - let x9 : int = tup6.Item1() - let x10 : int = tup7.Item1() - let x11 : int = tup8.Item1() - let x12 : int = tup9.Item1() + let x6 : int = tup3.GItem1() + let x7 : int = tup4.GItem1() + let x8 : int = tup5.GItem1() + let x9 : int = tup6.GItem1() + let x10 : int = tup7.GItem1() + let x11 : int = tup8.GItem1() + let x12 : int = tup9.GItem1() let y2 : int list = intList1.ExtendGenericConstrainedNoArg() let y3 : int list = intList1.ExtendGenericConstrainedOneArg(intList2) diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensionsCSLib.cs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensionsCSLib.cs index e1787c9ac6f..9d36041ba77 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensionsCSLib.cs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/GenericExtensionsCSLib.cs @@ -36,14 +36,14 @@ static public class C static public T1 ExtendTupleItem1(this Tuple s1) { return s1.Item1; } static public T2 ExtendTupleItem2(this Tuple s1) { return s1.Item2; } - static public T1 Item1(this Tuple s1) { return s1.Item1; } - static public T1 Item1(this Tuple s1) { return s1.Item1; } - static public T1 Item1(this Tuple s1) { return s1.Item1; } - static public T1 Item1(this Tuple s1) { return s1.Item1; } - static public T1 Item1(this Tuple s1) { return s1.Item1; } - static public T1 Item1(this Tuple s1) { return s1.Item1; } - static public T1 Item1(this Tuple> s1) { return s1.Item1; } - static public T1 Item1(this Tuple> s1) { return s1.Item1; } + static public T1 GItem1(this Tuple s1) { return s1.Item1; } + static public T1 GItem1(this Tuple s1) { return s1.Item1; } + static public T1 GItem1(this Tuple s1) { return s1.Item1; } + static public T1 GItem1(this Tuple s1) { return s1.Item1; } + static public T1 GItem1(this Tuple s1) { return s1.Item1; } + static public T1 GItem1(this Tuple s1) { return s1.Item1; } + static public T1 GItem1(this Tuple> s1) { return s1.Item1; } + static public T1 GItem1(this Tuple> s1) { return s1.Item1; } /* methods that add extra type parameters not captured by the 'this' argument */ static public U ExtendGenericIgnore(this T s1, U s2) { return s2; } From c6f9172a2331b5c4d5ec2f18281b67dba2fbb3fd Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 18 Jan 2018 16:24:54 +0000 Subject: [PATCH 06/17] fix tests --- src/fsharp/MethodOverrides.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 5e86d3455b4..67c0ca3723e 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -452,6 +452,7 @@ module DispatchSlotChecking = // Is a member an abstract slot of one of the implied interface types? let isImpliedInterfaceType ty = + isAppTy g ty && isImpliedInterfaceTable.ContainsKey (tcrefOfAppTy g ty) && impliedTys |> List.exists (TypesFeasiblyEquiv 0 g amap reqdTyRange ty) From 86daf4d9c28f4351ec9c6db6a31946793c2652a3 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 19 Jan 2018 17:33:39 +0000 Subject: [PATCH 07/17] add more protection --- src/fsharp/MethodOverrides.fs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 67c0ca3723e..236addea0ae 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -235,6 +235,7 @@ module DispatchSlotChecking = /// Check if an override implements a dispatch slot let OverrideImplementsDispatchSlot g amap m dispatchSlot availPriorOverride = IsExactMatch g amap m dispatchSlot availPriorOverride && + isAppTy g dispatchSlot.EnclosingType && // The override has to actually be in some subtype of the dispatch slot ExistsHeadTypeInEntireHierarchy g amap m (generalizedTyconRef availPriorOverride.BoundingTyconRef) (tcrefOfAppTy g dispatchSlot.EnclosingType) @@ -610,7 +611,8 @@ module DispatchSlotChecking = let overridenForThisSlotImplSet = [ for (RequiredSlot(dispatchSlot,_)) in NameMultiMap.find overrideByInfo.LogicalName dispatchSlotsKeyed do if OverrideImplementsDispatchSlot g amap m dispatchSlot overrideByInfo then - if tyconRefEq g overrideByInfo.BoundingTyconRef (tcrefOfAppTy g dispatchSlot.EnclosingType) then + if isAppTy g dispatchSlot.EnclosingType && + tyconRefEq g overrideByInfo.BoundingTyconRef (tcrefOfAppTy g dispatchSlot.EnclosingType) then match dispatchSlot.ArbitraryValRef with | Some virtMember -> if virtMember.MemberInfo.Value.IsImplemented then errorR(Error(FSComp.SR.tcDefaultImplementationAlreadyExists(),overrideByInfo.Range)) From 33fba0518eea7fb67e244d71c721879a09240b8d Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sat, 20 Jan 2018 11:47:23 +0000 Subject: [PATCH 08/17] improve code for decompiling types --- src/fsharp/AttributeChecking.fs | 8 +- src/fsharp/TcGlobals.fs | 131 ++++++++++++++---------- src/fsharp/import.fs | 4 +- tests/scripts/compiler-perf-results.txt | 2 + tests/scripts/compiler-perf.fsx | 4 +- 5 files changed, 86 insertions(+), 63 deletions(-) diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index ff15a307cec..6448b70434e 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -419,7 +419,7 @@ let CheckMethInfoAttributes g m tyargsOpt minfo = /// Indicate if a method has 'Obsolete', 'CompilerMessageAttribute' or 'TypeProviderEditorHideMethodsAttribute'. /// Used to suppress the item in intellisense. let MethInfoIsUnseen g m typ minfo = - let isUnseenByObsoleteAttrib = + let isUnseenByObsoleteAttrib () = match BindMethInfoAttributes m minfo (fun ilAttribs -> Some(CheckILAttributesForUnseen g ilAttribs m)) (fun fsAttribs -> Some(CheckFSharpAttributesForUnseen g fsAttribs m)) @@ -432,7 +432,7 @@ let MethInfoIsUnseen g m typ minfo = | Some res -> res | None -> false - let isUnseenByHidingAttribute = + let isUnseenByHidingAttribute () = #if !NO_EXTENSIONTYPING not (isObjTy g typ) && isAppTy g typ && @@ -457,9 +457,9 @@ let MethInfoIsUnseen g m typ minfo = false #endif - let isUnseenByBeingTupleMethod = isAnyTupleTy g typ + let isUnseenByBeingTupleMethod () = isAnyTupleTy g typ - isUnseenByObsoleteAttrib || isUnseenByHidingAttribute || isUnseenByBeingTupleMethod + isUnseenByObsoleteAttrib () || isUnseenByHidingAttribute () || isUnseenByBeingTupleMethod () /// Indicate if a property has 'Obsolete' or 'CompilerMessageAttribute'. /// Used to suppress the item in intellisense. diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index ea4a2511454..73434eb1002 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -685,7 +685,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d let addFieldNeverAttrs (fdef:ILFieldDef) = {fdef with CustomAttrs = addNeverAttrs fdef.CustomAttrs} let mkDebuggerTypeProxyAttribute (ty : ILType) = mkILCustomAttribute ilg (findSysILTypeRef tname_DebuggerTypeProxyAttribute, [ilg.typ_Type], [ILAttribElem.TypeRef (Some ty.TypeRef)], []) - let entries1 = + let betterTyconEntries = [| "Int32" , v_int_tcr "IntPtr" , v_nativeint_tcr "UIntPtr" , v_unativeint_tcr @@ -708,7 +708,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d let ty = mkNonGenericTy tcr nm, findSysTyconRef sys nm, (fun _ -> ty)) - let entries2 = + let decompileTyconEntries = [| "FSharpFunc`2" , v_fastFunc_tcr , (fun tinst -> mkFunTy (List.item 0 tinst) (List.item 1 tinst)) "Tuple`2" , v_ref_tuple2_tcr , decodeTupleTy tupInfoRef @@ -726,53 +726,81 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d "ValueTuple`7" , v_struct_tuple7_tcr , decodeTupleTy tupInfoStruct "ValueTuple`8" , v_struct_tuple8_tcr , decodeTupleTyIfPossible v_struct_tuple8_tcr tupInfoStruct |] - // Build a map that uses the "canonical" F# type names and TyconRef's for these - // in preference to the .NET type names. Doing this normalization is a fairly performance critical - // piece of code as it is frequently invoked in the process of converting .NET metadata to F# internal - // compiler data structures (see import.fs). - let buildTyconMapper (entries: (string * TyconRef * _)[]) = + let betterEntries = Array.append betterTyconEntries decompileTyconEntries + + let mutable decompileTypeDict = null + let mutable betterTypeDict1 = null + let mutable betterTypeDict2 = null + + /// This map is indexed by stamps and lazy to avoid dereferencing while setting up the base imports. + let getDecompileTypeDict () = + match decompileTypeDict with + | null -> + let entries = decompileTyconEntries + let t = Dictionary.newWithSize entries.Length + for _, tcref, builder in entries do + if tcref.CanDeref then + t.Add(tcref.Stamp, builder) + decompileTypeDict <- t + t + | t -> t + + /// This map is for use when building FSharp.Core.dll. The backing Tycon's may not yet exist for + /// the TyconRef's we have in our hands, hence we can't dereference them to find their stamps. + /// So this dictionary is indexed by names. Make it lazy to avoid dereferencing while setting up the base imports. + let getBetterTypeDict1 () = + match betterTypeDict1 with + | null -> + let entries = betterEntries + let t = Dictionary.newWithSize entries.Length + for nm, tcref, builder in entries do + t.Add(nm, fun tcref2 tinst2 -> if tyconRefEq tcref tcref2 then builder tinst2 else TType_app (tcref2, tinst2)) + betterTypeDict1 <- t + t + | t -> t + + /// This map is for use in normal times (not building FSharp.Core.dll). It is indexed by stamps + /// and lazy to avoid dereferencing while setting up the base imports. + let getBetterTypeDict2 () = + match betterTypeDict2 with + | null -> + let entries = betterEntries + let t = Dictionary.newWithSize entries.Length + for _, tcref, builder in entries do + if tcref.CanDeref then + t.Add(tcref.Stamp, builder) + betterTypeDict2 <- t + t + | t -> t + + /// For logical purposes equate some F# types with .NET types, e.g. TType_tuple == System.Tuple/ValueTuple. + /// Doing this normalization is a fairly performance critical piece of code as it is frequently invoked + /// in the process of converting .NET metadata to F# internal compiler data structures (see import.fs). + let decompileTy (tcref: EntityRef) tinst = + if compilingFslib then + // No need to decompile when compiling FSharp.Core.dll + TType_app (tcref, tinst) + else + let dict = getDecompileTypeDict() + let mutable builder = Unchecked.defaultof<_> + if dict.TryGetValue(tcref.Stamp, &builder) then builder tinst + else TType_app (tcref, tinst) + + /// For cosmetic purposes "improve" some .NET types, e.g. Int32 --> int32. + /// Doing this normalization is a fairly performance critical piece of code as it is frequently invoked + /// in the process of converting .NET metadata to F# internal compiler data structures (see import.fs). + let improveTy (tcref: EntityRef) tinst = if compilingFslib then - // This map is for use when building FSharp.Core.dll. The backing Tycon's may not yet exist for - // the TyconRef's we have in our hands, hence we can't dereference them to find their stamps. - - // So this dictionary is indexed by names. - // - // Make it lazy to avoid dereferencing while setting up the base imports. - let dict = - lazy ( - let dict = Dictionary.newWithSize entries.Length - for nm, tcref, builder in entries do - dict.Add(nm, fun tcref2 tinst -> if tyconRefEq tcref tcref2 then Some(builder tinst) else None) - dict - ) - (fun (tcref: EntityRef) tinst -> - let dict = dict.Value - let key = tcref.LogicalName - if dict.ContainsKey key then dict.[key] tcref tinst - else None ) + let dict = getBetterTypeDict1() + let mutable builder = Unchecked.defaultof<_> + if dict.TryGetValue(tcref.LogicalName, &builder) then builder tcref tinst + else TType_app (tcref, tinst) else - // This map is for use in normal times (not building FSharp.Core.dll). It is indexed by tcref stamp which is - // faster than the indexing technique used in the case above. - // - // So this dictionary is indexed by integers. - // - // Make it lazy to avoid dereferencing while setting up the base imports. - let dict = - lazy - let dict = Dictionary.newWithSize entries.Length - for _, tcref, builder in entries do - if tcref.CanDeref then - dict.Add(tcref.Stamp, builder) - dict - (fun tcref2 tinst -> - let dict = dict.Value - let key = tcref2.Stamp - if dict.ContainsKey key then Some(dict.[key] tinst) - else None) - - let betterTyconRefMapper = buildTyconMapper (Array.append entries1 entries2) - - let decodeTyconRefMapper = buildTyconMapper entries2 + let dict = getBetterTypeDict2() + let mutable builder = Unchecked.defaultof<_> + if dict.TryGetValue(tcref.Stamp, &builder) then builder tinst + else TType_app (tcref, tinst) + override x.ToString() = "" member __.ilg=ilg @@ -1063,14 +1091,9 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d member val attrib_SecuritySafeCriticalAttribute = findSysAttrib "System.Security.SecuritySafeCriticalAttribute" member val attrib_ComponentModelEditorBrowsableAttribute = findSysAttrib "System.ComponentModel.EditorBrowsableAttribute" - member __.betterTyconRefMap = betterTyconRefMapper - member __.decodeTyconRefMap = decodeTyconRefMapper + member g.improveType tcref tinst = improveTy tcref tinst - member g.decompileType tcref argtys = - let decode = if g.compilingFslib then None else g.decodeTyconRefMap tcref argtys - match decode with - | Some res -> res - | None -> TType_app (tcref, argtys) + member g.decompileType tcref tinst = decompileTy tcref tinst member __.new_decimal_info = v_new_decimal_info member __.seq_info = v_seq_info diff --git a/src/fsharp/import.fs b/src/fsharp/import.fs index 6db631a0318..f6f5648d8e4 100644 --- a/src/fsharp/import.fs +++ b/src/fsharp/import.fs @@ -150,9 +150,7 @@ let CanImportILTypeRef (env:ImportMap) m (tref:ILTypeRef) = /// Prefer the F# abbreviation for some built-in types, e.g. 'string' rather than /// 'System.String', since we prefer the F# abbreviation to the .NET equivalents. let ImportTyconRefApp (env:ImportMap) tcref tyargs = - match env.g.betterTyconRefMap tcref tyargs with - | Some res -> res - | None -> TType_app (tcref,tyargs) + env.g.improveType tcref tyargs /// Import an IL type as an F# type. let rec ImportILType (env:ImportMap) m tinst typ = diff --git a/tests/scripts/compiler-perf-results.txt b/tests/scripts/compiler-perf-results.txt index 56be78c3cbb..a79b78b4498 100644 --- a/tests/scripts/compiler-perf-results.txt +++ b/tests/scripts/compiler-perf-results.txt @@ -132,3 +132,5 @@ https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-t https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-to-us 87dafbc17b494c438b6db9e59e064736bd8a44e2 458e6c29d7e059a5a8a7b4cd7858c7d633fb5906 224.75 11.20 31.09 46.96 63.08 53.08 https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-to-us 87dafbc17b494c438b6db9e59e064736bd8a44e2 7e1fd6ac330f86597f3167e8067cfd805a89eec9 235.48 10.83 33.47 47.17 65.56 52.50 +https://github.com/dsyme/visualfsharp.git tup1 86daf4d9c28f4351ec9c6db6a31946793c2652a3 a8115c15d85ea5e54b642f53bad1ddb1215f78fb 305.41 11.64 31.67 46.92 58.15 62.07 +https://github.com/Microsoft/visualfsharp master a8115c15d85ea5e54b642f53bad1ddb1215f78fb a8115c15d85ea5e54b642f53bad1ddb1215f78fb 256.88 11.42 30.87 48.54 57.64 59.20 diff --git a/tests/scripts/compiler-perf.fsx b/tests/scripts/compiler-perf.fsx index 86d203bd245..6858d8ffe71 100644 --- a/tests/scripts/compiler-perf.fsx +++ b/tests/scripts/compiler-perf.fsx @@ -23,9 +23,9 @@ nuget FAKE #I "script-packages/packages/FAKE/tools" -#I "script-packages/packages/FSharp.Data/lib/net40" +#I "script-packages/packages/FSharp.Data/lib/net45" #r "script-packages/packages/FAKE/tools/FakeLib.dll" -#r "script-packages/packages/FSharp.Data/lib/net40/FSharp.Data.dll" +#r "script-packages/packages/FSharp.Data/lib/net45/FSharp.Data.dll" open System open System.IO From e26b201b3d3037d7b6577b19c617080b7119c699 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sat, 20 Jan 2018 16:02:53 +0000 Subject: [PATCH 09/17] fix unit tests --- src/fsharp/AttributeChecking.fs | 6 ++-- src/fsharp/InfoReader.fs | 2 +- .../Tests.LanguageService.ParameterInfo.fs | 3 +- .../unittests/VisualFSharp.UnitTests.fsproj | 32 +++++++++---------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index 6448b70434e..66cf2bcc079 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -457,16 +457,16 @@ let MethInfoIsUnseen g m typ minfo = false #endif - let isUnseenByBeingTupleMethod () = isAnyTupleTy g typ + //let isUnseenByBeingTupleMethod () = isAnyTupleTy g typ - isUnseenByObsoleteAttrib () || isUnseenByHidingAttribute () || isUnseenByBeingTupleMethod () + isUnseenByObsoleteAttrib () || isUnseenByHidingAttribute () //|| isUnseenByBeingTupleMethod () /// Indicate if a property has 'Obsolete' or 'CompilerMessageAttribute'. /// Used to suppress the item in intellisense. let PropInfoIsUnseen m pinfo = match pinfo with | ILProp (g,(ILPropInfo(_,pdef) as ilpinfo)) -> - // Properties on tuple types are resolvable but unseen + // Properties on .NET tuple types are resolvable but unseen isAnyTupleTy g ilpinfo.ILTypeInfo.ToType || CheckILAttributesForUnseen g pdef.CustomAttrs m | FSProp (g,_,Some vref,_) diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index 058a9464194..e2a7c073f91 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -632,7 +632,7 @@ let ExcludeHiddenOfMethInfos g amap m (minfos:MethInfo list list) = (fun minfo -> minfo.LogicalName) (fun m1 m2 -> // only hide those truly from super classes - not (tyconRefEq g (tcrefOfAppTy g m1.EnclosingType) (tcrefOfAppTy g m2.EnclosingType)) && + not (tyconRefEq g m1.DeclaringEntityRef m2.DeclaringEntityRef) && MethInfosEquivByNameAndPartialSig EraseNone true g amap m m1 m2) |> List.concat diff --git a/vsintegration/tests/unittests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs b/vsintegration/tests/unittests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs index 7547ba64599..c918cbd3ece 100644 --- a/vsintegration/tests/unittests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs +++ b/vsintegration/tests/unittests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs @@ -772,8 +772,7 @@ type UsingMSBuild() = [] //This test verifies that ParamInfo location on a provided type without the namespace that exposes static parameter that takes >1 argument works normally. member public this.``TypeProvider.Type.ParameterInfoLocation.WithOutNamespace`` () = - this.TestParameterInfoLocation("open N1 \n"+ - "type boo = T<$", + this.TestParameterInfoLocation("open N1 \n"+"type boo = T<$", expectedPos = 11, addtlRefAssy = [PathRelativeToTestAssembly(@"UnitTests\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll")]) diff --git a/vsintegration/tests/unittests/VisualFSharp.UnitTests.fsproj b/vsintegration/tests/unittests/VisualFSharp.UnitTests.fsproj index 0eb67c32862..2bedabfac17 100644 --- a/vsintegration/tests/unittests/VisualFSharp.UnitTests.fsproj +++ b/vsintegration/tests/unittests/VisualFSharp.UnitTests.fsproj @@ -59,52 +59,52 @@ - FsUnit.fs + CompilerService\FsUnit.fs - Common.fs + CompilerService\Common.fs - ServiceAnalysis\Symbols.fs + CompilerService\Symbols.fs - EditorTests.fs + CompilerService\EditorTests.fs - FileSystemTests.fs + CompilerService\FileSystemTests.fs - ProjectAnalysisTests.fs + CompilerService\ProjectAnalysisTests.fs - MultiProjectAnalysisTests.fs + CompilerService\MultiProjectAnalysisTests.fs - PerfTests.fs + CompilerService\PerfTests.fs - InteractiveCheckerTests.fs + CompilerService\InteractiveCheckerTests.fs - ExprTests.fs + CompilerService\ExprTests.fs - CSharpProjectAnalysis.fs + CompilerService\CSharpProjectAnalysis.fs - ProjectOptionsTests.fs + CompilerService\ProjectOptionsTests.fs - StructureTests.fs + CompilerService\StructureTests.fs - AssemblyContentProviderTests.fs + CompilerService\AssemblyContentProviderTests.fs - ServiceUntypedParseTests.fs + CompilerService\ServiceUntypedParseTests.fs - ServiceAnalysis\UnusedOpensTests.fs + CompilerService\UnusedOpensTests.fs Roslyn\ColorizationServiceTests.fs From d31327b65d90508b5173ab4714b56e94c2bcdcde Mon Sep 17 00:00:00 2001 From: Don Syme Date: Sat, 20 Jan 2018 16:06:33 +0000 Subject: [PATCH 10/17] don't rebuild --- src/fsharp/FSharp.Build/WriteCodeFragment.fs | 10 +++++++--- tests/scripts/compiler-perf-results.txt | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fsharp/FSharp.Build/WriteCodeFragment.fs b/src/fsharp/FSharp.Build/WriteCodeFragment.fs index ee8eaab2830..1002a489b10 100644 --- a/src/fsharp/FSharp.Build/WriteCodeFragment.fs +++ b/src/fsharp/FSharp.Build/WriteCodeFragment.fs @@ -113,15 +113,19 @@ open System.Reflection" let sb = StringBuilder().AppendLine(boilerplate).AppendLine() let code = Array.fold (fun (sb:StringBuilder) (item:ITaskItem) -> sb.AppendLine(WriteCodeFragment.GenerateAttribute item)) sb _assemblyAttributes code.AppendLine().AppendLine("do()") |> ignore + let fileName = _outputFile.ItemSpec let outputFileItem = - if not (isNull _outputFile) && not (isNull _outputDirectory) && not (Path.IsPathRooted(_outputFile.ItemSpec)) then - TaskItem(Path.Combine(_outputDirectory.ItemSpec, _outputFile.ItemSpec)) :> ITaskItem + if not (isNull _outputFile) && not (isNull _outputDirectory) && not (Path.IsPathRooted(fileName)) then + TaskItem(Path.Combine(_outputDirectory.ItemSpec, fileName)) :> ITaskItem elif isNull _outputFile then let tempFile = Path.Combine(Path.GetTempPath(), sprintf "tmp%s.fs" (Guid.NewGuid().ToString("N"))) TaskItem(tempFile) :> ITaskItem else _outputFile - File.WriteAllText(_outputFile.ItemSpec, code.ToString()) + let codeText = code.ToString() + let alreadyExists = (try File.Exists fileName && File.ReadAllText(fileName) = codeText with _ -> false) + if not alreadyExists then + File.WriteAllText(fileName, codeText) _outputFile <- outputFileItem true with e -> diff --git a/tests/scripts/compiler-perf-results.txt b/tests/scripts/compiler-perf-results.txt index 56be78c3cbb..ee00b0994f9 100644 --- a/tests/scripts/compiler-perf-results.txt +++ b/tests/scripts/compiler-perf-results.txt @@ -131,4 +131,3 @@ https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-t https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-to-us 87dafbc17b494c438b6db9e59e064736bd8a44e2 ba63403cb5898596c5e875a14ce22b33ef618c01 221.58 11.19 31.91 48.23 66.05 52.99 https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-to-us 87dafbc17b494c438b6db9e59e064736bd8a44e2 458e6c29d7e059a5a8a7b4cd7858c7d633fb5906 224.75 11.20 31.09 46.96 63.08 53.08 https://github.com/manofstick/visualfsharp.git all-your-collections-are-belong-to-us 87dafbc17b494c438b6db9e59e064736bd8a44e2 7e1fd6ac330f86597f3167e8067cfd805a89eec9 235.48 10.83 33.47 47.17 65.56 52.50 - From 582bd6590bd47aa5794007be6c3a6376287ebbb4 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 14:22:55 +0000 Subject: [PATCH 11/17] make infos systematic to reduce use of tcrefOfAppTy --- .gitignore | 5 + src/absil/il.fs | 46 +-- src/absil/il.fsi | 16 +- src/absil/ilmorph.fs | 8 +- src/absil/ilprint.fs | 12 +- src/absil/ilread.fs | 4 +- src/absil/ilreflect.fs | 14 +- src/absil/ilwrite.fs | 20 +- src/absil/ilx.fs | 2 +- src/absil/ilx.fsi | 2 +- src/fsharp/AccessibilityLogic.fs | 10 +- src/fsharp/AttributeChecking.fs | 18 +- src/fsharp/CompileOps.fs | 6 +- src/fsharp/ConstraintSolver.fs | 18 +- src/fsharp/IlxGen.fs | 42 +-- src/fsharp/InfoReader.fs | 10 +- src/fsharp/MethodCalls.fs | 14 +- src/fsharp/MethodOverrides.fs | 22 +- src/fsharp/NameResolution.fs | 36 +-- src/fsharp/NicePrint.fs | 21 +- src/fsharp/Optimizer.fs | 6 +- src/fsharp/QuotationTranslator.fs | 6 +- src/fsharp/TastOps.fs | 10 +- src/fsharp/TastPickle.fs | 12 +- src/fsharp/TypeChecker.fs | 40 +-- src/fsharp/fsc.fs | 4 +- src/fsharp/infos.fs | 298 +++++++++++------- src/fsharp/service/ServiceDeclarationLists.fs | 14 +- src/fsharp/service/service.fs | 20 +- src/fsharp/symbols/Exprs.fs | 16 +- src/fsharp/symbols/SymbolHelpers.fs | 71 ++--- src/fsharp/symbols/Symbols.fs | 124 ++++---- src/ilx/EraseUnions.fs | 2 +- 33 files changed, 509 insertions(+), 440 deletions(-) diff --git a/.gitignore b/.gitignore index 236ddf853f2..a78b05f7c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,11 @@ /packages /Tools +/tests/scripts/current +/release +/debug +/Proto + # Patches that may have been generated by scripts. # (These aren't generally useful to commit directly; if anything, they should be applied.) scripts/*.patch diff --git a/src/absil/il.fs b/src/absil/il.fs index 6f5f0d873b3..9335440f70c 100644 --- a/src/absil/il.fs +++ b/src/absil/il.fs @@ -726,7 +726,7 @@ type ILMethodRef = mrefName: string; mrefArgs: ILTypes; mrefReturn: ILType } - member x.EnclosingTypeRef = x.mrefParent + member x.DeclaringTypeRef = x.mrefParent member x.CallingConv = x.mrefCallconv member x.Name = x.mrefName member x.GenericArity = x.mrefGenericArity @@ -737,24 +737,24 @@ type ILMethodRef = member x.CallingSignature = mkILCallSig (x.CallingConv,x.ArgTypes,x.ReturnType) static member Create(a,b,c,d,e,f) = { mrefParent= a;mrefCallconv=b;mrefName=c;mrefGenericArity=d; mrefArgs=e;mrefReturn=f } - override x.ToString() = x.EnclosingTypeRef.ToString() + "::" + x.Name + "(...)" + override x.ToString() = x.DeclaringTypeRef.ToString() + "::" + x.Name + "(...)" [] type ILFieldRef = - { EnclosingTypeRef: ILTypeRef; + { DeclaringTypeRef: ILTypeRef; Name: string; Type: ILType } - override x.ToString() = x.EnclosingTypeRef.ToString() + "::" + x.Name + override x.ToString() = x.DeclaringTypeRef.ToString() + "::" + x.Name [] type ILMethodSpec = { mspecMethodRef: ILMethodRef; - mspecEnclosingType: ILType; + mspecDeclaringType: ILType; mspecMethodInst: ILGenericArgs; } - static member Create(a,b,c) = { mspecEnclosingType=a; mspecMethodRef =b; mspecMethodInst=c } + static member Create(a,b,c) = { mspecDeclaringType=a; mspecMethodRef =b; mspecMethodInst=c } member x.MethodRef = x.mspecMethodRef - member x.EnclosingType=x.mspecEnclosingType + member x.DeclaringType=x.mspecDeclaringType member x.GenericArgs=x.mspecMethodInst member x.Name=x.MethodRef.Name member x.CallingConv=x.MethodRef.CallingConv @@ -766,10 +766,10 @@ type ILMethodSpec = type ILFieldSpec = { FieldRef: ILFieldRef; - EnclosingType: ILType } + DeclaringType: ILType } member x.FormalType = x.FieldRef.Type member x.Name = x.FieldRef.Name - member x.EnclosingTypeRef = x.FieldRef.EnclosingTypeRef + member x.DeclaringTypeRef = x.FieldRef.DeclaringTypeRef override x.ToString() = x.FieldRef.ToString() @@ -1302,7 +1302,7 @@ type ILReturn = type ILOverridesSpec = | OverridesSpec of ILMethodRef * ILType member x.MethodRef = let (OverridesSpec(mr,_ty)) = x in mr - member x.EnclosingType = let (OverridesSpec(_mr,ty)) = x in ty + member x.DeclaringType = let (OverridesSpec(_mr,ty)) = x in ty type ILMethodVirtualInfo = { IsFinal: bool @@ -1817,10 +1817,10 @@ let mkILMethRef (tref,callconv,nm,gparams,args,rty) = let mkILMethSpecForMethRefInTy (mref,typ,minst) = { mspecMethodRef=mref; - mspecEnclosingType=typ; + mspecDeclaringType=typ; mspecMethodInst=minst } -let mkILMethSpec (mref, vc, tinst, minst) = mkILMethSpecForMethRefInTy (mref,mkILNamedTy vc mref.EnclosingTypeRef tinst, minst) +let mkILMethSpec (mref, vc, tinst, minst) = mkILMethSpecForMethRefInTy (mref,mkILNamedTy vc mref.DeclaringTypeRef tinst, minst) let mk_mspec_in_tref (tref,vc,cc,nm,args,rty,tinst,minst) = mkILMethSpec (mkILMethRef ( tref,cc,nm,List.length minst,args,rty),vc,tinst,minst) @@ -1856,9 +1856,9 @@ let mkILNonGenericCtorMethSpec (tref,args) = // Make references to fields // -------------------------------------------------------------------- -let mkILFieldRef(tref,nm,ty) = { EnclosingTypeRef=tref; Name=nm; Type=ty} +let mkILFieldRef(tref,nm,ty) = { DeclaringTypeRef=tref; Name=nm; Type=ty} -let mkILFieldSpec (tref,ty) = { FieldRef= tref; EnclosingType=ty } +let mkILFieldSpec (tref,ty) = { FieldRef= tref; DeclaringType=ty } let mkILFieldSpecInTy (typ:ILType,nm,fty) = mkILFieldSpec (mkILFieldRef (typ.TypeRef,nm,fty), typ) @@ -2205,7 +2205,7 @@ and rescopeILCallSig scoref csig = mkILCallSig (csig.CallingConv,rescopeILTypes scoref csig.ArgTypes,rescopeILType scoref csig.ReturnType) let rescopeILMethodRef scoref (x:ILMethodRef) = - { mrefParent = rescopeILTypeRef scoref x.EnclosingTypeRef; + { mrefParent = rescopeILTypeRef scoref x.DeclaringTypeRef; mrefCallconv = x.mrefCallconv; mrefGenericArity=x.mrefGenericArity; mrefName=x.mrefName; @@ -2213,7 +2213,7 @@ let rescopeILMethodRef scoref (x:ILMethodRef) = mrefReturn= rescopeILType scoref x.mrefReturn } let rescopeILFieldRef scoref x = - { EnclosingTypeRef = rescopeILTypeRef scoref x.EnclosingTypeRef; + { DeclaringTypeRef = rescopeILTypeRef scoref x.DeclaringTypeRef; Name= x.Name; Type= rescopeILType scoref x.Type } @@ -2277,7 +2277,7 @@ let mkILLocal ty dbgInfo : ILLocal = type ILFieldSpec with member fr.ActualType = - let env = fr.EnclosingType.GenericArgs + let env = fr.DeclaringType.GenericArgs instILType env fr.FormalType // -------------------------------------------------------------------- @@ -3482,20 +3482,20 @@ and refs_of_genparams s b = List.iter (refs_of_genparam s) b and refs_of_dloc s ts = refs_of_tref s ts and refs_of_mref s (x:ILMethodRef) = - refs_of_dloc s x.EnclosingTypeRef ; + refs_of_dloc s x.DeclaringTypeRef ; refs_of_typs s x.mrefArgs; refs_of_typ s x.mrefReturn -and refs_of_fref s x = refs_of_tref s x.EnclosingTypeRef; refs_of_typ s x.Type +and refs_of_fref s x = refs_of_tref s x.DeclaringTypeRef; refs_of_typ s x.Type and refs_of_ospec s (OverridesSpec(mref,ty)) = refs_of_mref s mref; refs_of_typ s ty and refs_of_mspec s (x: ILMethodSpec) = refs_of_mref s x.MethodRef; - refs_of_typ s x.EnclosingType; + refs_of_typ s x.DeclaringType; refs_of_inst s x.GenericArgs and refs_of_fspec s x = refs_of_fref s x.FieldRef; - refs_of_typ s x.EnclosingType + refs_of_typ s x.DeclaringType and refs_of_typs s l = List.iter (refs_of_typ s) l @@ -3769,11 +3769,11 @@ let ungenericizeTypeName n = type ILEventRef = { erA: ILTypeRef; erB: string } static member Create(a,b) = {erA=a;erB=b} - member x.EnclosingTypeRef = x.erA + member x.DeclaringTypeRef = x.erA member x.Name = x.erB type ILPropertyRef = { prA: ILTypeRef; prB: string } static member Create (a,b) = {prA=a;prB=b} - member x.EnclosingTypeRef = x.prA + member x.DeclaringTypeRef = x.prA member x.Name = x.prB diff --git a/src/absil/il.fsi b/src/absil/il.fsi index 4d3cfd74d4a..b6f374217f2 100644 --- a/src/absil/il.fsi +++ b/src/absil/il.fsi @@ -372,7 +372,7 @@ and ILTypes = list [] type ILMethodRef = static member Create : enclosingTypeRef: ILTypeRef * callingConv: ILCallingConv * name: string * genericArity: int * argTypes: ILTypes * returnType: ILType -> ILMethodRef - member EnclosingTypeRef: ILTypeRef + member DeclaringTypeRef: ILTypeRef member CallingConv: ILCallingConv member Name: string member GenericArity: int @@ -386,7 +386,7 @@ type ILMethodRef = [] type ILFieldRef = - { EnclosingTypeRef: ILTypeRef; + { DeclaringTypeRef: ILTypeRef; Name: string; Type: ILType } @@ -407,7 +407,7 @@ type ILFieldRef = type ILMethodSpec = static member Create : ILType * ILMethodRef * ILGenericArgs -> ILMethodSpec member MethodRef: ILMethodRef - member EnclosingType: ILType + member DeclaringType: ILType member GenericArgs: ILGenericArgs member CallingConv: ILCallingConv member GenericArity: int @@ -421,8 +421,8 @@ type ILMethodSpec = [] type ILFieldSpec = { FieldRef: ILFieldRef; - EnclosingType: ILType } - member EnclosingTypeRef: ILTypeRef + DeclaringType: ILType } + member DeclaringTypeRef: ILTypeRef member Name: string member FormalType: ILType member ActualType : ILType @@ -963,7 +963,7 @@ type PInvokeMethod = type ILOverridesSpec = | OverridesSpec of ILMethodRef * ILType member MethodRef: ILMethodRef - member EnclosingType: ILType + member DeclaringType: ILType // REVIEW: fold this into ILMethodDef. type ILMethodVirtualInfo = @@ -1921,13 +1921,13 @@ val computeILEnumInfo: string * ILFieldDefs -> ILEnumInfo [] type ILEventRef = static member Create : ILTypeRef * string -> ILEventRef - member EnclosingTypeRef: ILTypeRef + member DeclaringTypeRef: ILTypeRef member Name: string [] type ILPropertyRef = static member Create : ILTypeRef * string -> ILPropertyRef - member EnclosingTypeRef: ILTypeRef + member DeclaringTypeRef: ILTypeRef member Name: string interface System.IComparable diff --git a/src/absil/ilmorph.fs b/src/absil/ilmorph.fs index dc0d27e1feb..90b0e267f69 100644 --- a/src/absil/ilmorph.fs +++ b/src/absil/ilmorph.fs @@ -103,7 +103,7 @@ let gparam_typ2typ f gf = {gf with Constraints = List.map f gf.Constraints} let gparams_typ2typ f gfs = List.map (gparam_typ2typ f) gfs let typs_typ2typ (f: ILType -> ILType) x = List.map f x let mref_typ2typ (f: ILType -> ILType) (x:ILMethodRef) = - ILMethodRef.Create(enclosingTypeRef= (f (mkILBoxedType (mkILNonGenericTySpec x.EnclosingTypeRef))).TypeRef, + ILMethodRef.Create(enclosingTypeRef= (f (mkILBoxedType (mkILNonGenericTySpec x.DeclaringTypeRef))).TypeRef, callingConv=x.CallingConv, name=x.Name, genericArity=x.GenericArity, @@ -115,16 +115,16 @@ type formal_scopeCtxt = Choice let mspec_typ2typ (((factualty : ILType -> ILType) , (fformalty: formal_scopeCtxt -> ILType -> ILType))) (x: ILMethodSpec) = mkILMethSpecForMethRefInTy(mref_typ2typ (fformalty (Choice1Of2 x)) x.MethodRef, - factualty x.EnclosingType, + factualty x.DeclaringType, typs_typ2typ factualty x.GenericArgs) let fref_typ2typ (f: ILType -> ILType) x = - { x with EnclosingTypeRef = (f (mkILBoxedType (mkILNonGenericTySpec x.EnclosingTypeRef))).TypeRef; + { x with DeclaringTypeRef = (f (mkILBoxedType (mkILNonGenericTySpec x.DeclaringTypeRef))).TypeRef; Type= f x.Type } let fspec_typ2typ ((factualty,(fformalty : formal_scopeCtxt -> ILType -> ILType))) x = { FieldRef=fref_typ2typ (fformalty (Choice2Of2 x)) x.FieldRef; - EnclosingType= factualty x.EnclosingType } + DeclaringType= factualty x.DeclaringType } let rec celem_typ2typ f celem = match celem with diff --git a/src/absil/ilprint.fs b/src/absil/ilprint.fs index 6c98fc605b9..0e1727effe1 100644 --- a/src/absil/ilprint.fs +++ b/src/absil/ilprint.fs @@ -338,12 +338,12 @@ and goutput_mref env os (mref:ILMethodRef) = and goutput_mspec env os (mspec:ILMethodSpec) = let fenv = ppenv_enter_method mspec.GenericArity - (ppenv_enter_tdef (mkILFormalTypars mspec.EnclosingType.GenericArgs) env) + (ppenv_enter_tdef (mkILFormalTypars mspec.DeclaringType.GenericArgs) env) output_callconv os mspec.CallingConv; output_string os " "; goutput_typ fenv os mspec.FormalReturnType; output_string os " "; - goutput_dlocref env os mspec.EnclosingType; + goutput_dlocref env os mspec.DeclaringType; output_string os " "; let name = mspec.Name if name = ".ctor" || name = ".cctor" then output_string os name else output_id os name; @@ -356,12 +356,12 @@ and goutput_vararg_mspec env os (mspec, varargs) = | Some varargs' -> let fenv = ppenv_enter_method mspec.GenericArity - (ppenv_enter_tdef (mkILFormalTypars mspec.EnclosingType.GenericArgs) env) + (ppenv_enter_tdef (mkILFormalTypars mspec.DeclaringType.GenericArgs) env) output_callconv os mspec.CallingConv; output_string os " "; goutput_typ fenv os mspec.FormalReturnType; output_string os " "; - goutput_dlocref env os mspec.EnclosingType; + goutput_dlocref env os mspec.DeclaringType; let name = mspec.Name if name = ".ctor" || name = ".cctor" then output_string os name else output_id os name goutput_gactuals env os mspec.GenericArgs; @@ -385,10 +385,10 @@ and goutput_vararg_sig env os (csig:ILCallingSignature,varargs:ILVarArgs) = output_string os ")"; and goutput_fspec env os (x:ILFieldSpec) = - let fenv = ppenv_enter_tdef (mkILFormalTypars x.EnclosingType.GenericArgs) env + let fenv = ppenv_enter_tdef (mkILFormalTypars x.DeclaringType.GenericArgs) env goutput_typ fenv os x.FormalType; output_string os " "; - goutput_dlocref env os x.EnclosingType; + goutput_dlocref env os x.DeclaringType; output_id os x.Name let output_member_access os access = diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs index f4ea49effee..b4a88f58e7d 100644 --- a/src/absil/ilread.fs +++ b/src/absil/ilread.fs @@ -1877,7 +1877,7 @@ and seekReadMethodRefParent ctxt numtypars (TaggedIndex(tag, idx)) = | tag when tag = mrp_MethodDef -> let (MethodData(enclTyp, cc, nm, argtys, retty, minst)) = seekReadMethodDefAsMethodData ctxt idx let mspec = mkILMethSpecInTy (enclTyp, cc, nm, argtys, retty, minst) - mspec.EnclosingType + mspec.DeclaringType | tag when tag = mrp_TypeSpec -> readBlobHeapAsType ctxt numtypars (seekReadTypeSpecRow ctxt idx) | _ -> failwith "seekReadMethodRefParent ctxt" @@ -2416,7 +2416,7 @@ and seekReadMethodImpls ctxt numtypars tidx = Overrides= let (MethodData(enclTyp, cc, nm, argtys, retty, minst)) = seekReadMethodDefOrRefNoVarargs ctxt numtypars c let mspec = mkILMethSpecInTy (enclTyp, cc, nm, argtys, retty, minst) - OverridesSpec(mspec.MethodRef, mspec.EnclosingType) })) + OverridesSpec(mspec.MethodRef, mspec.DeclaringType) })) and seekReadMultipleMethodSemantics ctxt (flags, id) = seekReadIndexedRows diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index f35e6e7b792..774b7a24366 100644 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -654,7 +654,7 @@ let typeIsNotQueryable (typ : Type) = let queryableTypeGetField _emEnv (parentT:Type) (fref: ILFieldRef) = let res = parentT.GetField(fref.Name, BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Instance ||| BindingFlags.Static ) match res with - | null -> error(Error(FSComp.SR.itemNotFoundInTypeDuringDynamicCodeGen ("field", fref.Name, fref.EnclosingTypeRef.FullName, fref.EnclosingTypeRef.Scope.QualifiedName), range0)) + | null -> error(Error(FSComp.SR.itemNotFoundInTypeDuringDynamicCodeGen ("field", fref.Name, fref.DeclaringTypeRef.FullName, fref.DeclaringTypeRef.Scope.QualifiedName), range0)) | _ -> res let nonQueryableTypeGetField (parentTI:Type) (fieldInfo : FieldInfo) : FieldInfo = @@ -668,8 +668,8 @@ let nonQueryableTypeGetField (parentTI:Type) (fieldInfo : FieldInfo) : FieldInfo let convFieldSpec cenv emEnv fspec = let fref = fspec.FieldRef - let tref = fref.EnclosingTypeRef - let parentTI = convType cenv emEnv fspec.EnclosingType + let tref = fref.DeclaringTypeRef + let parentTI = convType cenv emEnv fspec.DeclaringType if isEmittedTypeRef emEnv tref then // NOTE: if "convType becomes convCreatedType", then handle queryable types here too. [bug 4063] (necessary? what repro?) let fieldB = envGetFieldB emEnv fref @@ -793,7 +793,7 @@ let nonQueryableTypeGetMethod (parentTI:Type) (methInfo : MethodInfo) : MethodIn else methInfo let convMethodRef cenv emEnv (parentTI:Type) (mref:ILMethodRef) = - let parent = mref.EnclosingTypeRef + let parent = mref.DeclaringTypeRef let res = if isEmittedTypeRef emEnv parent then // NOTE: if "convType becomes convCreatedType", then handle queryable types here too. [bug 4063] @@ -817,7 +817,7 @@ let convMethodRef cenv emEnv (parentTI:Type) (mref:ILMethodRef) = //---------------------------------------------------------------------------- let convMethodSpec cenv emEnv (mspec:ILMethodSpec) = - let typT = convType cenv emEnv mspec.EnclosingType (* (instanced) parent Type *) + let typT = convType cenv emEnv mspec.DeclaringType (* (instanced) parent Type *) let methInfo = convMethodRef cenv emEnv typT mspec.MethodRef (* (generic) method of (generic) parent *) let methInfo = if isNil mspec.GenericArgs then @@ -852,9 +852,9 @@ let nonQueryableTypeGetConstructor (parentTI:Type) (consInfo : ConstructorInfo) let convConstructorSpec cenv emEnv (mspec:ILMethodSpec) = let mref = mspec.MethodRef - let parentTI = convType cenv emEnv mspec.EnclosingType + let parentTI = convType cenv emEnv mspec.DeclaringType let res = - if isEmittedTypeRef emEnv mref.EnclosingTypeRef then + if isEmittedTypeRef emEnv mref.DeclaringTypeRef then let consB = envGetConsB emEnv mref nonQueryableTypeGetConstructor parentTI consB else diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index 81fcf5be8ae..8ea9dec6a7a 100644 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -406,8 +406,8 @@ type ILTypeWriterEnv = { EnclosingTyparCount: int } let envForTypeDef (td:ILTypeDef) = { EnclosingTyparCount=td.GenericParams.Length } let envForMethodRef env (typ:ILType) = { EnclosingTyparCount=(match typ with ILType.Array _ -> env.EnclosingTyparCount | _ -> typ.GenericArgs.Length) } let envForNonGenericMethodRef _mref = { EnclosingTyparCount=System.Int32.MaxValue } -let envForFieldSpec (fspec:ILFieldSpec) = { EnclosingTyparCount=fspec.EnclosingType.GenericArgs.Length } -let envForOverrideSpec (ospec:ILOverridesSpec) = { EnclosingTyparCount=ospec.EnclosingType.GenericArgs.Length } +let envForFieldSpec (fspec:ILFieldSpec) = { EnclosingTyparCount=fspec.DeclaringType.GenericArgs.Length } +let envForOverrideSpec (ospec:ILOverridesSpec) = { EnclosingTyparCount=ospec.DeclaringType.GenericArgs.Length } //--------------------------------------------------------------------- // TABLES @@ -1285,7 +1285,7 @@ and GetFieldDefAsFieldDefIdx cenv tidx fd = // -------------------------------------------------------------------- let GetMethodRefAsMethodDefIdx cenv (mref:ILMethodRef) = - let tref = mref.EnclosingTypeRef + let tref = mref.DeclaringTypeRef try if not (isTypeRefLocal tref) then failwithf "method referred to by method impl, event or property is not in a type defined in this module, method ref is %A" mref @@ -1358,7 +1358,7 @@ and GetMethodSpecAsMethodDef cenv env (mspec, varargs) = and InfoOfMethodSpec (mspec:ILMethodSpec, varargs) = (mspec.Name, - mspec.EnclosingType, + mspec.DeclaringType, mspec.CallingConv, mspec.FormalArgTypes, mspec.FormalReturnType, @@ -1373,11 +1373,11 @@ and InfoOfMethodSpec (mspec:ILMethodSpec, varargs) = let rec GetOverridesSpecAsMemberRefIdx cenv env ospec = let fenv = envForOverrideSpec ospec - let row = MethodRefInfoAsMemberRefRow cenv env fenv (ospec.MethodRef.Name, ospec.EnclosingType, ospec.MethodRef.CallingConv, ospec.MethodRef.ArgTypes, ospec.MethodRef.ReturnType, None, ospec.MethodRef.GenericArity) + let row = MethodRefInfoAsMemberRefRow cenv env fenv (ospec.MethodRef.Name, ospec.DeclaringType, ospec.MethodRef.CallingConv, ospec.MethodRef.ArgTypes, ospec.MethodRef.ReturnType, None, ospec.MethodRef.GenericArity) FindOrAddSharedRow cenv TableNames.MemberRef row and GetOverridesSpecAsMethodDefOrRef cenv env (ospec:ILOverridesSpec) = - let typ = ospec.EnclosingType + let typ = ospec.DeclaringType if isTypeLocal typ then if not typ.IsNominal then failwith "GetOverridesSpecAsMethodDefOrRef: unexpected local tref-typ" try (mdor_MethodDef, GetMethodRefAsMethodDefIdx cenv ospec.MethodRef) @@ -1392,12 +1392,12 @@ and GetOverridesSpecAsMethodDefOrRef cenv env (ospec:ILOverridesSpec) = // -------------------------------------------------------------------- let rec GetMethodRefAsMemberRefIdx cenv env fenv (mref:ILMethodRef) = - let row = MethodRefInfoAsMemberRefRow cenv env fenv (mref.Name, mkILNonGenericBoxedTy mref.EnclosingTypeRef, mref.CallingConv, mref.ArgTypes, mref.ReturnType, None, mref.GenericArity) + let row = MethodRefInfoAsMemberRefRow cenv env fenv (mref.Name, mkILNonGenericBoxedTy mref.DeclaringTypeRef, mref.CallingConv, mref.ArgTypes, mref.ReturnType, None, mref.GenericArity) FindOrAddSharedRow cenv TableNames.MemberRef row and GetMethodRefAsCustomAttribType cenv (mref:ILMethodRef) = let fenv = envForNonGenericMethodRef mref - let tref = mref.EnclosingTypeRef + let tref = mref.DeclaringTypeRef if isTypeRefLocal tref then try (cat_MethodDef, GetMethodRefAsMethodDefIdx cenv mref) with MethodDefNotFound -> (cat_MemberRef, GetMethodRefAsMemberRefIdx cenv fenv fenv mref) @@ -1452,7 +1452,7 @@ and GenSecurityDeclsPass3 cenv hds attrs = // -------------------------------------------------------------------- let rec GetFieldSpecAsMemberRefRow cenv env fenv (fspec:ILFieldSpec) = - MemberRefRow (GetTypeAsMemberRefParent cenv env fspec.EnclosingType, + MemberRefRow (GetTypeAsMemberRefParent cenv env fspec.DeclaringType, GetStringHeapIdx cenv fspec.Name, GetFieldSpecSigAsBlobIdx cenv fenv fspec) @@ -1472,7 +1472,7 @@ and GetFieldSpecSigAsBlobIdx cenv env x = GetBytesAsBlobIdx cenv (GetFieldSpecSigAsBytes cenv env x) and GetFieldSpecAsFieldDefOrRef cenv env (fspec:ILFieldSpec) = - let typ = fspec.EnclosingType + let typ = fspec.DeclaringType if isTypeLocal typ then if not typ.IsNominal then failwith "GetFieldSpecAsFieldDefOrRef: unexpected local tref-typ" let tref = typ.TypeRef diff --git a/src/absil/ilx.fs b/src/absil/ilx.fs index afe285ae73f..d28ff3d2f4f 100644 --- a/src/absil/ilx.fs +++ b/src/absil/ilx.fs @@ -49,7 +49,7 @@ type IlxUnionRef = type IlxUnionSpec = | IlxUnionSpec of IlxUnionRef * ILGenericArgs - member x.EnclosingType = let (IlxUnionSpec(IlxUnionRef(bx, tref, _, _, _), inst)) = x in mkILNamedTy bx tref inst + member x.DeclaringType = let (IlxUnionSpec(IlxUnionRef(bx, tref, _, _, _), inst)) = x in mkILNamedTy bx tref inst member x.Boxity = let (IlxUnionSpec(IlxUnionRef(bx, _, _, _, _), _)) = x in bx member x.TypeRef = let (IlxUnionSpec(IlxUnionRef(_, tref, _, _, _), _)) = x in tref member x.GenericArgs = let (IlxUnionSpec(_, inst)) = x in inst diff --git a/src/absil/ilx.fsi b/src/absil/ilx.fsi index 6ee5eceef12..39792635fe7 100644 --- a/src/absil/ilx.fsi +++ b/src/absil/ilx.fsi @@ -44,7 +44,7 @@ type IlxUnionRef = type IlxUnionSpec = | IlxUnionSpec of IlxUnionRef * ILGenericArgs - member EnclosingType : ILType + member DeclaringType : ILType member GenericArgs : ILGenericArgs member Alternatives : IlxUnionAlternative list member AlternativesArray : IlxUnionAlternative[] diff --git a/src/fsharp/AccessibilityLogic.fs b/src/fsharp/AccessibilityLogic.fs index 006f225fec4..5f72c2a7577 100644 --- a/src/fsharp/AccessibilityLogic.fs +++ b/src/fsharp/AccessibilityLogic.fs @@ -226,9 +226,9 @@ let IsILFieldInfoAccessible g amap m ad x = match x with | ILFieldInfo (tinfo,fd) -> IsILTypeAndMemberAccessible g amap m ad ad tinfo fd.Access #if !NO_EXTENSIONTYPING - | ProvidedField (amap, tpfi, m) as pfi -> + | ProvidedField (amap, tpfi, m) -> let access = tpfi.PUntaint((fun fi -> ComputeILAccess fi.IsPublic fi.IsFamily fi.IsFamilyOrAssembly fi.IsFamilyAndAssembly), m) - IsProvidedMemberAccessible amap m ad pfi.EnclosingType access + IsProvidedMemberAccessible amap m ad x.LogicalEnclosingType access #endif let GetILAccessOfILEventInfo (ILEventInfo (tinfo,edef)) = @@ -314,12 +314,12 @@ let IsTypeAndMethInfoAccessible amap m adTyp ad = function #if !NO_EXTENSIONTYPING | ProvidedMeth(amap,tpmb,_,m) as etmi -> let access = tpmb.PUntaint((fun mi -> ComputeILAccess mi.IsPublic mi.IsFamily mi.IsFamilyOrAssembly mi.IsFamilyAndAssembly), m) - IsProvidedMemberAccessible amap m ad etmi.EnclosingType access + IsProvidedMemberAccessible amap m ad etmi.LogicalEnclosingType access #endif let IsMethInfoAccessible amap m ad minfo = IsTypeAndMethInfoAccessible amap m ad ad minfo let IsPropInfoAccessible g amap m ad = function - | ILProp (_,x) -> IsILPropInfoAccessible g amap m ad x + | ILProp ilpinfo -> IsILPropInfoAccessible g amap m ad ilpinfo | FSProp (_,_,Some vref,_) | FSProp (_,_,_,Some vref) -> IsValAccessible ad vref #if !NO_EXTENSIONTYPING @@ -334,7 +334,7 @@ let IsPropInfoAccessible g amap m ad = function | None -> tryGetILAccessForProvidedMethodBase(ppi.GetSetMethod()) | x -> x), m) defaultArg a ILMemberAccess.Public - IsProvidedMemberAccessible amap m ad pp.EnclosingType access + IsProvidedMemberAccessible amap m ad pp.LogicalEnclosingType access #endif | _ -> false diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index 66cf2bcc079..2f7b8a2014d 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -81,7 +81,7 @@ type AttribInfo = match x with | FSAttribInfo(_g,Attrib(tcref,_,_,_,_,_,_)) -> tcref | ILAttribInfo (g, amap, scoref, a, m) -> - let ty = ImportILType scoref amap m [] a.Method.EnclosingType + let ty = ImportILType scoref amap m [] a.Method.DeclaringType tcrefOfAppTy g ty member x.ConstructorArguments = @@ -154,7 +154,7 @@ let GetAttribInfosOfMethod amap m minfo = let GetAttribInfosOfProp amap m pinfo = match pinfo with - | ILProp(g,ilpinfo) -> ilpinfo.RawMetadata.CustomAttrs |> AttribInfosOfIL g amap ilpinfo.ILTypeInfo.ILScopeRef m + | ILProp ilpinfo -> ilpinfo.RawMetadata.CustomAttrs |> AttribInfosOfIL ilpinfo.TcGlobals amap ilpinfo.ILTypeInfo.ILScopeRef m | FSProp(g,_,Some vref,_) | FSProp(g,_,_,Some vref) -> vref.Attribs |> AttribInfosOfFS g | FSProp _ -> failwith "GetAttribInfosOfProp: unreachable" @@ -165,7 +165,7 @@ let GetAttribInfosOfProp amap m pinfo = let GetAttribInfosOfEvent amap m einfo = match einfo with - | ILEvent(g, x) -> x.RawMetadata.CustomAttrs |> AttribInfosOfIL g amap x.ILTypeInfo.ILScopeRef m + | ILEvent ileinfo -> ileinfo.RawMetadata.CustomAttrs |> AttribInfosOfIL einfo.TcGlobals amap ileinfo.ILTypeInfo.ILScopeRef m | FSEvent(_, pi, _vref1, _vref2) -> GetAttribInfosOfProp amap m pi #if !NO_EXTENSIONTYPING // TODO: provided attributes @@ -373,7 +373,7 @@ let CheckProvidedAttributesForUnseen (provAttribs: Tainted CheckILAttributes g pdef.CustomAttrs m + | ILProp(ILPropInfo(_,pdef)) -> CheckILAttributes pinfo.TcGlobals pdef.CustomAttrs m | FSProp(g,_,Some vref,_) | FSProp(g,_,_,Some vref) -> CheckFSharpAttributes g vref.Attribs m | FSProp _ -> failwith "CheckPropInfoAttributes: unreachable" @@ -436,7 +436,7 @@ let MethInfoIsUnseen g m typ minfo = #if !NO_EXTENSIONTYPING not (isObjTy g typ) && isAppTy g typ && - isObjTy g minfo.EnclosingType && + isObjTy g minfo.LogicalEnclosingType && let tcref = tcrefOfAppTy g typ match tcref.TypeReprInfo with | TProvidedTypeExtensionPoint info -> @@ -449,7 +449,7 @@ let MethInfoIsUnseen g m typ minfo = // just to look at the attributes on IL methods. if tcref.IsILTycon then tcref.ILTyconRawMetadata.CustomAttrs.AsList - |> List.exists (fun attr -> attr.Method.EnclosingType.TypeSpec.Name = typeof.FullName) + |> List.exists (fun attr -> attr.Method.DeclaringType.TypeSpec.Name = typeof.FullName) else false #else @@ -465,10 +465,10 @@ let MethInfoIsUnseen g m typ minfo = /// Used to suppress the item in intellisense. let PropInfoIsUnseen m pinfo = match pinfo with - | ILProp (g,(ILPropInfo(_,pdef) as ilpinfo)) -> + | ILProp (ILPropInfo(_,pdef) as ilpinfo) -> // Properties on .NET tuple types are resolvable but unseen - isAnyTupleTy g ilpinfo.ILTypeInfo.ToType || - CheckILAttributesForUnseen g pdef.CustomAttrs m + isAnyTupleTy pinfo.TcGlobals ilpinfo.ILTypeInfo.ToType || + CheckILAttributesForUnseen pinfo.TcGlobals pdef.CustomAttrs m | FSProp (g,_,Some vref,_) | FSProp (g,_,_,Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs m | FSProp _ -> failwith "CheckPropInfoAttributes: unreachable" diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 91dc8bb83bd..294521a4e3c 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1249,7 +1249,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = | _ :: ts -> hasUnitTType_app ts | [] -> false - match minfoVirt.EnclosingType with + match minfoVirt.LogicalEnclosingType with | TType_app (t, types) when t.IsFSharpInterfaceTycon && hasUnitTType_app types -> // match abstract member with 'unit' passed as generic argument os.Append(OverrideDoesntOverride4E().Format sig1) |> ignore @@ -1347,8 +1347,8 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = | NonUniqueInferredAbstractSlot(_, denv, bindnm, bvirt1, bvirt2, _) -> os.Append(NonUniqueInferredAbstractSlot1E().Format bindnm) |> ignore - let ty1 = bvirt1.EnclosingType - let ty2 = bvirt2.EnclosingType + let ty1 = bvirt1.LogicalEnclosingType + let ty2 = bvirt2.LogicalEnclosingType // REVIEW: consider if we need to show _cxs (the type parameter constraints) let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2 os.Append(NonUniqueInferredAbstractSlot2E().Format) |> ignore diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index 92364027de0..db032852db2 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -1035,7 +1035,7 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep | _, _, false, ("op_Addition" | "op_Subtraction" | "op_Modulus"), [argty1;argty2] when // Ignore any explicit +/- overloads from any basic integral types - (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.EnclosingType ) && + (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.LogicalEnclosingType ) && ( (IsNumericOrIntegralEnumType g argty1 || (nm = "op_Addition" && (isCharTy g argty1 || isStringTy g argty1))) && (permitWeakResolution || not (isTyparTy g argty2)) || (IsNumericOrIntegralEnumType g argty2 || (nm = "op_Addition" && (isCharTy g argty2 || isStringTy g argty2))) && (permitWeakResolution || not (isTyparTy g argty1)))) -> SolveTypEqualsTypKeepAbbrevs csenv ndeep m2 trace argty2 argty1 ++ (fun () -> @@ -1044,7 +1044,7 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep | _, _, false, ("op_LessThan" | "op_LessThanOrEqual" | "op_GreaterThan" | "op_GreaterThanOrEqual" | "op_Equality" | "op_Inequality" ), [argty1;argty2] when // Ignore any explicit overloads from any basic integral types - (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.EnclosingType ) && + (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.LogicalEnclosingType ) && ( (IsRelationalType g argty1 && (permitWeakResolution || not (isTyparTy g argty2))) || (IsRelationalType g argty2 && (permitWeakResolution || not (isTyparTy g argty1))))) -> SolveTypEqualsTypKeepAbbrevs csenv ndeep m2 trace argty2 argty1 ++ (fun () -> @@ -1286,9 +1286,9 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep let isInstance = minfo.IsInstance if isInstance <> memFlags.IsInstance then if isInstance then - ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsNotStatic((NicePrint.minimalStringOfType denv minfo.EnclosingType), (DecompileOpName nm), nm), m, m2 )) + ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsNotStatic((NicePrint.minimalStringOfType denv minfo.LogicalEnclosingType), (DecompileOpName nm), nm), m, m2 )) else - ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsStatic((NicePrint.minimalStringOfType denv minfo.EnclosingType), (DecompileOpName nm), nm), m, m2 )) + ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsStatic((NicePrint.minimalStringOfType denv minfo.LogicalEnclosingType), (DecompileOpName nm), nm), m, m2 )) else CheckMethInfoAttributes g m None minfo ++ (fun () -> ResultD (TTraitSolved (minfo, calledMeth.CalledTyArgs)))) @@ -1337,8 +1337,8 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst = match minfo with | ILMeth(_, ilMeth, _) -> let mref = IL.mkRefToILMethod (ilMeth.DeclaringTyconRef.CompiledRepresentationForNamedType, ilMeth.RawMetadata) - let iltref = ilMeth.DeclaringTyconRefOption |> Option.map (fun tcref -> tcref.CompiledRepresentationForNamedType) - ILMethSln(ilMeth.ApparentEnclosingType, iltref, mref, minst) + let iltref = ilMeth.ILExtensionMethodDeclaringTyconRef |> Option.map (fun tcref -> tcref.CompiledRepresentationForNamedType) + ILMethSln(ilMeth.LogicalEnclosingType, iltref, mref, minst) | FSMeth(_, typ, vref, _) -> FSMethSln(typ, vref, minst) | MethInfo.DefaultStructCtor _ -> @@ -1348,7 +1348,7 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst = let g = amap.g let minst = [] // GENERIC TYPE PROVIDERS: for generics, we would have an minst here let allArgVars, allArgs = minfo.GetParamTypes(amap, m, minst) |> List.concat |> List.mapi (fun i ty -> mkLocal m ("arg"+string i) ty) |> List.unzip - let objArgVars, objArgs = (if minfo.IsInstance then [mkLocal m "this" minfo.EnclosingType] else []) |> List.unzip + let objArgVars, objArgs = (if minfo.IsInstance then [mkLocal m "this" minfo.LogicalEnclosingType] else []) |> List.unzip let callMethInfoOpt, callExpr, callExprTy = ProvidedMethodCalls.BuildInvokerExpressionForProvidedMethodCall css.TcVal (g, amap, mi, objArgs, NeverMutates, false, ValUseFlag.NormalValUse, allArgs, m) let closedExprSln = ClosedExprSln (mkLambdas m [] (objArgVars@allArgVars) (callExpr, callExprTy) ) // If the call is a simple call to an IL method with all the arguments in the natural order, then revert to use ILMethSln. @@ -2040,7 +2040,7 @@ and ReportNoCandidatesError (csenv:ConstraintSolverEnv) (nUnnamedCallerArgs, nNa | CallerNamedArg(id, _) :: _ -> if minfo.IsConstructor then let predictFields() = - minfo.DeclaringEntityRef.AllInstanceFieldsAsList + minfo.DeclaringTyconRef.AllInstanceFieldsAsList |> List.map (fun p -> p.Name.Replace("@", "")) |> System.Collections.Generic.HashSet @@ -2207,7 +2207,7 @@ and ResolveOverloading if isOpConversion then match calledMethGroup, reqdRetTyOpt with | h :: _, Some rty -> - Some (h.Method.EnclosingType, rty) + Some (h.Method.LogicalEnclosingType, rty) | _ -> None else None diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 13e1f5bd67f..3b91db9f700 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -1505,7 +1505,7 @@ let GenConstArray cenv (cgbuf:CodeGenBuffer) eenv ilElementType (data:'a[]) (wri let ilFieldDef = { ilFieldDef with CustomAttrs = mkILCustomAttrs [ cenv.g.DebuggerBrowsableNeverAttribute ] } let fspec = mkILFieldSpecInTy (mkILTyForCompLoc eenv.cloc,ilFieldName, fty) CountStaticFieldDef() - cgbuf.mgbuf.AddFieldDef(fspec.EnclosingTypeRef,ilFieldDef) + cgbuf.mgbuf.AddFieldDef(fspec.DeclaringTypeRef,ilFieldDef) CG.EmitInstrs cgbuf (pop 0) (Push [ ilArrayType; ilArrayType; cenv.g.iltyp_RuntimeFieldHandle ]) @@ -2171,7 +2171,7 @@ and GenAllocExn cenv cgbuf eenv (c,args,m) sequel = and GenAllocUnionCase cenv cgbuf eenv (c,tyargs,args,m) sequel = GenExprs cenv cgbuf eenv args let cuspec,idx = GenUnionCaseSpec cenv.amap m eenv.tyenv c tyargs - CG.EmitInstrs cgbuf (pop args.Length) (Push [cuspec.EnclosingType]) (EraseUnions.mkNewData cenv.g.ilg (cuspec, idx)) + CG.EmitInstrs cgbuf (pop args.Length) (Push [cuspec.DeclaringType]) (EraseUnions.mkNewData cenv.g.ilg (cuspec, idx)) GenSequel cenv eenv.cloc cgbuf sequel and GenAllocRecd cenv cgbuf eenv ctorInfo (tcref,argtys,args,m) sequel = @@ -2361,7 +2361,7 @@ and GenSetUnionCaseField cenv cgbuf eenv (e,ucref,tyargs,n,e2,m) sequel = let cuspec,idx = GenUnionCaseSpec cenv.amap m eenv.tyenv ucref tyargs let avoidHelpers = entityRefInThisAssembly cenv.g.compilingFslib ucref.TyconRef EraseUnions.emitCastData cenv.g.ilg (UnionCodeGen cgbuf) (false,avoidHelpers,cuspec,idx) - CG.EmitInstrs cgbuf (pop 1) (Push [cuspec.EnclosingType]) [ ] // push/pop to match the line above + CG.EmitInstrs cgbuf (pop 1) (Push [cuspec.DeclaringType]) [ ] // push/pop to match the line above GenExpr cenv cgbuf eenv SPSuppress e2 Continue CG.EmitInstrs cgbuf (pop 2) Push0 (EraseUnions.mkStData (cuspec, idx, n)) GenUnitThenSequel cenv eenv m eenv.cloc cgbuf sequel @@ -2406,7 +2406,7 @@ and GenFieldGet isStatic cenv cgbuf eenv (rfref:RecdFieldRef,tyargs,m) = CG.EmitInstrs cgbuf (mk_field_pops isStatic 0) (Push [fspec.ActualType]) [ instr ] else let cconv = if isStatic then ILCallingConv.Static else ILCallingConv.Instance - let mspec = mkILMethSpecInTy (fspec.EnclosingType,cconv, "get_" + rfref.RecdField.rfield_id.idText, [], fspec.FormalType, []) + let mspec = mkILMethSpecInTy (fspec.DeclaringType,cconv, "get_" + rfref.RecdField.rfield_id.idText, [], fspec.FormalType, []) CG.EmitInstr cgbuf (mk_field_pops isStatic 0) (Push [fspec.ActualType]) (mkNormalCall mspec) and GenFieldStore isStatic cenv cgbuf eenv (rfref:RecdFieldRef,tyargs,m) sequel = @@ -2414,7 +2414,7 @@ and GenFieldStore isStatic cenv cgbuf eenv (rfref:RecdFieldRef,tyargs,m) sequel let fld = rfref.RecdField if fld.IsMutable && not (useGenuineField rfref.Tycon fld) then let cconv = if isStatic then ILCallingConv.Static else ILCallingConv.Instance - let mspec = mkILMethSpecInTy (fspec.EnclosingType, cconv, "set_" + fld.rfield_id.idText, [fspec.FormalType],ILType.Void,[]) + let mspec = mkILMethSpecInTy (fspec.DeclaringType, cconv, "set_" + fld.rfield_id.idText, [fspec.FormalType],ILType.Void,[]) CG.EmitInstr cgbuf (mk_field_pops isStatic 1) Push0 (mkNormalCall mspec) else let vol = if rfref.RecdField.IsVolatile then Volatile else Nonvolatile @@ -2610,7 +2610,7 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = if ilTyArgs.Length < numEnclILTypeArgs then error(InternalError("length mismatch",m)) List.chop numEnclILTypeArgs ilTyArgs - let boxity = mspec.EnclosingType.Boxity + let boxity = mspec.DeclaringType.Boxity let mspec = mkILMethSpec (mspec.MethodRef, boxity,ilEnclArgTys,ilMethArgTys) // "Unit" return types on static methods become "void" @@ -2645,7 +2645,7 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = // ok, now we're ready to generate if isSuperInit || isSelfInit then - CG.EmitInstrs cgbuf (pop 0) (Push [mspec.EnclosingType ]) [ mkLdarg0 ] + CG.EmitInstrs cgbuf (pop 0) (Push [mspec.DeclaringType ]) [ mkLdarg0 ] GenUntupledArgsDiscardingLoneUnit cenv cgbuf eenv m vref.NumObjArgs curriedArgInfos nowArgs @@ -2668,7 +2668,7 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = (if mustGenerateUnitAfterCall || isSuperInit || isSelfInit then Push0 else (Push [(GenType cenv.amap m eenv.tyenv actualRetTy)])) callInstr // For isSuperInit, load the 'this' pointer as the pretend 'result' of the operation. It will be popped again in most cases - if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [mspec.EnclosingType]) [ mkLdarg0 ] + if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [mspec.DeclaringType]) [ mkLdarg0 ] // When generating debug code, generate a 'nop' after a 'call' that returns 'void' // This is what C# does, as it allows the call location to be maintained correctly in the stack frame @@ -3098,8 +3098,8 @@ and GenAsmCode cenv cgbuf eenv (il,tyargs,args,returnTys,m) sequel = if isNil ilTyArgs then fspec else - {fspec with EnclosingType= - let ty = fspec.EnclosingType + {fspec with DeclaringType= + let ty = fspec.DeclaringType let tspec = ty.TypeSpec mkILTy ty.Boxity (mkILTySpec(tspec.TypeRef, ilTyArgs)) } match i,ilTyArgs with @@ -3306,7 +3306,7 @@ and GenILCall cenv cgbuf eenv (virt,valu,newobj,valUseFlags,isDllImport,ilMethRe // Load the 'this' pointer to pass to the superclass constructor. This argument is not // in the expression tree since it can't be treated like an ordinary value - if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [ilMethSpec.EnclosingType]) [ mkLdarg0 ] + if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [ilMethSpec.DeclaringType]) [ mkLdarg0 ] GenExprs cenv cgbuf eenv argExprs let il = if newobj then [ I_newobj(ilMethSpec,None) ] @@ -3323,7 +3323,7 @@ and GenILCall cenv cgbuf eenv (virt,valu,newobj,valUseFlags,isDllImport,ilMethRe // Load the 'this' pointer as the pretend 'result' of the isSuperInit operation. // It will be immediately popped in most cases, but may also be used as the target of some "property set" operations. - if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [ilMethSpec.EnclosingType]) [ mkLdarg0 ] + if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [ilMethSpec.DeclaringType]) [ mkLdarg0 ] CommitCallSequel cenv eenv m eenv.cloc cgbuf mustGenerateUnitAfterCall sequel and CommitCallSequel cenv eenv m cloc cgbuf mustGenerateUnitAfterCall sequel = @@ -4740,7 +4740,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec,rhsExpr,_)) sta Init = None Args = [] CustomAttrs = mkILCustomAttrs ilAttribs } - cgbuf.mgbuf.AddOrMergePropertyDef(ilGetterMethSpec.MethodRef.EnclosingTypeRef, ilPropDef,m) + cgbuf.mgbuf.AddOrMergePropertyDef(ilGetterMethSpec.MethodRef.DeclaringTypeRef, ilPropDef,m) let ilMethodDef = let ilMethodBody = MethodBody.IL(CodeGenMethodForExpr cenv cgbuf.mgbuf (SPSuppress, [], ilGetterMethSpec.Name, eenv, 0, 0, rhsExpr, Return)) @@ -4749,7 +4749,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec,rhsExpr,_)) sta |> AddNonUserCompilerGeneratedAttribs cenv.g CountMethodDef() - cgbuf.mgbuf.AddMethodDef(ilGetterMethSpec.MethodRef.EnclosingTypeRef, ilMethodDef) + cgbuf.mgbuf.AddMethodDef(ilGetterMethSpec.MethodRef.DeclaringTypeRef, ilMethodDef) CommitStartScope cgbuf startScopeMarkOpt match optShadowLocal with @@ -4794,7 +4794,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec,rhsExpr,_)) sta { ilFieldDef with CustomAttrs = mkILCustomAttrs (ilAttribs @ [ cenv.g.DebuggerBrowsableNeverAttribute ]) } - [ (fspec.EnclosingTypeRef, ilFieldDef) ] + [ (fspec.DeclaringTypeRef, ilFieldDef) ] let ilTypeRefForProperty = ilTyForProperty.TypeRef @@ -5066,7 +5066,7 @@ and GenEventForProperty cenv eenvForMeth (mspec:ILMethodSpec) (v:Val) ilAttrsTha let evname = v.PropertyName let delegateTy = Infos.FindDelegateTypeOfPropertyEvent cenv.g cenv.amap evname m returnTy let ilDelegateTy = GenType cenv.amap m eenvForMeth.tyenv delegateTy - let ilThisTy = mspec.EnclosingType + let ilThisTy = mspec.DeclaringType let addMethRef = mkILMethRef (ilThisTy.TypeRef,mspec.CallingConv,"add_" + evname,0,[ilDelegateTy],ILType.Void) let removeMethRef = mkILMethRef (ilThisTy.TypeRef,mspec.CallingConv,"remove_" + evname,0,[ilDelegateTy],ILType.Void) { Type = Some(ilDelegateTy) @@ -5238,7 +5238,7 @@ and GenMethodForBinding let ilParams = GenParams cenv eenv mspec paramInfos (Some(nonUnitNonSelfMethodVars)) let ilReturn = GenReturnInfo cenv eenv mspec.FormalReturnType retInfo let methName = mspec.Name - let tref = mspec.MethodRef.EnclosingTypeRef + let tref = mspec.MethodRef.DeclaringTypeRef let EmitTheMethodDef mdef = // Does the function have an explicit [] attribute? @@ -5275,7 +5275,7 @@ and GenMethodForBinding () | Some(memberInfo) when not v.IsExtensionMember -> - let ilMethTypars = ilTypars |> List.drop mspec.EnclosingType.GenericArgs.Length + let ilMethTypars = ilTypars |> List.drop mspec.DeclaringType.GenericArgs.Length if memberInfo.MemberFlags.MemberKind = MemberKind.Constructor then assert (isNil ilMethTypars) let mdef = mkILCtor (access,ilParams,ilMethodBody) @@ -7016,7 +7016,7 @@ let LookupGeneratedValue (amap:ImportMap) (ctxt: ExecutionContext) eenv (v:Val) | StaticField (fspec, _, hasLiteralAttr, ilContainerTy, _, _, ilGetterMethRef, _, _) -> let obj = if hasLiteralAttr then - let staticTyp = ctxt.LookupTypeRef fspec.EnclosingTypeRef + let staticTyp = ctxt.LookupTypeRef fspec.DeclaringTypeRef // Checked: This FieldInfo (FieldBuilder) supports GetValue(). staticTyp.GetField(fspec.Name).GetValue(null:obj) else @@ -7030,7 +7030,7 @@ let LookupGeneratedValue (amap:ImportMap) (ctxt: ExecutionContext) eenv (v:Val) | StaticProperty (ilGetterMethSpec, _) -> let obj = - let staticTyp = ctxt.LookupTypeRef ilGetterMethSpec.MethodRef.EnclosingTypeRef + let staticTyp = ctxt.LookupTypeRef ilGetterMethSpec.MethodRef.DeclaringTypeRef // We can't call .Invoke on the ILMethodRef's MethodInfo, // because it is the MethodBuilder and that does not support Invoke. // Rather, we look for the getter MethodInfo from the built type and .Invoke on that. @@ -7057,7 +7057,7 @@ let ClearGeneratedValue (ctxt: ExecutionContext) (_g:TcGlobals) eenv (v:Val) = match StorageForVal v.Range v eenv with | StaticField (fspec, _, hasLiteralAttr, _, _, _, _ilGetterMethRef, ilSetterMethRef, _) -> if not hasLiteralAttr && v.IsMutable then - let staticTyp = ctxt.LookupTypeRef ilSetterMethRef.EnclosingTypeRef + let staticTyp = ctxt.LookupTypeRef ilSetterMethRef.DeclaringTypeRef let typ = ctxt.LookupType fspec.ActualType let methInfo = staticTyp.GetMethod(ilSetterMethRef.Name, BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic) diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index e2a7c073f91..eabc0bf862c 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -154,7 +154,7 @@ let rec GetImmediateIntrinsicPropInfosOfTypeAux (optFilter,ad) g amap m origTy m let tinfo = ILTypeInfo.FromType g origTy let pdefs = tinfo.RawMetadata.Properties let pdefs = match optFilter with None -> pdefs.AsList | Some nm -> pdefs.LookupByName nm - pdefs |> List.map (fun pdef -> ILProp(g,ILPropInfo(tinfo, pdef))) + pdefs |> List.map (fun pdef -> ILProp(ILPropInfo(tinfo, pdef))) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> // Tuple types also support the properties Item1-8, Rest from the compiled tuple type @@ -249,9 +249,9 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) = let edefs = tinfo.RawMetadata.Events let edefs = match optFilter with None -> edefs.AsList | Some nm -> edefs.LookupByName nm [ for edef in edefs do - let einfo = ILEventInfo(tinfo,edef) - if IsILEventInfoAccessible g amap m ad einfo then - yield ILEvent(g,einfo) ] + let ileinfo = ILEventInfo(tinfo,edef) + if IsILEventInfoAccessible g amap m ad ileinfo then + yield ILEvent ileinfo ] | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> [] infos @@ -632,7 +632,7 @@ let ExcludeHiddenOfMethInfos g amap m (minfos:MethInfo list list) = (fun minfo -> minfo.LogicalName) (fun m1 m2 -> // only hide those truly from super classes - not (tyconRefEq g m1.DeclaringEntityRef m2.DeclaringEntityRef) && + not (tyconRefEq g m1.DeclaringTyconRef m2.DeclaringTyconRef) && MethInfosEquivByNameAndPartialSig EraseNone true g amap m m1 m2) |> List.concat diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index fd442d1f09e..cffc3d43fc1 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -295,7 +295,7 @@ type CalledMeth<'T> [] let assignedNamedProps,unassignedNamedItems = - let returnedObjTy = if minfo.IsConstructor then minfo.EnclosingType else methodRetTy + let returnedObjTy = if minfo.IsConstructor then minfo.LogicalEnclosingType else methodRetTy unassignedNamedItems |> List.splitChoose (fun (CallerNamedArg(id,e) as arg) -> let nm = id.idText let pinfos = GetIntrinsicPropInfoSetsOfType infoReader (Some(nm),ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides id.idRange returnedObjTy @@ -509,7 +509,7 @@ let IsBaseCall objArgs = let ComputeConstrainedCallInfo g amap m (objArgs,minfo:MethInfo) = match objArgs with | [objArgExpr] when not minfo.IsExtensionMember -> - let methObjTy = minfo.EnclosingType + let methObjTy = minfo.LogicalEnclosingType let objArgTy = tyOfExpr g objArgExpr if TypeDefinitelySubsumesTypeNoCoercion 0 g amap m methObjTy objArgTy // Constrained calls to class types can only ever be needed for the three class types that @@ -546,8 +546,8 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f = // Extension members and calls to class constraints may need a coercion for their object argument let objArgExpr' = if Option.isNone ccallInfo && // minfo.IsExtensionMember && minfo.IsStruct && - not (TypeDefinitelySubsumesTypeNoCoercion 0 g amap m minfo.EnclosingType objArgTy) then - mkCoerceExpr(objArgExpr',minfo.EnclosingType,m,objArgTy) + not (TypeDefinitelySubsumesTypeNoCoercion 0 g amap m minfo.LogicalEnclosingType objArgTy) then + mkCoerceExpr(objArgExpr',minfo.LogicalEnclosingType,m,objArgTy) else objArgExpr' @@ -569,7 +569,7 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f = /// Build an expression node that is a call to a .NET method. let BuildILMethInfoCall g amap m isProp (minfo:ILMethInfo) valUseFlags minst direct args = - let valu = isStructTy g minfo.ApparentEnclosingType + let valu = isStructTy g minfo.LogicalEnclosingType let ctor = minfo.IsConstructor if minfo.IsClassConstructor then error (InternalError (minfo.ILName+": cannot call a class constructor",m)) @@ -578,7 +578,7 @@ let BuildILMethInfoCall g amap m isProp (minfo:ILMethInfo) valUseFlags minst dir let isProtected = minfo.IsProtectedAccessibility let ilMethRef = minfo.ILMethodRef let newobj = ctor && (match valUseFlags with NormalValUse -> true | _ -> false) - let exprTy = if ctor then minfo.ApparentEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) + let exprTy = if ctor then minfo.LogicalEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) let retTy = (if not ctor && (ilMethRef.ReturnType = ILType.Void) then [] else [exprTy]) let isDllImport = minfo.IsDllImport g Expr.Op(TOp.ILCall(useCallvirt,isProtected,valu,newobj,valUseFlags,isProp,isDllImport,ilMethRef,minfo.DeclaringTypeInst,minst,retTy),[],args,m), @@ -717,7 +717,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA // TODO: there is a fair bit of duplication here with mk_il_minfo_call. We should be able to merge these /// Build an expression node that is a call to a extension method in a generated assembly - let enclTy = minfo.EnclosingType + let enclTy = minfo.LogicalEnclosingType // prohibit calls to methods that are declared in specific array types (Get,Set,Address) // these calls are provided by the runtime and should not be called from the user code if isArrayTy g enclTy then diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 236addea0ae..1859b693545 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -83,7 +83,7 @@ module DispatchSlotChecking = let (CompiledSig (argTys,retTy,fmtps,ttpinst)) = CompiledSigOfMeth g amap m minfo let isFakeEventProperty = minfo.IsFSharpEventPropertyMethod - Override(parentType,tcrefOfAppTy g minfo.EnclosingAppType,mkSynId m nm, (fmtps,ttpinst),argTys,retTy,isFakeEventProperty,false) + Override(parentType,tcrefOfAppTy g minfo.LogicalEnclosingAppType,mkSynId m nm, (fmtps,ttpinst),argTys,retTy,isFakeEventProperty,false) /// Get the override info for a value being used to implement a dispatch slot. let GetTypeMemberOverrideInfo g reqdTy (overrideBy:ValRef) = @@ -160,9 +160,9 @@ module DispatchSlotChecking = (match overrideBy.CanImplement with | CanImplementNoSlots -> false | CanImplementAnySlot -> true - | CanImplementAnyClassHierarchySlot -> not (isInterfaceTy g dispatchSlot.EnclosingType) - //| CanImplementSpecificInterfaceSlot parentTy -> isInterfaceTy g dispatchSlot.EnclosingType && typeEquiv g parentTy dispatchSlot.EnclosingType - | CanImplementAnyInterfaceSlot -> isInterfaceTy g dispatchSlot.EnclosingType) + | CanImplementAnyClassHierarchySlot -> not (isInterfaceTy g dispatchSlot.LogicalEnclosingType) + //| CanImplementSpecificInterfaceSlot parentTy -> isInterfaceTy g dispatchSlot.LogicalEnclosingType && typeEquiv g parentTy dispatchSlot.LogicalEnclosingType + | CanImplementAnyInterfaceSlot -> isInterfaceTy g dispatchSlot.LogicalEnclosingType) /// Check if the kinds of type parameters match between a dispatch slot and an override. let IsTyparKindMatch g amap m (dispatchSlot:MethInfo) (Override(_,_,_,(mtps,_),_,_,_,_)) = @@ -235,9 +235,8 @@ module DispatchSlotChecking = /// Check if an override implements a dispatch slot let OverrideImplementsDispatchSlot g amap m dispatchSlot availPriorOverride = IsExactMatch g amap m dispatchSlot availPriorOverride && - isAppTy g dispatchSlot.EnclosingType && // The override has to actually be in some subtype of the dispatch slot - ExistsHeadTypeInEntireHierarchy g amap m (generalizedTyconRef availPriorOverride.BoundingTyconRef) (tcrefOfAppTy g dispatchSlot.EnclosingType) + ExistsHeadTypeInEntireHierarchy g amap m (generalizedTyconRef availPriorOverride.BoundingTyconRef) dispatchSlot.DeclaringTyconRef /// Check if a dispatch slot is already implemented let DispatchSlotIsAlreadyImplemented g amap m availPriorOverridesKeyed (dispatchSlot: MethInfo) = @@ -364,11 +363,11 @@ module DispatchSlotChecking = | [dispatchSlot] -> - if dispatchSlot.IsFinal && (isObjExpr || not (typeEquiv g reqdTy dispatchSlot.EnclosingType)) then + if dispatchSlot.IsFinal && (isObjExpr || not (typeEquiv g reqdTy dispatchSlot.LogicalEnclosingType)) then errorR(Error(FSComp.SR.typrelMethodIsSealed(NicePrint.stringOfMethInfo amap m denv dispatchSlot),m)) | dispatchSlots -> match dispatchSlots |> List.filter (fun dispatchSlot -> - isInterfaceTy g dispatchSlot.EnclosingType || + isInterfaceTy g dispatchSlot.LogicalEnclosingType || not (DispatchSlotIsAlreadyImplemented g amap m availPriorOverridesKeyed dispatchSlot)) with | h1 :: h2 :: _ -> errorR(Error(FSComp.SR.typrelOverrideImplementsMoreThenOneSlot((FormatOverride denv overrideBy), (NicePrint.stringOfMethInfo amap m denv h1), (NicePrint.stringOfMethInfo amap m denv h2)),m)) @@ -376,7 +375,7 @@ module DispatchSlotChecking = // dispatch slots are ordered from the derived classes to base // so we can check the topmost dispatch slot if it is final match dispatchSlots with - | meth::_ when meth.IsFinal -> errorR(Error(FSComp.SR.tcCannotOverrideSealedMethod((sprintf "%s::%s" (meth.EnclosingType.ToString()) (meth.LogicalName))), m)) + | meth::_ when meth.IsFinal -> errorR(Error(FSComp.SR.tcCannotOverrideSealedMethod((sprintf "%s::%s" (meth.LogicalEnclosingType.ToString()) (meth.LogicalName))), m)) | _ -> () @@ -507,7 +506,7 @@ module DispatchSlotChecking = // We also collect up the properties. This is used for abstract slot inference when overriding properties let isRelevantRequiredProperty (x:PropInfo) = (x.IsVirtualProperty && not (isInterfaceTy g reqdTy)) || - isImpliedInterfaceType x.EnclosingType + isImpliedInterfaceType x.LogicalEnclosingType let reqdProperties = GetIntrinsicPropInfosOfType infoReader (None,AccessibleFromSomewhere,AllowMultiIntfInstantiations.Yes) IgnoreOverrides reqdTyRange reqdTy @@ -611,8 +610,7 @@ module DispatchSlotChecking = let overridenForThisSlotImplSet = [ for (RequiredSlot(dispatchSlot,_)) in NameMultiMap.find overrideByInfo.LogicalName dispatchSlotsKeyed do if OverrideImplementsDispatchSlot g amap m dispatchSlot overrideByInfo then - if isAppTy g dispatchSlot.EnclosingType && - tyconRefEq g overrideByInfo.BoundingTyconRef (tcrefOfAppTy g dispatchSlot.EnclosingType) then + if tyconRefEq g overrideByInfo.BoundingTyconRef dispatchSlot.DeclaringTyconRef then match dispatchSlot.ArbitraryValRef with | Some virtMember -> if virtMember.MemberInfo.Value.IsImplemented then errorR(Error(FSComp.SR.tcDefaultImplementationAlreadyExists(),overrideByInfo.Range)) diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index b2d9d02f46d..54ad14b4191 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -1300,7 +1300,7 @@ let (|EntityUse|_|) (item: Item) = | Item.DelegateCtor(AbbrevOrAppTy tcref) | Item.FakeInterfaceCtor(AbbrevOrAppTy tcref) -> Some tcref | Item.CtorGroup(_, ctor::_) -> - match ctor.EnclosingType with + match ctor.LogicalEnclosingType with | AbbrevOrAppTy tcref -> Some tcref | _ -> None | _ -> None @@ -1610,7 +1610,7 @@ let CheckAllTyparsInferrable amap m item = | Item.Property(_,pinfos) -> pinfos |> List.forall (fun pinfo -> pinfo.IsExtensionMember || - let freeInDeclaringType = freeInType CollectTyparsNoCaching pinfo.EnclosingType + let freeInDeclaringType = freeInType CollectTyparsNoCaching pinfo.LogicalEnclosingType let freeInArgsAndRetType = accFreeInTypes CollectTyparsNoCaching (pinfo.GetParamTypes(amap,m)) (freeInType CollectTyparsNoCaching (pinfo.GetPropertyType(amap,m))) @@ -1621,7 +1621,7 @@ let CheckAllTyparsInferrable amap m item = minfos |> List.forall (fun minfo -> minfo.IsExtensionMember || let fminst = minfo.FormalMethodInst - let freeInDeclaringType = freeInType CollectTyparsNoCaching minfo.EnclosingType + let freeInDeclaringType = freeInType CollectTyparsNoCaching minfo.LogicalEnclosingType let freeInArgsAndRetType = List.foldBack (accFreeInTypes CollectTyparsNoCaching) (minfo.GetParamTypes(amap, m, fminst)) (accFreeInTypes CollectTyparsNoCaching (minfo.GetObjArgTypes(amap, m, fminst)) @@ -1908,7 +1908,7 @@ let ExtensionPropInfosOfTypeInScope (infoReader:InfoReader) (nenv: NameResolutio let extMemsFromHierarchy = infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,typ) |> List.collect (fun typ -> - if (isAppTy g typ) then + if isAppTy g typ then let tcref = tcrefOfAppTy g typ let extMemInfos = nenv.eIndexedExtensionMembers.Find tcref SelectPropInfosFromExtMembers (infoReader,ad,optFilter) typ m extMemInfos @@ -1971,7 +1971,7 @@ let ExtensionMethInfosOfTypeInScope (infoReader:InfoReader) (nenv: NameResolutio let extMemsFromHierarchy = infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,typ) |> List.collect (fun typ -> let g = infoReader.g - if (isAppTy g typ) then + if isAppTy g typ then let tcref = tcrefOfAppTy g typ let extValRefs = nenv.eIndexedExtensionMembers.Find tcref SelectMethInfosFromExtMembers infoReader optFilter typ m extValRefs @@ -2012,7 +2012,7 @@ let CoreDisplayName(pinfo:PropInfo) = | FSProp(_,_,_,Some set) -> set.CoreDisplayName | FSProp(_,_,Some get,_) -> get.CoreDisplayName | FSProp _ -> failwith "unexpected (property must have either getter or setter)" - | ILProp(_,ILPropInfo(_,def)) -> def.Name + | ILProp(ILPropInfo(_,def)) -> def.Name #if !NO_EXTENSIONTYPING | ProvidedProp(_,pi,m) -> pi.PUntaint((fun pi -> pi.Name), m) #endif @@ -2021,8 +2021,8 @@ let DecodeFSharpEvent (pinfos:PropInfo list) ad g (ncenv:NameResolver) m = match pinfos with | [pinfo] when pinfo.IsFSharpEventProperty -> let nm = CoreDisplayName(pinfo) - let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+nm),ad) g ncenv.amap m pinfo.EnclosingType - let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+nm),ad) g ncenv.amap m pinfo.EnclosingType + let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+nm),ad) g ncenv.amap m pinfo.LogicalEnclosingType + let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+nm),ad) g ncenv.amap m pinfo.LogicalEnclosingType match minfos1,minfos2 with | [FSMeth(_,_,addValRef,_)],[FSMeth(_,_,removeValRef,_)] -> // FOUND PROPERTY-AS-EVENT AND CORRESPONDING ADD/REMOVE METHODS @@ -3509,8 +3509,8 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso let (SigOfFunctionForDelegate(invokeMethInfo,_,_,_)) = GetSigOfFunctionForDelegate ncenv.InfoReader delegateType m ad // Only events with void return types are suppressed in intellisense. if slotSigHasVoidReturnTy (invokeMethInfo.GetSlotSig(amap, m)) then - yield einfo.GetAddMethod().DisplayName - yield einfo.GetRemoveMethod().DisplayName ] + yield einfo.AddMethod.DisplayName + yield einfo.RemoveMethod.DisplayName ] else [] let suppressedMethNames = Zset.ofList String.order (pinfoMethNames @ einfoMethNames) @@ -3534,10 +3534,10 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso not minfo.IsExtensionMember && match minfo.LogicalName with | "GetType" -> false - | "GetHashCode" -> isObjTy g minfo.EnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) + | "GetHashCode" -> isObjTy g minfo.LogicalEnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) | "ToString" -> false | "Equals" -> - if not (isObjTy g minfo.EnclosingType) then + if not (isObjTy g minfo.LogicalEnclosingType) then // declaring type is not System.Object - show it false elif minfo.IsInstance then @@ -3548,7 +3548,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso true | _ -> // filter out self methods of obj type - isObjTy g minfo.EnclosingType + isObjTy g minfo.LogicalEnclosingType let result = not isUnseenDueToBasicObjRules && @@ -4149,8 +4149,8 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ let (SigOfFunctionForDelegate(invokeMethInfo,_,_,_)) = GetSigOfFunctionForDelegate ncenv.InfoReader delegateType m ad // Only events with void return types are suppressed in intellisense. if slotSigHasVoidReturnTy (invokeMethInfo.GetSlotSig(amap, m)) then - yield einfo.GetAddMethod().DisplayName - yield einfo.GetRemoveMethod().DisplayName ] + yield einfo.AddMethod.DisplayName + yield einfo.RemoveMethod.DisplayName ] let suppressedMethNames = Zset.ofList String.order (pinfoMethNames @ einfoMethNames) @@ -4168,10 +4168,10 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ not minfo.IsExtensionMember && match minfo.LogicalName with | "GetType" -> false - | "GetHashCode" -> isObjTy g minfo.EnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) + | "GetHashCode" -> isObjTy g minfo.LogicalEnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) | "ToString" -> false | "Equals" -> - if not (isObjTy g minfo.EnclosingType) then + if not (isObjTy g minfo.LogicalEnclosingType) then // declaring type is not System.Object - show it false elif minfo.IsInstance then @@ -4182,7 +4182,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ true | _ -> // filter out self methods of obj type - isObjTy g minfo.EnclosingType + isObjTy g minfo.LogicalEnclosingType let result = not isUnseenDueToBasicObjRules && not minfo.IsInstance = statics && diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index c5a8b19ef99..ac5afb3973f 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -659,11 +659,11 @@ module private PrintTypes = match k with | ILAttrib ilMethRef -> let trimmedName = - let name = ilMethRef.EnclosingTypeRef.Name + let name = ilMethRef.DeclaringTypeRef.Name match String.tryDropSuffix name "Attribute" with | Some shortName -> shortName | None -> name - let tref = ilMethRef.EnclosingTypeRef + let tref = ilMethRef.DeclaringTypeRef let tref = ILTypeRef.Create(scope= tref.Scope, enclosing=tref.Enclosing, name=trimmedName) PrintIL.layoutILTypeRef denv tref ++ argsL | FSAttrib vref -> @@ -1296,18 +1296,15 @@ module InfoMemberPrinting = // Container(argName1:argType1, ..., argNameN:argTypeN) : retType // Container.Method(argName1:argType1, ..., argNameN:argTypeN) : retType let private layoutMethInfoCSharpStyle amap m denv (minfo:MethInfo) minst = - let retTy = if minfo.IsConstructor then minfo.EnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) + let retTy = if minfo.IsConstructor then minfo.LogicalEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) let layout = if minfo.IsExtensionMember then LeftL.leftParen ^^ wordL (tagKeyword (FSComp.SR.typeInfoExtension())) ^^ RightL.rightParen else emptyL let layout = layout ^^ - match tryDestAppTy amap.g minfo.EnclosingType with - | Some tcref -> - PrintTypes.layoutTyconRef denv tcref - | None -> - PrintTypes.layoutType denv minfo.EnclosingType + let tcref = tcrefOfAppTy amap.g minfo.LogicalEnclosingAppType + PrintTypes.layoutTyconRef denv tcref let layout = layout ^^ if minfo.IsConstructor then @@ -1359,7 +1356,7 @@ module InfoMemberPrinting = match methInfo with | DefaultStructCtor(g,_typ) -> let prettyTyparInst, _ = PrettyTypes.PrettifyInst amap.g typarInst - prettyTyparInst, PrintTypes.layoutTyconRef denv (tcrefOfAppTy g methInfo.EnclosingType) ^^ wordL (tagPunctuation "()") + prettyTyparInst, PrintTypes.layoutTyconRef denv (tcrefOfAppTy g methInfo.LogicalEnclosingAppType) ^^ wordL (tagPunctuation "()") | FSMeth(_,_,vref,_) -> let prettyTyparInst, resL = PrintTastMemberOrVals.prettyLayoutOfValOrMember { denv with showMemberContainers=true } typarInst vref.Deref prettyTyparInst, resL @@ -1383,7 +1380,7 @@ module InfoMemberPrinting = | Some vref -> tagProperty >> mkNav vref.DefinitionRange let nameL = DemangleOperatorNameAsLayout tagProp pinfo.PropertyName wordL (tagText (FSComp.SR.typeInfoProperty())) ^^ - layoutTyconRef denv (tcrefOfAppTy g pinfo.EnclosingType) ^^ + layoutTyconRef denv (tcrefOfAppTy g pinfo.LogicalEnclosingAppType) ^^ SepL.dot ^^ nameL ^^ RightL.colon ^^ @@ -1557,8 +1554,8 @@ module private TastDefinitionPrinting = if p.HasGetter then yield p.GetterMethod.DisplayName if p.HasSetter then yield p.SetterMethod.DisplayName for e in events do - yield e.GetAddMethod().DisplayName - yield e.GetRemoveMethod().DisplayName ] + yield e.AddMethod.DisplayName + yield e.RemoveMethod.DisplayName ] with _ -> Set.empty let ctorLs = diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index b4ebba45671..77a1be55adf 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -1814,9 +1814,9 @@ and OptimizeExprOp cenv env (op, tyargs, args, m) = // guarantees to optimize. | TOp.ILCall (_, _, _, _, _, _, _, mref, _enclTypeArgs, _methTypeArgs, _tys), _, [arg] - when (mref.EnclosingTypeRef.Scope.IsAssemblyRef && - mref.EnclosingTypeRef.Scope.AssemblyRef.Name = cenv.g.ilg.typ_Array.TypeRef.Scope.AssemblyRef.Name && - mref.EnclosingTypeRef.Name = cenv.g.ilg.typ_Array.TypeRef.Name && + when (mref.DeclaringTypeRef.Scope.IsAssemblyRef && + mref.DeclaringTypeRef.Scope.AssemblyRef.Name = cenv.g.ilg.typ_Array.TypeRef.Scope.AssemblyRef.Name && + mref.DeclaringTypeRef.Name = cenv.g.ilg.typ_Array.TypeRef.Name && mref.Name = "get_Length" && isArray1DTy cenv.g (tyOfExpr cenv.g arg)) -> OptimizeExpr cenv env (Expr.Op(TOp.ILAsm(i_ldlen, [cenv.g.int_ty]), [], [arg], m)) diff --git a/src/fsharp/QuotationTranslator.fs b/src/fsharp/QuotationTranslator.fs index 177d50063d6..81f50d17de8 100644 --- a/src/fsharp/QuotationTranslator.fs +++ b/src/fsharp/QuotationTranslator.fs @@ -453,7 +453,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | TOp.ILAsm([ I_stfld(_,_,fspec) | I_stsfld (_,fspec) ],_),enclTypeArgs,args -> let tyargsR = ConvTypes cenv env m enclTypeArgs - let parentTyconR = ConvILTypeRefUnadjusted cenv m fspec.EnclosingTypeRef + let parentTyconR = ConvILTypeRefUnadjusted cenv m fspec.DeclaringTypeRef let argsR = ConvLValueArgs cenv env args QP.mkFieldSet( (parentTyconR, fspec.Name),tyargsR, argsR) @@ -558,7 +558,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | _ -> wfail(Error(FSComp.SR.crefQuotationsCantContainDescendingForLoops(), m)) | TOp.ILCall(_,_,_,isNewObj,valUseFlags,isProp,_,ilMethRef,enclTypeArgs,methTypeArgs,_tys),[],callArgs -> - let parentTyconR = ConvILTypeRefUnadjusted cenv m ilMethRef.EnclosingTypeRef + let parentTyconR = ConvILTypeRefUnadjusted cenv m ilMethRef.DeclaringTypeRef let isNewObj = isNewObj || (match valUseFlags with CtorValUsedAsSuperInit | CtorValUsedAsSelfInit -> true | _ -> false) let methArgTypesR = List.map (ConvILType cenv env m) ilMethRef.ArgTypes let methRetTypeR = ConvILType cenv env m ilMethRef.ReturnType @@ -598,7 +598,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. and ConvLdfld cenv env m (fspec: ILFieldSpec) enclTypeArgs args = let tyargsR = ConvTypes cenv env m enclTypeArgs - let parentTyconR = ConvILTypeRefUnadjusted cenv m fspec.EnclosingTypeRef + let parentTyconR = ConvILTypeRefUnadjusted cenv m fspec.DeclaringTypeRef let argsR = ConvLValueArgs cenv env args QP.mkFieldGet( (parentTyconR, fspec.Name),tyargsR, argsR) diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 39bae69e436..7ff96982e3e 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -2732,8 +2732,8 @@ let superOfTycon (g:TcGlobals) (tycon:Tycon) = // AbsIL view of attributes (we read these from .NET binaries) let isILAttribByName (tencl:string list, tname: string) (attr: ILAttribute) = - (attr.Method.EnclosingType.TypeSpec.Name = tname) && - (attr.Method.EnclosingType.TypeSpec.Enclosing = tencl) + (attr.Method.DeclaringType.TypeSpec.Name = tname) && + (attr.Method.DeclaringType.TypeSpec.Enclosing = tencl) // AbsIL view of attributes (we read these from .NET binaries) let isILAttrib (tref:ILTypeRef) (attr: ILAttribute) = @@ -2753,7 +2753,7 @@ let TryDecodeILAttribute (g:TcGlobals) tref (attrs: ILAttributes) = // This one is done by name to ensure the compiler doesn't take a dependency on dereferencing a type that only exists in .NET 3.5 let ILThingHasExtensionAttribute (attrs : ILAttributes) = attrs.AsArray - |> Array.exists (fun attr -> attr.Method.EnclosingType.TypeSpec.Name = "System.Runtime.CompilerServices.ExtensionAttribute") + |> Array.exists (fun attr -> attr.Method.DeclaringType.TypeSpec.Name = "System.Runtime.CompilerServices.ExtensionAttribute") // F# view of attributes (these get converted to AbsIL attributes in ilxgen) let IsMatchingFSharpAttribute g (AttribInfo(_, tcref)) (Attrib(tcref2, _, _, _, _, _, _)) = tyconRefEq g tcref tcref2 @@ -3547,7 +3547,7 @@ module DebugPrint = begin (lvalopL lvop ^^ valRefL vr --- bracketL (commaListL (List.map atomL args))) |> wrap | Expr.Op (TOp.ILCall (_isVirtCall, _isProtectedCall, _valu, _isNewObjCall, _valUseFlags, _isProperty, _noTailCall, ilMethRef, tinst, minst, _tys), tyargs, args, _) -> let meth = ilMethRef.Name - wordL(tagText "ILCall") ^^ aboveListL [wordL(tagText "meth ") --- wordL (tagText ilMethRef.EnclosingTypeRef.FullName) ^^ sepL(tagText ".") ^^ wordL (tagText meth); + wordL(tagText "ILCall") ^^ aboveListL [wordL(tagText "meth ") --- wordL (tagText ilMethRef.DeclaringTypeRef.FullName) ^^ sepL(tagText ".") ^^ wordL (tagText meth); wordL(tagText "tinst ") --- listL typeL tinst; wordL(tagText "minst ") --- listL typeL minst; wordL(tagText "tyargs") --- listL typeL tyargs; @@ -6356,7 +6356,7 @@ let mkCompilationMappingAttrForQuotationResource (g:TcGlobals) (nm, tys: ILTypeR //---------------------------------------------------------------------------- let isTypeProviderAssemblyAttr (cattr:ILAttribute) = - cattr.Method.EnclosingType.BasicQualifiedName = typeof.FullName + cattr.Method.DeclaringType.BasicQualifiedName = typeof.FullName let TryDecodeTypeProviderAssemblyAttr ilg (cattr:ILAttribute) = if isTypeProviderAssemblyAttr cattr then diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index 18307ce1559..3c7e70ca283 100755 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -948,13 +948,13 @@ and u_ILCallSig = u_wrap (fun (a,b,c) -> {CallingConv=a; ArgTypes=b; ReturnType= and u_ILTypeSpec st = let a,b = u_tup2 u_ILTypeRef u_ILTypes st in ILTypeSpec.Create(a,b) -let p_ILMethodRef (x: ILMethodRef) st = p_tup6 p_ILTypeRef p_ILCallConv p_int p_string p_ILTypes p_ILType (x.EnclosingTypeRef,x.CallingConv,x.GenericArity,x.Name,x.ArgTypes,x.ReturnType) st +let p_ILMethodRef (x: ILMethodRef) st = p_tup6 p_ILTypeRef p_ILCallConv p_int p_string p_ILTypes p_ILType (x.DeclaringTypeRef,x.CallingConv,x.GenericArity,x.Name,x.ArgTypes,x.ReturnType) st -let p_ILFieldRef (x: ILFieldRef) st = p_tup3 p_ILTypeRef p_string p_ILType (x.EnclosingTypeRef, x.Name, x.Type) st +let p_ILFieldRef (x: ILFieldRef) st = p_tup3 p_ILTypeRef p_string p_ILType (x.DeclaringTypeRef, x.Name, x.Type) st -let p_ILMethodSpec (x: ILMethodSpec) st = p_tup3 p_ILMethodRef p_ILType p_ILTypes (x.MethodRef, x.EnclosingType, x.GenericArgs) st +let p_ILMethodSpec (x: ILMethodSpec) st = p_tup3 p_ILMethodRef p_ILType p_ILTypes (x.MethodRef, x.DeclaringType, x.GenericArgs) st -let p_ILFieldSpec (x : ILFieldSpec) st = p_tup2 p_ILFieldRef p_ILType (x.FieldRef, x.EnclosingType) st +let p_ILFieldSpec (x : ILFieldSpec) st = p_tup2 p_ILFieldRef p_ILType (x.FieldRef, x.DeclaringType) st let p_ILBasicType x st = p_int (match x with @@ -982,7 +982,7 @@ let u_ILMethodRef st = let u_ILFieldRef st = let x1,x2,x3 = u_tup3 u_ILTypeRef u_string u_ILType st - {EnclosingTypeRef=x1;Name=x2;Type=x3} + {DeclaringTypeRef=x1;Name=x2;Type=x3} let u_ILMethodSpec st = let x1,x2,x3 = u_tup3 u_ILMethodRef u_ILType u_ILTypes st @@ -990,7 +990,7 @@ let u_ILMethodSpec st = let u_ILFieldSpec st = let x1,x2 = u_tup2 u_ILFieldRef u_ILType st - {FieldRef=x1;EnclosingType=x2} + {FieldRef=x1;DeclaringType=x2} let u_ILBasicType st = match u_int st with diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index f312308ff5f..6e259f8f705 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -174,7 +174,7 @@ let MethInfoChecks g amap isInstance tyargsOpt objArgs ad m (minfo:MethInfo) = if not (IsTypeAndMethInfoAccessible amap m adOriginal ad minfo) then error (Error (FSComp.SR.tcMethodNotAccessible(minfo.LogicalName), m)) - if isAnyTupleTy g minfo.EnclosingType then + if isAnyTupleTy g minfo.LogicalEnclosingType then warning (Error (FSComp.SR.tcTupleMemberNotNormallyUsed(), m)) CheckMethInfoAttributes g m tyargsOpt minfo |> CommitOperationResult @@ -1955,7 +1955,7 @@ let FreshenAbstractSlot g amap m synTyparDecls absMethInfo = // If the virtual method is a generic method then copy its type parameters let typarsFromAbsSlot, typarInstFromAbsSlot, _ = let ttps = absMethInfo.GetFormalTyparsOfDeclaringType m - let ttinst = argsOfAppTy g absMethInfo.EnclosingType + let ttinst = argsOfAppTy g absMethInfo.LogicalEnclosingType let rigid = if typarsFromAbsSlotAreRigid then TyparRigidity.Rigid else TyparRigidity.Flexible ConstraintSolver.FreshenAndFixupTypars m rigid ttps ttinst fmtps @@ -3094,7 +3094,7 @@ let BuildILFieldGet g amap m objExpr (finfo:ILFieldInfo) = // The empty instantiation on the AbstractIL fspec is OK, since we make the correct fspec in IlxGen.GenAsm // This ensures we always get the type instantiation right when doing this from // polymorphic code, after inlining etc. * - let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.EnclosingTypeRef []) + let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.DeclaringTypeRef []) // Add an I_nop if this is an initonly field to make sure we never recognize it as an lvalue. See mkExprAddrOfExpr. wrap (mkAsmExpr (([ mkNormalLdfld fspec ] @ (if finfo.IsInitOnly then [ AI_nop ] else [])), tinst, [objExpr], [fieldType], m)) @@ -3106,7 +3106,7 @@ let BuildILFieldSet g m objExpr (finfo:ILFieldInfo) argExpr = // The empty instantiation on the AbstractIL fspec is OK, since we make the correct fspec in IlxGen.GenAsm // This ensures we always get the type instantiation right when doing this from // polymorphic code, after inlining etc. * - let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.EnclosingTypeRef []) + let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.DeclaringTypeRef []) if finfo.IsInitOnly then error (Error (FSComp.SR.tcFieldIsReadonly(), m)) let wrap, objExpr = mkExprAddrOfExpr g isValueType false DefinitelyMutates objExpr None m wrap (mkAsmExpr ([ mkNormalStfld fspec ], tinst, [objExpr; argExpr], [], m)) @@ -3119,12 +3119,12 @@ let BuildILStaticFieldSet m (finfo:ILFieldInfo) argExpr = // The empty instantiation on the AbstractIL fspec is OK, since we make the correct fspec in IlxGen.GenAsm // This ensures we always get the type instantiation right when doing this from // polymorphic code, after inlining etc. - let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.EnclosingTypeRef []) + let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.DeclaringTypeRef []) if finfo.IsInitOnly then error (Error (FSComp.SR.tcFieldIsReadonly(), m)) mkAsmExpr ([ mkNormalStsfld fspec ], tinst, [argExpr], [], m) let BuildRecdFieldSet g m objExpr (rfinfo:RecdFieldInfo) argExpr = - let tgty = rfinfo.EnclosingType + let tgty = rfinfo.DeclaringType let valu = isStructTy g tgty let objExpr = if valu then objExpr else mkCoerceExpr(objExpr, tgty, m, tyOfExpr g objExpr) let wrap, objExpr = mkExprAddrOfExpr g valu false DefinitelyMutates objExpr None m @@ -8659,7 +8659,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del | Item.CtorGroup(nm, minfos) -> let objTy = match minfos with - | (minfo :: _) -> minfo.EnclosingType + | (minfo :: _) -> minfo.LogicalEnclosingType | [] -> error(Error(FSComp.SR.tcTypeHasNoAccessibleConstructor(), mItem)) match delayed with | ((DelayedApp (_, arg, mExprAndArg))::otherDelayed) -> @@ -8685,7 +8685,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del #endif item, minfos - minfosAfterTyArgs |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.EnclosingType objTyAfterTyArgs) + minfosAfterTyArgs |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.LogicalEnclosingType objTyAfterTyArgs) TcCtorCall true cenv env tpenv overallTy objTyAfterTyArgs (Some mExprAndTypeArgs) itemAfterTyArgs false [arg] mExprAndArg otherDelayed (Some afterResolution) | ((DelayedTypeApp(tyargs, _mTypeArgs, mExprAndTypeArgs))::otherDelayed) -> @@ -8696,7 +8696,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del let resolvedItem = Item.Types(nm, [objTy]) CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs, env.NameEnv, resolvedItem, resolvedItem, emptyTyparInst, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights) - minfos |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.EnclosingType objTy) + minfos |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.LogicalEnclosingType objTy) TcCtorCall true cenv env tpenv overallTy objTy (Some mExprAndTypeArgs) item false [] mExprAndTypeArgs otherDelayed (Some afterResolution) | _ -> @@ -8935,7 +8935,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del // The empty instantiation on the fspec is OK, since we make the correct fspec in IlxGen.GenAsm // This ensures we always get the type instantiation right when doing this from // polymorphic code, after inlining etc. - let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.EnclosingTypeRef []) + let fspec = mkILFieldSpec(fref, mkILNamedTy valu fref.DeclaringTypeRef []) // Add an I_nop if this is an initonly field to make sure we never recognize it as an lvalue. See mkExprAddrOfExpr. mkAsmExpr ([ mkNormalLdsfld fspec ] @ (if finfo.IsInitOnly then [ AI_nop ] else []), finfo.TypeInst, [], [exprty], mItem) @@ -9085,7 +9085,7 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela | Item.RecdField rfinfo -> // Get or set instance F# field or literal RecdFieldInstanceChecks cenv.g cenv.amap ad mItem rfinfo - let tgty = rfinfo.EnclosingType + let tgty = rfinfo.DeclaringType let valu = isStructTy cenv.g tgty AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css mItem NoTrace tgty objExprTy let objExpr = if valu then objExpr else mkCoerceExpr(objExpr, tgty, mExprAndItem, objExprTy) @@ -9161,10 +9161,10 @@ and TcEventValueThen cenv overallTy env tpenv mItem mExprAndItem objDetails (ein // EventHelper ((fun d -> e.add_X(d)), (fun d -> e.remove_X(d)), (fun f -> new 'Delegate(f))) mkCallCreateEvent cenv.g mItem delegateType argsTy (let dv, de = mkCompGenLocal mItem "eventDelegate" delegateType - let callExpr, _ = BuildPossiblyConditionalMethodCall cenv env PossiblyMutates mItem false (einfo.GetAddMethod()) NormalValUse [] objVars [de] + let callExpr, _ = BuildPossiblyConditionalMethodCall cenv env PossiblyMutates mItem false einfo.AddMethod NormalValUse [] objVars [de] mkLambda mItem dv (callExpr, cenv.g.unit_ty)) (let dv, de = mkCompGenLocal mItem "eventDelegate" delegateType - let callExpr, _ = BuildPossiblyConditionalMethodCall cenv env PossiblyMutates mItem false (einfo.GetRemoveMethod()) NormalValUse [] objVars [de] + let callExpr, _ = BuildPossiblyConditionalMethodCall cenv env PossiblyMutates mItem false einfo.RemoveMethod NormalValUse [] objVars [de] mkLambda mItem dv (callExpr, cenv.g.unit_ty)) (let fvty = (cenv.g.obj_ty --> (argsTy --> cenv.g.unit_ty)) let fv, fe = mkCompGenLocal mItem "callback" fvty @@ -9630,20 +9630,20 @@ and TcMethodApplication // if (isInstance && finalCalledMethInfo.IsInstance && - typeEquiv cenv.g finalCalledMethInfo.EnclosingType cenv.g.obj_ty && + typeEquiv cenv.g finalCalledMethInfo.LogicalEnclosingType cenv.g.obj_ty && (finalCalledMethInfo.LogicalName = "GetHashCode" || finalCalledMethInfo.LogicalName = "Equals")) then objArgs |> List.iter (fun expr -> ConstraintSolver.AddCxTypeMustSupportEquality env.DisplayEnv cenv.css mMethExpr NoTrace (tyOfExpr cenv.g expr)) // Uses of a Dictionary() constructor without an IEqualityComparer argument imply an equality constraint // on the first type argument. - if HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.EnclosingType && + if HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.LogicalEnclosingType && finalCalledMethInfo.IsConstructor && not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs) |> List.existsSquared (fun (ParamData(_, _, _, _, _, _, ty)) -> HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_IEqualityComparer ty)) then - match argsOfAppTy cenv.g finalCalledMethInfo.EnclosingType with + match argsOfAppTy cenv.g finalCalledMethInfo.LogicalEnclosingType with | [dty; _] -> ConstraintSolver.AddCxTypeMustSupportEquality env.DisplayEnv cenv.css mMethExpr NoTrace dty | _ -> () end @@ -10196,7 +10196,7 @@ and TcAndBuildFixedExpr cenv env (overallPatTy, fixedExpr, overallExprTy, mBindi | Expr.Op (op, tyargs, args, _) -> match op, tyargs, args with | TOp.ValFieldGetAddr rfref, _, [_] -> not rfref.Tycon.IsStructOrEnumTycon - | TOp.ILAsm ([ I_ldflda (fspec)], _), _, _ -> fspec.EnclosingType.Boxity = ILBoxity.AsObject + | TOp.ILAsm ([ I_ldflda (fspec)], _), _, _ -> fspec.DeclaringType.Boxity = ILBoxity.AsObject | TOp.ILAsm ([ I_ldelema _], _), _, _ -> true | TOp.RefAddrGet _, _, _ -> true | _ -> false @@ -10932,7 +10932,7 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy, m, synTy let optInferredImplSlotTys = match optIntfSlotTy with | Some (x, _) -> [x] - | None -> uniqueAbstractMethSigs |> List.map (fun x -> x.EnclosingType) + | None -> uniqueAbstractMethSigs |> List.map (fun x -> x.LogicalEnclosingType) optInferredImplSlotTys, declaredTypars @@ -10994,7 +10994,7 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy, m, synTy let optInferredImplSlotTys = match optIntfSlotTy with | Some (x, _) -> [ x ] - | None -> uniqueAbstractPropSigs |> List.map (fun pinfo -> pinfo.EnclosingType) + | None -> uniqueAbstractPropSigs |> List.map (fun pinfo -> pinfo.LogicalEnclosingType) optInferredImplSlotTys, declaredTypars @@ -14308,7 +14308,7 @@ module TcExceptionDeclarations = minfo.GenericArity = 0) match candidates with | [minfo] -> - match minfo.EnclosingType with + match minfo.LogicalEnclosingType with | AppTy cenv.g (tcref, _) as ety when (TypeDefinitelySubsumesTypeNoCoercion 0 cenv.g cenv.amap m cenv.g.exn_ty ety) -> let tref = tcref.CompiledRepresentationForNamedType TExnAsmRepr tref diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index b1ec3cfca0c..f6d7b4c6b8f 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -1091,7 +1091,7 @@ module StaticLinker = match depILModule.Manifest with | Some m -> for ca in m.CustomAttrs.AsList do - if ca.Method.MethodRef.EnclosingTypeRef.FullName = typeof.FullName then + if ca.Method.MethodRef.DeclaringTypeRef.FullName = typeof.FullName then yield ca | _ -> () ] @@ -1201,7 +1201,7 @@ module StaticLinker = |> List.map (fun md -> {md with CustomAttrs = mkILCustomAttrs (td.CustomAttrs.AsList |> List.filter (fun ilattr -> - ilattr.Method.EnclosingType.TypeRef.FullName <> "System.Runtime.TargetedPatchingOptOutAttribute") )}) + ilattr.Method.DeclaringType.TypeRef.FullName <> "System.Runtime.TargetedPatchingOptOutAttribute") )}) |> mkILMethods } ])} //ILAsciiWriter.output_module stdout fakeModule fakeModule.TypeDefs.AsList diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index a28af3005b4..145ae93e513 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -665,12 +665,12 @@ type ILTypeInfo = member x.ILTypeRef = let (ILTypeInfo(_,_,tref,_)) = x in tref /// Get the compiled nominal type. In the case of tuple types, this is a .NET tuple type - member x.RawType = + member x.ToAppType = let (ILTypeInfo(g, ty, _, _)) = x helpEnsureTypeHasMetadata g ty - member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.RawType - member x.TypeInstOfRawMetadata = argsOfAppTy x.TcGlobals x.RawType + member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.ToAppType + member x.TypeInstOfRawMetadata = argsOfAppTy x.TcGlobals x.ToAppType member x.RawMetadata = let (ILTypeInfo(_,_,_,tdef)) = x in tdef member x.ToType = let (ILTypeInfo(_,ty,_,_)) = x in ty @@ -719,15 +719,15 @@ type ILMethInfo = /// Get the apparent declaring type of the method as an F# type. /// If this is a C#-style extension method then this is the type which the method /// appears to extend. This may be a variable type. - member x.ApparentEnclosingType = match x with ILMethInfo(_,ty,_,_,_) -> ty + member x.LogicalEnclosingType = match x with ILMethInfo(_,ty,_,_,_) -> ty - /// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type - member x.ApparentEnclosingAppType = - let enclTy = x.ApparentEnclosingType + /// Like LogicalEnclosingType but use the compiled nominal type if this is a method on a tuple type + member x.LogicalEnclosingAppType = + let enclTy = x.LogicalEnclosingType helpEnsureTypeHasMetadata x.TcGlobals enclTy /// Get the declaring type associated with an extension member, if any. - member x.DeclaringTyconRefOption = match x with ILMethInfo(_,_,tcrefOpt,_,_) -> tcrefOpt + member x.ILExtensionMethodDeclaringTyconRef = match x with ILMethInfo(_,_,tcrefOpt,_,_) -> tcrefOpt /// Get the Abstract IL metadata associated with the method. member x.RawMetadata = match x with ILMethInfo(_,_,_,md,_) -> md @@ -739,21 +739,21 @@ type ILMethInfo = member x.ILName = x.RawMetadata.Name /// Indicates if the method is an extension method - member x.IsILExtensionMethod = x.DeclaringTyconRefOption.IsSome + member x.IsILExtensionMethod = x.ILExtensionMethodDeclaringTyconRef.IsSome /// Get the declaring type of the method. If this is an C#-style extension method then this is the IL type /// holding the static member that is the extension method. member x.DeclaringTyconRef = - match x.DeclaringTyconRefOption with + match x.ILExtensionMethodDeclaringTyconRef with | Some tcref -> tcref - | None -> tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType + | None -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType /// Get the instantiation of the declaring type of the method. /// If this is an C#-style extension method then this is empty because extension members /// are never in generic classes. member x.DeclaringTypeInst = if x.IsILExtensionMethod then [] - else argsOfAppTy x.TcGlobals x.ApparentEnclosingAppType + else argsOfAppTy x.TcGlobals x.LogicalEnclosingAppType /// Get the Abstract IL scope information associated with interpreting the Abstract IL metadata that backs this method. member x.MetadataScope = x.DeclaringTyconRef.CompiledRepresentationForNamedType.Scope @@ -843,7 +843,7 @@ type ILMethInfo = if x.IsILExtensionMethod then [ImportILTypeFromMetadata amap m x.MetadataScope x.DeclaringTypeInst minst x.RawMetadata.Parameters.Head.Type] else if x.IsInstance then - [ x.ApparentEnclosingType ] + [ x.LogicalEnclosingType ] else [] @@ -866,7 +866,7 @@ type ILMethInfo = /// Describes an F# use of a method [] type MethInfo = - /// FSMeth(tcGlobals, declaringType, valRef, extensionMethodPriority). + /// FSMeth(tcGlobals, enclosingType, valRef, extensionMethodPriority). /// /// Describes a use of a method declared in F# code and backed by F# metadata. | FSMeth of TcGlobals * TType * ValRef * ExtensionMethodPriority option @@ -888,9 +888,9 @@ type MethInfo = /// /// If this is an extension member, then this is the apparent parent, i.e. the type the method appears to extend. /// This may be a variable type. - member x.EnclosingType = + member x.LogicalEnclosingType = match x with - | ILMeth(_,ilminfo,_) -> ilminfo.ApparentEnclosingType + | ILMeth(_,ilminfo,_) -> ilminfo.LogicalEnclosingType | FSMeth(_,typ,_,_) -> typ | DefaultStructCtor(_,typ) -> typ #if !NO_EXTENSIONTYPING @@ -899,19 +899,19 @@ type MethInfo = #endif /// Get the enclosing type of the method info, using a nominal type for tuple types - member x.EnclosingAppType = + member x.LogicalEnclosingAppType = match x with - | ILMeth(_,ilminfo,_) -> ilminfo.ApparentEnclosingAppType - | _ -> x.EnclosingType + | ILMeth(_,ilminfo,_) -> ilminfo.LogicalEnclosingAppType + | _ -> x.LogicalEnclosingType /// Get the declaring type or module holding the method. If this is an C#-style extension method then this is the type /// holding the static member that is the extension method. If this is an F#-style extension method it is the logical module /// holding the value for the extension method. - member x.DeclaringEntityRef = + member x.DeclaringTyconRef = match x with | ILMeth(_,ilminfo,_) when x.IsExtensionMember -> ilminfo.DeclaringTyconRef | FSMeth(_,_,vref,_) when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent - | _ -> tcrefOfAppTy x.TcGlobals x.EnclosingAppType + | _ -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType /// Get the information about provided static parameters, if any member x.ProvidedStaticParameterInfo = @@ -981,13 +981,13 @@ type MethInfo = #endif | _ -> false - override x.ToString() = x.EnclosingType.ToString() + x.LogicalName + override x.ToString() = x.LogicalEnclosingType.ToString() + x.LogicalName /// Get the actual type instantiation of the declaring type associated with this use of the method. /// /// For extension members this is empty (the instantiation of the declaring type). member x.DeclaringTypeInst = - if x.IsExtensionMember then [] else argsOfAppTy x.TcGlobals x.EnclosingAppType + if x.IsExtensionMember then [] else argsOfAppTy x.TcGlobals x.LogicalEnclosingAppType /// Get the TcGlobals value that governs the method declaration member x.TcGlobals = @@ -1107,7 +1107,7 @@ type MethInfo = match x with | ILMeth(_g,ilmeth,_) -> ilmeth.IsVirtual | FSMeth(g,_,vref,_) as x -> - isInterfaceTy g x.EnclosingType || + isInterfaceTy g x.LogicalEnclosingType || vref.MemberInfo.Value.MemberFlags.IsDispatchSlot | DefaultStructCtor _ -> false #if !NO_EXTENSIONTYPING @@ -1134,14 +1134,14 @@ type MethInfo = member minfo.IsAbstract = match minfo with | ILMeth(_,ilmeth,_) -> ilmeth.IsAbstract - | FSMeth(g,_,vref,_) -> isInterfaceTy g minfo.EnclosingType || vref.IsDispatchSlotMember + | FSMeth(g,_,vref,_) -> isInterfaceTy g minfo.LogicalEnclosingType || vref.IsDispatchSlotMember | DefaultStructCtor _ -> false #if !NO_EXTENSIONTYPING | ProvidedMeth(_,mi,_,m) -> mi.PUntaint((fun mi -> mi.IsAbstract), m) #endif member x.IsNewSlot = - isInterfaceTy x.TcGlobals x.EnclosingType || + isInterfaceTy x.TcGlobals x.LogicalEnclosingType || (x.IsVirtual && (match x with | ILMeth(_,x,_) -> x.IsNewSlot @@ -1200,7 +1200,7 @@ type MethInfo = // but is compiled as a generic methods with two type arguments // Map<'T,'U>(this: List<'T>, f : 'T -> 'U) member x.AdjustUserTypeInstForFSharpStyleIndexedExtensionMembers(tyargs) = - (if x.IsFSharpStyleExtensionMember then argsOfAppTy x.TcGlobals x.EnclosingAppType else []) @ tyargs + (if x.IsFSharpStyleExtensionMember then argsOfAppTy x.TcGlobals x.LogicalEnclosingAppType else []) @ tyargs /// Indicates if this method is a generated method associated with an F# CLIEvent property compiled as a .NET event member x.IsFSharpEventPropertyMethod = @@ -1218,7 +1218,7 @@ type MethInfo = /// /// For an extension method, this indicates if the method extends a struct type. member x.IsStruct = - isStructTy x.TcGlobals x.EnclosingType + isStructTy x.TcGlobals x.LogicalEnclosingType /// Build IL method infos. static member CreateILMeth (amap:Import.ImportMap, m, typ:TType, md: ILMethodDef) = @@ -1238,7 +1238,7 @@ type MethInfo = match x1,x2 with | ILMeth(_,x1,_), ILMeth(_,x2,_) -> (x1.RawMetadata === x2.RawMetadata) | FSMeth(g,_,vref1,_), FSMeth(_,_,vref2,_) -> valRefEq g vref1 vref2 - | DefaultStructCtor(g,ty1), DefaultStructCtor(_,ty2) -> tyconRefEq g (tcrefOfAppTy g ty1) (tcrefOfAppTy g ty2) + | DefaultStructCtor _, DefaultStructCtor _ -> tyconRefEq x1.TcGlobals x1.DeclaringTyconRef x2.DeclaringTyconRef #if !NO_EXTENSIONTYPING | ProvidedMeth(_,mi1,_,_),ProvidedMeth(_,mi2,_,_) -> ProvidedMethodBase.TaintedEquals (mi1, mi2) #endif @@ -1450,7 +1450,7 @@ type MethInfo = // The FSMeth, ILMeth+ProvidedMeth paths can probably be unified too. member x.GetSlotSig(amap, m) = match x with - | FSMeth(g,typ,vref,_) -> + | FSMeth(g,_,vref,_) -> match vref.RecursiveValInfo with | ValInRecScope(false) -> error(Error((FSComp.SR.InvalidRecursiveReferenceToAbstractSlot()),m)) | _ -> () @@ -1458,14 +1458,15 @@ type MethInfo = let allTyparsFromMethod,_,retTy,_ = GetTypeOfMemberInMemberForm g vref // A slot signature is w.r.t. the type variables of the type it is associated with. // So we have to rename from the member type variables to the type variables of the type. - let formalEnclosingTypars = (tcrefOfAppTy g typ).Typars(m) + let tcref = tcrefOfAppTy g x.LogicalEnclosingAppType + let formalEnclosingTypars = tcref.Typars(m) let formalEnclosingTyparsFromMethod,formalMethTypars = List.chop formalEnclosingTypars.Length allTyparsFromMethod let methodToParentRenaming,_ = mkTyparToTyparRenaming formalEnclosingTyparsFromMethod formalEnclosingTypars let formalParams = GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref |> List.mapSquared (map1Of2 (instType methodToParentRenaming) >> MakeSlotParam ) let formalRetTy = Option.map (instType methodToParentRenaming) retTy - MakeSlotSig(x.LogicalName, x.EnclosingType, formalEnclosingTypars, formalMethTypars, formalParams, formalRetTy) + MakeSlotSig(x.LogicalName, x.LogicalEnclosingType, formalEnclosingTypars, formalMethTypars, formalParams, formalRetTy) | DefaultStructCtor _ -> error(InternalError("no slotsig for DefaultStructCtor",m)) | _ -> let g = x.TcGlobals @@ -1475,7 +1476,7 @@ type MethInfo = // happens to make the return type 'unit' (i.e. it was originally a variable type // then that does not correspond to a slotsig compiled as a 'void' return type. // REVIEW: should we copy down attributes to slot params? - let tcref = tcrefOfAppTy g x.EnclosingAppType + let tcref = tcrefOfAppTy g x.LogicalEnclosingAppType let formalEnclosingTyparsOrig = tcref.Typars(m) let formalEnclosingTypars = copyTypars formalEnclosingTyparsOrig let _,formalEnclosingTyparTys = FixupNewTypars m [] [] formalEnclosingTyparsOrig formalEnclosingTypars @@ -1507,7 +1508,7 @@ type MethInfo = formalRetTy, formalParams #endif | _ -> failwith "unreachable" - MakeSlotSig(x.LogicalName, x.EnclosingType, formalEnclosingTypars, formalMethTypars,formalParams, formalRetTy) + MakeSlotSig(x.LogicalName, x.LogicalEnclosingType, formalEnclosingTypars, formalMethTypars,formalParams, formalRetTy) /// Get the ParamData objects for the parameters of a MethInfo member x.GetParamDatas(amap, m, minst) = @@ -1555,16 +1556,11 @@ type MethInfo = if x.IsExtensionMember then [] else match x with - | ILMeth(_,ilminfo,_) -> ilminfo.DeclaringTyconRef.Typars m | FSMeth(g,typ,vref,_) -> let memberParentTypars,_,_,_ = AnalyzeTypeOfMemberVal false g (typ,vref) memberParentTypars - | DefaultStructCtor(g,typ) -> - (tcrefOfAppTy g typ).Typars(m) -#if !NO_EXTENSIONTYPING - | ProvidedMeth (amap,_,_,_) -> - (tcrefOfAppTy amap.g x.EnclosingAppType).Typars(m) -#endif + | _ -> + x.DeclaringTyconRef.Typars(m) //------------------------------------------------------------------------- // ILFieldInfo @@ -1581,13 +1577,24 @@ type ILFieldInfo = #endif /// Get the enclosing ("parent"/"declaring") type of the field. - member x.EnclosingType = + member x.LogicalEnclosingType = match x with | ILFieldInfo(tinfo,_) -> tinfo.ToType #if !NO_EXTENSIONTYPING | ProvidedField(amap,fi,m) -> (Import.ImportProvidedType amap m (fi.PApply((fun fi -> fi.DeclaringType),m))) #endif + member x.LogicalEnclosingAppType = x.LogicalEnclosingType + + member x.DeclaringTyconRef = tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + + member x.TcGlobals = + match x with + | ILFieldInfo(tinfo,_) -> tinfo.TcGlobals +#if !NO_EXTENSIONTYPING + | ProvidedField(amap,_,_) -> amap.g +#endif + /// Get a reference to the declaring type of the field as an ILTypeRef member x.ILTypeRef = match x with @@ -1628,7 +1635,7 @@ type ILFieldInfo = match x with | ILFieldInfo(tinfo,_) -> tinfo.IsValueType #if !NO_EXTENSIONTYPING - | ProvidedField(amap,_,_) -> isStructTy amap.g x.EnclosingType + | ProvidedField(amap,_,_) -> isStructTy amap.g x.LogicalEnclosingType #endif /// Indicates if the field is static @@ -1720,7 +1727,7 @@ type RecdFieldInfo = member x.FieldType = actualTyOfRecdFieldRef x.RecdFieldRef x.TypeInst /// Get the enclosing (declaring) type of the field in an F#-declared record, class or struct type - member x.EnclosingType = TType_app (x.RecdFieldRef.TyconRef,x.TypeInst) + member x.DeclaringType = TType_app (x.RecdFieldRef.TyconRef,x.TypeInst) override x.ToString() = x.TyconRef.ToString() + "::" + x.Name @@ -1758,26 +1765,39 @@ type UnionCaseInfo = type ILPropInfo = | ILPropInfo of ILTypeInfo * ILPropertyDef + /// Get the TcGlobals governing this value + member x.TcGlobals = match x with ILPropInfo(tinfo,_) -> tinfo.TcGlobals + /// Get the declaring IL type of the IL property, including any generic instantiation - member x.ILTypeInfo = match x with (ILPropInfo(tinfo,_)) -> tinfo + member x.ILTypeInfo = match x with ILPropInfo(tinfo,_) -> tinfo + + /// Get the apparent declaring type of the method as an F# type. + /// If this is a C#-style extension method then this is the type which the method + /// appears to extend. This may be a variable type. + member x.LogicalEnclosingType = match x with ILPropInfo(tinfo,_) -> tinfo.ToType + + /// Like LogicalEnclosingType but use the compiled nominal type if this is a method on a tuple type + member x.LogicalEnclosingAppType = + let enclTy = x.LogicalEnclosingType + helpEnsureTypeHasMetadata x.TcGlobals enclTy /// Get the raw Abstract IL metadata for the IL property - member x.RawMetadata = match x with (ILPropInfo(_,pd)) -> pd + member x.RawMetadata = match x with ILPropInfo(_,pd) -> pd /// Get the name of the IL property member x.PropertyName = x.RawMetadata.Name /// Gets the ILMethInfo of the 'get' method for the IL property - member x.GetterMethod(g) = + member x.GetterMethod = assert x.HasGetter let mdef = resolveILMethodRef x.ILTypeInfo.RawMetadata x.RawMetadata.GetMethod.Value - ILMethInfo(g,x.ILTypeInfo.ToType,None,mdef,[]) + ILMethInfo(x.TcGlobals,x.ILTypeInfo.ToType,None,mdef,[]) /// Gets the ILMethInfo of the 'set' method for the IL property - member x.SetterMethod(g) = + member x.SetterMethod = assert x.HasSetter let mdef = resolveILMethodRef x.ILTypeInfo.RawMetadata x.RawMetadata.SetMethod.Value - ILMethInfo(g,x.ILTypeInfo.ToType,None,mdef,[]) + ILMethInfo(x.TcGlobals,x.ILTypeInfo.ToType,None,mdef,[]) /// Indicates if the IL property has a 'get' method member x.HasGetter = Option.isSome x.RawMetadata.GetMethod @@ -1789,14 +1809,14 @@ type ILPropInfo = member x.IsStatic = (x.RawMetadata.CallingConv = ILThisConvention.Static) /// Indicates if the IL property is virtual - member x.IsVirtual(g) = - (x.HasGetter && x.GetterMethod(g).IsVirtual) || - (x.HasSetter && x.SetterMethod(g).IsVirtual) + member x.IsVirtual = + (x.HasGetter && x.GetterMethod.IsVirtual) || + (x.HasSetter && x.SetterMethod.IsVirtual) /// Indicates if the IL property is logically a 'newslot', i.e. hides any previous slots of the same name. - member x.IsNewSlot(g) = - (x.HasGetter && x.GetterMethod(g).IsNewSlot) || - (x.HasSetter && x.SetterMethod(g).IsNewSlot) + member x.IsNewSlot = + (x.HasGetter && x.GetterMethod.IsNewSlot) || + (x.HasSetter && x.SetterMethod.IsNewSlot) /// Get the names and types of the indexer arguments associated with the IL property. /// @@ -1829,14 +1849,42 @@ type PropInfo = /// An F# use of a property backed by F#-declared metadata | FSProp of TcGlobals * TType * ValRef option * ValRef option /// An F# use of a property backed by Abstract IL metadata - | ILProp of TcGlobals * ILPropInfo + | ILProp of ILPropInfo #if !NO_EXTENSIONTYPING /// An F# use of a property backed by provided metadata | ProvidedProp of Import.ImportMap * Tainted * range #endif + /// Get the enclosing type of the property. + /// + /// If this is an extension member, then this is the apparent parent, i.e. the type the property appears to extend. + member x.LogicalEnclosingType = + match x with + | ILProp ilpinfo -> ilpinfo.ILTypeInfo.ToType + | FSProp(_,typ,_,_) -> typ +#if !NO_EXTENSIONTYPING + | ProvidedProp(amap,pi,m) -> + Import.ImportProvidedType amap m (pi.PApply((fun pi -> pi.DeclaringType),m)) +#endif + + /// Get the enclosing type of the method info, using a nominal type for tuple types + member x.LogicalEnclosingAppType = + match x with + | ILProp ilpinfo -> ilpinfo.LogicalEnclosingAppType + | _ -> x.LogicalEnclosingType + + /// Get the declaring type or module holding the method. + /// Note that C#-style extension properties don't exist in the C# design as yet. + /// If this is an F#-style extension method it is the logical module + /// holding the value for the extension method. + member x.DeclaringTyconRef = + match x.ArbitraryValRef with + | Some vref when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent + | _ -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + + /// Try to get an arbitrary F# ValRef associated with the member. This is to determine if the member is virtual, amongst other things. - member x.ArbitraryValRef = + member x.ArbitraryValRef : ValRef option = match x with | FSProp(_,_,Some vref,_) | FSProp(_,_,_, Some vref) -> Some vref @@ -1856,7 +1904,7 @@ type PropInfo = /// Get the logical name of the property. member x.PropertyName = match x with - | ILProp(_,x) -> x.PropertyName + | ILProp ilpinfo -> ilpinfo.PropertyName | FSProp(_,_,Some vref,_) | FSProp(_,_,_, Some vref) -> vref.PropertyName #if !NO_EXTENSIONTYPING @@ -1867,7 +1915,7 @@ type PropInfo = /// Indicates if this property has an associated getter method. member x.HasGetter = match x with - | ILProp(_,x) -> x.HasGetter + | ILProp ilpinfo-> ilpinfo.HasGetter | FSProp(_,_,x,_) -> Option.isSome x #if !NO_EXTENSIONTYPING | ProvidedProp(_,pi,m) -> pi.PUntaint((fun pi -> pi.CanRead),m) @@ -1876,33 +1924,24 @@ type PropInfo = /// Indicates if this property has an associated setter method. member x.HasSetter = match x with - | ILProp(_,x) -> x.HasSetter + | ILProp ilpinfo -> ilpinfo.HasSetter | FSProp(_,_,_,x) -> Option.isSome x #if !NO_EXTENSIONTYPING | ProvidedProp(_,pi,m) -> pi.PUntaint((fun pi -> pi.CanWrite),m) #endif - /// Get the enclosing type of the property. - /// - /// If this is an extension member, then this is the apparent parent, i.e. the type the property appears to extend. - member x.EnclosingType = - match x with - | ILProp(_,x) -> x.ILTypeInfo.ToType - | FSProp(_,typ,_,_) -> typ -#if !NO_EXTENSIONTYPING - | ProvidedProp(amap,pi,m) -> - Import.ImportProvidedType amap m (pi.PApply((fun pi -> pi.DeclaringType),m)) -#endif /// Indicates if this is an extension member member x.IsExtensionMember = - match x.ArbitraryValRef with Some vref -> vref.IsExtensionMember | _ -> false + match x.ArbitraryValRef with + | Some vref -> vref.IsExtensionMember + | _ -> false /// True if the getter (or, if absent, the setter) is a virtual method // REVIEW: for IL properties this is getter OR setter. For F# properties it is getter ELSE setter member x.IsVirtualProperty = match x with - | ILProp(g,x) -> x.IsVirtual(g) + | ILProp ilpinfo -> ilpinfo.IsVirtual | FSProp(_,_,Some vref,_) | FSProp(_,_,_, Some vref) -> vref.IsVirtualMember | FSProp _-> failwith "unreachable" @@ -1915,7 +1954,7 @@ type PropInfo = /// Indicates if the property is logically a 'newslot', i.e. hides any previous slots of the same name. member x.IsNewSlot = match x with - | ILProp(g,x) -> x.IsNewSlot(g) + | ILProp ilpinfo -> ilpinfo.IsNewSlot | FSProp(_,_,Some vref,_) | FSProp(_,_,_, Some vref) -> vref.IsDispatchSlotMember | FSProp(_,_,None,None) -> failwith "unreachable" @@ -1930,7 +1969,7 @@ type PropInfo = // REVIEW: for IL properties this is getter OR setter. For F# properties it is getter ELSE setter member x.IsDispatchSlot = match x with - | ILProp(g,x) -> x.IsVirtual(g) + | ILProp ilpinfo -> ilpinfo.IsVirtual | FSProp(g,typ,Some vref,_) | FSProp(g,typ,_, Some vref) -> isInterfaceTy g typ || (vref.MemberInfo.Value.MemberFlags.IsDispatchSlot) @@ -1944,7 +1983,7 @@ type PropInfo = /// Indicates if this property is static. member x.IsStatic = match x with - | ILProp(_,x) -> x.IsStatic + | ILProp ilpinfo -> ilpinfo.IsStatic | FSProp(_,_,Some vref,_) | FSProp(_,_,_, Some vref) -> not vref.IsInstanceMember | FSProp(_,_,None,None) -> failwith "unreachable" @@ -1971,7 +2010,7 @@ type PropInfo = /// Indicates if this property is an indexer property, i.e. a property with arguments. member x.IsIndexer = match x with - | ILProp(_,ILPropInfo(_,pdef)) -> pdef.Args.Length <> 0 + | ILProp(ILPropInfo(_,pdef)) -> pdef.Args.Length <> 0 | FSProp(g,_,Some vref,_) -> // A getter has signature { OptionalObjectType } -> Unit -> PropertyType // A getter indexer has signature { OptionalObjectType } -> TupledIndexerArguments -> PropertyType @@ -2029,7 +2068,7 @@ type PropInfo = /// Get the TcGlobals associated with the object member x.TcGlobals = match x with - | ILProp(g,_) -> g + | ILProp ilpinfo -> ilpinfo.TcGlobals | FSProp(g,_,_,_) -> g #if !NO_EXTENSIONTYPING | ProvidedProp(amap,_,_) -> amap.g @@ -2038,13 +2077,13 @@ type PropInfo = /// Indicates if the enclosing type for the property is a value type. /// /// For an extension property, this indicates if the property extends a struct type. - member x.IsValueType = isStructTy x.TcGlobals x.EnclosingType + member x.IsValueType = isStructTy x.TcGlobals x.LogicalEnclosingType /// Get the result type of the property member x.GetPropertyType (amap,m) = match x with - | ILProp (_,ilpinfo) -> ilpinfo.GetPropertyType (amap,m) + | ILProp ilpinfo -> ilpinfo.GetPropertyType (amap,m) | FSProp (g,typ,Some vref,_) | FSProp (g,typ,_,Some vref) -> let inst = GetInstantiationForPropertyVal g (typ,vref) @@ -2062,7 +2101,7 @@ type PropInfo = /// If the property is in a generic type, then the type parameters are instantiated in the types returned. member x.GetParamNamesAndTypes(amap,m) = match x with - | ILProp (_,ilpinfo) -> ilpinfo.GetParamNamesAndTypes(amap,m) + | ILProp ilpinfo -> ilpinfo.GetParamNamesAndTypes(amap,m) | FSProp (g,typ,Some vref,_) | FSProp (g,typ,_,Some vref) -> let inst = GetInstantiationForPropertyVal g (typ,vref) @@ -2088,7 +2127,7 @@ type PropInfo = /// Get a MethInfo for the 'getter' method associated with the property member x.GetterMethod = match x with - | ILProp(g,x) -> ILMeth(g,x.GetterMethod(g),None) + | ILProp ilpinfo -> ILMeth(x.TcGlobals, ilpinfo.GetterMethod, None) | FSProp(g,typ,Some vref,_) -> FSMeth(g,typ,vref,None) #if !NO_EXTENSIONTYPING | ProvidedProp(amap,pi,m) -> @@ -2101,7 +2140,7 @@ type PropInfo = /// Get a MethInfo for the 'setter' method associated with the property member x.SetterMethod = match x with - | ILProp(g,x) -> ILMeth(g,x.SetterMethod(g),None) + | ILProp ilpinfo -> ILMeth(x.TcGlobals, ilpinfo.SetterMethod, None) | FSProp(g,typ,_,Some vref) -> FSMeth(g,typ,vref,None) #if !NO_EXTENSIONTYPING | ProvidedProp(amap,pi,m) -> @@ -2119,7 +2158,7 @@ type PropInfo = | None, None -> true | _ -> false match x1,x2 with - | ILProp(_, x1), ILProp(_, x2) -> (x1.RawMetadata === x2.RawMetadata) + | ILProp ilpinfo1, ILProp ilpinfo2 -> (ilpinfo1.RawMetadata === ilpinfo2.RawMetadata) | FSProp(g, _, vrefa1, vrefb1), FSProp(_, _, vrefa2, vrefb2) -> (optVrefEq g (vrefa1, vrefa2)) && (optVrefEq g (vrefb1, vrefb2)) #if !NO_EXTENSIONTYPING @@ -2130,7 +2169,7 @@ type PropInfo = /// Calculates a hash code of property info (similar as previous) member pi.ComputeHashCode() = match pi with - | ILProp(_, x1) -> hash x1.RawMetadata.Name + | ILProp ilpinfo -> hash ilpinfo.RawMetadata.Name | FSProp(_,_,vrefOpt1, vrefOpt2) -> // Hash on option*option let vth = (vrefOpt1 |> Option.map (fun vr -> vr.LogicalName), (vrefOpt2 |> Option.map (fun vr -> vr.LogicalName))) @@ -2148,21 +2187,32 @@ type PropInfo = type ILEventInfo = | ILEventInfo of ILTypeInfo * ILEventDef + /// Get the enclosing ("parent"/"declaring") type of the field. + member x.LogicalEnclosingType = match x with ILEventInfo(tinfo,_) -> tinfo.ToType + + // Note: events are always assocaited with nominal types + member x.LogicalEnclosingAppType = x.LogicalEnclosingType + + // Note: IL Events are never extension members as C# has no notion of extension events as yet + member x.DeclaringTyconRef = tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + + member x.TcGlobals = match x with ILEventInfo(tinfo,_) -> tinfo.TcGlobals + /// Get the raw Abstract IL metadata for the event - member x.RawMetadata = match x with (ILEventInfo(_,ed)) -> ed + member x.RawMetadata = match x with ILEventInfo(_,ed) -> ed /// Get the declaring IL type of the event as an ILTypeInfo - member x.ILTypeInfo = match x with (ILEventInfo(tinfo,_)) -> tinfo + member x.ILTypeInfo = match x with ILEventInfo(tinfo,_) -> tinfo /// Get the ILMethInfo describing the 'add' method associated with the event - member x.AddMethod(g) = + member x.AddMethod = let mdef = resolveILMethodRef x.ILTypeInfo.RawMetadata x.RawMetadata.AddMethod - ILMethInfo(g,x.ILTypeInfo.ToType,None,mdef,[]) + ILMethInfo(x.TcGlobals,x.ILTypeInfo.ToType,None,mdef,[]) /// Get the ILMethInfo describing the 'remove' method associated with the event - member x.RemoveMethod(g) = + member x.RemoveMethod = let mdef = resolveILMethodRef x.ILTypeInfo.RawMetadata x.RawMetadata.RemoveMethod - ILMethInfo(g,x.ILTypeInfo.ToType,None,mdef,[]) + ILMethInfo(x.TcGlobals,x.ILTypeInfo.ToType,None,mdef,[]) /// Get the declaring type of the event as an ILTypeRef member x.TypeRef = x.ILTypeInfo.ILTypeRef @@ -2171,7 +2221,7 @@ type ILEventInfo = member x.Name = x.RawMetadata.Name /// Indicates if the property is static - member x.IsStatic(g) = x.AddMethod(g).IsStatic + member x.IsStatic = x.AddMethod.IsStatic override x.ToString() = x.ILTypeInfo.ToString() + "::" + x.Name //------------------------------------------------------------------------- @@ -2213,7 +2263,7 @@ type EventInfo = /// An F# use of an event backed by F#-declared metadata | FSEvent of TcGlobals * PropInfo * ValRef * ValRef /// An F# use of an event backed by .NET metadata - | ILEvent of TcGlobals * ILEventInfo + | ILEvent of ILEventInfo #if !NO_EXTENSIONTYPING /// An F# use of an event backed by provided metadata | ProvidedEvent of Import.ImportMap * Tainted * range @@ -2222,13 +2272,28 @@ type EventInfo = /// Get the enclosing type of the event. /// /// If this is an extension member, then this is the apparent parent, i.e. the type the event appears to extend. - member x.EnclosingType = + member x.LogicalEnclosingType = match x with - | ILEvent(_,e) -> e.ILTypeInfo.ToType - | FSEvent (_,p,_,_) -> p.EnclosingType + | ILEvent ileinfo -> ileinfo.LogicalEnclosingType + | FSEvent (_,p,_,_) -> p.LogicalEnclosingType #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,ei,m) -> Import.ImportProvidedType amap m (ei.PApply((fun ei -> ei.DeclaringType),m)) #endif + /// Get the enclosing type of the method info, using a nominal type for tuple types + member x.LogicalEnclosingAppType = + match x with + | ILEvent ileinfo -> ileinfo.LogicalEnclosingAppType + | _ -> x.LogicalEnclosingType + + /// Get the declaring type or module holding the method. + /// Note that C#-style extension properties don't exist in the C# design as yet. + /// If this is an F#-style extension method it is the logical module + /// holding the value for the extension method. + member x.DeclaringTyconRef = + match x.ArbitraryValRef with + | Some vref when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent + | _ -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + /// Indicates if this event has an associated XML comment authored in this assembly. member x.HasDirectXmlComment = @@ -2252,7 +2317,7 @@ type EventInfo = /// Get the logical name of the event. member x.EventName = match x with - | ILEvent(_,e) -> e.Name + | ILEvent ileinfo -> ileinfo.Name | FSEvent (_,p,_,_) -> p.PropertyName #if !NO_EXTENSIONTYPING | ProvidedEvent (_,ei,m) -> ei.PUntaint((fun ei -> ei.Name), m) @@ -2261,7 +2326,7 @@ type EventInfo = /// Indicates if this property is static. member x.IsStatic = match x with - | ILEvent(g,e) -> e.IsStatic(g) + | ILEvent ileinfo -> ileinfo.IsStatic | FSEvent (_,p,_,_) -> p.IsStatic #if !NO_EXTENSIONTYPING | ProvidedEvent (_,ei,m) -> @@ -2269,10 +2334,19 @@ type EventInfo = meth.PUntaint((fun mi -> mi.IsStatic), m) #endif + /// Indicates if this is an extension member + member x.IsExtensionMember = + match x with + | ILEvent _ -> false + | FSEvent (_,p,_,_) -> p.IsExtensionMember +#if !NO_EXTENSIONTYPING + | ProvidedEvent _ -> false +#endif + /// Get the TcGlobals associated with the object member x.TcGlobals = match x with - | ILEvent(g,_) -> g + | ILEvent ileinfo -> ileinfo.TcGlobals | FSEvent(g,_,_,_) -> g #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,_,_) -> amap.g @@ -2281,13 +2355,13 @@ type EventInfo = /// Indicates if the enclosing type for the event is a value type. /// /// For an extension event, this indicates if the event extends a struct type. - member x.IsValueType = isStructTy x.TcGlobals x.EnclosingType + member x.IsValueType = isStructTy x.TcGlobals x.LogicalEnclosingType /// Get the 'add' method associated with an event - member x.GetAddMethod() = + member x.AddMethod = match x with - | ILEvent(g,e) -> ILMeth(g,e.AddMethod(g),None) - | FSEvent(g,p,addValRef,_) -> FSMeth(g,p.EnclosingType,addValRef,None) + | ILEvent ileinfo -> ILMeth(ileinfo.TcGlobals, ileinfo.AddMethod, None) + | FSEvent(g,p,addValRef,_) -> FSMeth(g,p.LogicalEnclosingType,addValRef,None) #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,ei,m) -> let meth = GetAndSanityCheckProviderMethod m ei (fun ei -> ei.GetAddMethod()) FSComp.SR.etEventNoAdd @@ -2295,10 +2369,10 @@ type EventInfo = #endif /// Get the 'remove' method associated with an event - member x.GetRemoveMethod() = + member x.RemoveMethod = match x with - | ILEvent(g,e) -> ILMeth(g,e.RemoveMethod(g),None) - | FSEvent(g,p,_,removeValRef) -> FSMeth(g,p.EnclosingType,removeValRef,None) + | ILEvent ileinfo -> ILMeth(x.TcGlobals, ileinfo.RemoveMethod, None) + | FSEvent(g,p,_,removeValRef) -> FSMeth(g,p.LogicalEnclosingType,removeValRef,None) #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,ei,m) -> let meth = GetAndSanityCheckProviderMethod m ei (fun ei -> ei.GetRemoveMethod()) FSComp.SR.etEventNoRemove @@ -2306,7 +2380,7 @@ type EventInfo = #endif /// Try to get an arbitrary F# ValRef associated with the member. This is to determine if the member is virtual, amongst other things. - member x.ArbitraryValRef = + member x.ArbitraryValRef: ValRef option = match x with | FSEvent(_,_,addValRef,_) -> Some addValRef | _ -> None @@ -2314,7 +2388,7 @@ type EventInfo = /// Get the delegate type associated with the event. member x.GetDelegateType(amap,m) = match x with - | ILEvent(_,ILEventInfo(tinfo,edef)) -> + | ILEvent(ILEventInfo(tinfo,edef)) -> // Get the delegate type associated with an IL event, taking into account the instantiation of the // declaring type. if Option.isNone edef.Type then error (nonStandardEventError x.EventName m) @@ -2333,7 +2407,7 @@ type EventInfo = match x1, x2 with | FSEvent(g, pi1, vrefa1, vrefb1), FSEvent(_, pi2, vrefa2, vrefb2) -> PropInfo.PropInfosUseIdenticalDefinitions pi1 pi2 && valRefEq g vrefa1 vrefa2 && valRefEq g vrefb1 vrefb2 - | ILEvent(_, x1), ILEvent(_, x2) -> (x1.RawMetadata === x2.RawMetadata) + | ILEvent ileinfo1, ILEvent ileinfo2 -> (ileinfo1.RawMetadata === ileinfo2.RawMetadata) #if !NO_EXTENSIONTYPING | ProvidedEvent (_,ei1,_), ProvidedEvent (_,ei2,_) -> ProvidedEventInfo.TaintedEquals (ei1, ei2) #endif @@ -2342,7 +2416,7 @@ type EventInfo = /// Calculates a hash code of event info (similar as previous) member ei.ComputeHashCode() = match ei with - | ILEvent(_, x1) -> hash x1.RawMetadata.Name + | ILEvent ileinfo -> hash ileinfo.RawMetadata.Name | FSEvent(_, pi, vref1, vref2) -> hash ( pi.ComputeHashCode(), vref1.LogicalName, vref2.LogicalName) #if !NO_EXTENSIONTYPING | ProvidedEvent (_,ei,_) -> ProvidedEventInfo.TaintedGetHashCode(ei) @@ -2368,7 +2442,7 @@ let CompiledSigOfMeth g amap m (minfo:MethInfo) = // of the enclosing type. For example, they may have constraints involving the _formal_ type parameters // of the enclosing type. This instantiations can be used to interpret those type parameters let fmtpinst = - let parentTyArgs = argsOfAppTy g minfo.EnclosingAppType + let parentTyArgs = argsOfAppTy g minfo.LogicalEnclosingAppType let memberParentTypars = minfo.GetFormalTyparsOfDeclaringType m mkTyparInst memberParentTypars parentTyArgs diff --git a/src/fsharp/service/ServiceDeclarationLists.fs b/src/fsharp/service/ServiceDeclarationLists.fs index 8fa9f7d4509..ce7291f55ed 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fs +++ b/src/fsharp/service/ServiceDeclarationLists.fs @@ -560,9 +560,9 @@ type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForT let items = items |> SymbolHelpers.RemoveExplicitlySuppressedCompletionItems g let tyconRefOptEq tref1 tref2 = - match tref1 with - | Some tref1 -> tyconRefEq g tref1 tref2 - | None -> false + match tref1, tref2 with + | Some tref1, tref2 -> tyconRefEq g tref1 tref2 + | _ -> false // Adjust items priority. Sort by name. For things with the same name, // - show types with fewer generic parameters first @@ -576,10 +576,10 @@ type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForT | Item.FakeInterfaceCtor (TType_app(tcref,_)) | Item.DelegateCtor (TType_app(tcref,_)) -> { x with MinorPriority = 1000 + tcref.TyparsNoRange.Length } // Put type ctors after types, sorted by #typars. RemoveDuplicateItems will remove DefaultStructCtors if a type is also reported with this name - | Item.CtorGroup (_, (cinfo :: _)) -> { x with MinorPriority = 1000 + 10 * (tcrefOfAppTy g cinfo.EnclosingType).TyparsNoRange.Length } - | Item.MethodGroup(_, minfo :: _, _) -> { x with IsOwnMember = tyconRefOptEq x.Type minfo.DeclaringEntityRef } - | Item.Property(_, pinfo :: _) -> { x with IsOwnMember = tyconRefOptEq x.Type (tcrefOfAppTy g pinfo.EnclosingType) } - | Item.ILField finfo -> { x with IsOwnMember = tyconRefOptEq x.Type (tcrefOfAppTy g finfo.EnclosingType) } + | Item.CtorGroup (_, (cinfo :: _)) -> { x with MinorPriority = 1000 + 10 * cinfo.DeclaringTyconRef.TyparsNoRange.Length } + | Item.MethodGroup(_, minfo :: _, _) -> { x with IsOwnMember = tyconRefOptEq x.Type minfo.DeclaringTyconRef } + | Item.Property(_, pinfo :: _) -> { x with IsOwnMember = tyconRefOptEq x.Type pinfo.DeclaringTyconRef } + | Item.ILField finfo -> { x with IsOwnMember = tyconRefOptEq x.Type finfo.DeclaringTyconRef } | _ -> x) |> List.sortBy (fun x -> x.MinorPriority) |> List.fold (fun (prevRealPrior, prevNormalizedPrior, acc) x -> diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index a65b685b8c1..56263fe9de5 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -364,7 +364,7 @@ type TypeCheckInfo let result = match cnrs with | CNR(_, Item.CtorGroup(_, ((ctor::_) as ctors)), _, denv, nenv, ad, m) ::_ -> - let props = ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ctor.EnclosingType + let props = ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ctor.LogicalEnclosingType let parameters = CollectParameters ctors amap m let items = props @ parameters Some (denv, m, items) @@ -974,7 +974,7 @@ type TypeCheckInfo | Item.FakeInterfaceCtor (TType_app(tcref,_)) | Item.DelegateCtor (TType_app(tcref,_)) -> 1000 + tcref.TyparsNoRange.Length // Put type ctors after types, sorted by #typars. RemoveDuplicateItems will remove DefaultStructCtors if a type is also reported with this name - | Item.CtorGroup (_, (cinfo :: _)) -> 1000 + 10 * (tcrefOfAppTy g cinfo.EnclosingType).TyparsNoRange.Length + | Item.CtorGroup (_, (cinfo :: _)) -> 1000 + 10 * cinfo.DeclaringTyconRef.TyparsNoRange.Length | _ -> 0 (d.Item.DisplayName,n)) @@ -1149,7 +1149,7 @@ type TypeCheckInfo let typeVarNames = getTypeVarNames ilinfo ParamTypeSymbol.tryOfILTypes typeVarNames ilinfo.ILMethodRef.ArgTypes |> Option.map (fun args -> - let externalSym = ExternalSymbol.Constructor (ilinfo.ILMethodRef.EnclosingTypeRef.FullName, args) + let externalSym = ExternalSymbol.Constructor (ilinfo.ILMethodRef.DeclaringTypeRef.FullName, args) FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) | _ -> None @@ -1159,21 +1159,21 @@ type TypeCheckInfo let typeVarNames = getTypeVarNames ilinfo ParamTypeSymbol.tryOfILTypes typeVarNames ilinfo.ILMethodRef.ArgTypes |> Option.map (fun args -> - let externalSym = ExternalSymbol.Method (ilinfo.ILMethodRef.EnclosingTypeRef.FullName, name, args, ilinfo.ILMethodRef.GenericArity) + let externalSym = ExternalSymbol.Method (ilinfo.ILMethodRef.DeclaringTypeRef.FullName, name, args, ilinfo.ILMethodRef.GenericArity) FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) | _ -> None - | Item.Property (name, ILProp (_, propInfo) :: _) -> + | Item.Property (name, ILProp propInfo :: _) -> let methInfo = - if propInfo.HasGetter then Some (propInfo.GetterMethod g) - elif propInfo.HasSetter then Some (propInfo.SetterMethod g) + if propInfo.HasGetter then Some propInfo.GetterMethod + elif propInfo.HasSetter then Some propInfo.SetterMethod else None match methInfo with | Some methInfo -> match methInfo.MetadataScope with | ILScopeRef.Assembly assref -> - let externalSym = ExternalSymbol.Property (methInfo.ILMethodRef.EnclosingTypeRef.FullName, name) + let externalSym = ExternalSymbol.Property (methInfo.ILMethodRef.DeclaringTypeRef.FullName, name) Some (FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) | _ -> None | None -> None @@ -1185,7 +1185,7 @@ type TypeCheckInfo Some (FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) | _ -> None - | Item.Event (ILEvent (_, ILEventInfo (typeInfo, eventDef))) when not typeInfo.TyconRefOfRawMetadata.IsLocalRef -> + | Item.Event (ILEvent (ILEventInfo (typeInfo, eventDef))) when not typeInfo.TyconRefOfRawMetadata.IsLocalRef -> match typeInfo.ILScopeRef with | ILScopeRef.Assembly assref -> let externalSym = ExternalSymbol.Event (typeInfo.ILTypeRef.FullName, eventDef.Name) @@ -1353,7 +1353,7 @@ type TypeCheckInfo Some (m, SemanticClassificationType.ValueType) else Some (m, SemanticClassificationType.ReferenceType) | CNR(_, Item.CtorGroup(_, minfos), LegitTypeOccurence, _, _, _, m) -> - if minfos |> List.exists (fun minfo -> isStructTy g minfo.EnclosingType) then + if minfos |> List.exists (fun minfo -> isStructTy g minfo.LogicalEnclosingType) then Some (m, SemanticClassificationType.ValueType) else Some (m, SemanticClassificationType.ReferenceType) | CNR(_, Item.ExnCase _, LegitTypeOccurence, _, _, _, m) -> diff --git a/src/fsharp/symbols/Exprs.fs b/src/fsharp/symbols/Exprs.fs index 8d15a98ae96..13717ece55e 100644 --- a/src/fsharp/symbols/Exprs.fs +++ b/src/fsharp/symbols/Exprs.fs @@ -511,22 +511,22 @@ module FSharpExprConvert = E.TupleGet(tyR, n, ConvExpr cenv env e) | TOp.ILAsm([ I_ldfld(_, _, fspec) ], _), enclTypeArgs, [obj] -> - let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let typR = ConvILTypeRefApp cenv m fspec.DeclaringTypeRef enclTypeArgs let objR = ConvLValueExpr cenv env obj E.ILFieldGet(Some objR, typR, fspec.Name) | TOp.ILAsm(( [ I_ldsfld (_, fspec) ] | [ I_ldsfld (_, fspec); AI_nop ]), _), enclTypeArgs, [] -> - let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let typR = ConvILTypeRefApp cenv m fspec.DeclaringTypeRef enclTypeArgs E.ILFieldGet(None, typR, fspec.Name) | TOp.ILAsm([ I_stfld(_, _, fspec) ], _), enclTypeArgs, [obj;arg] -> - let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let typR = ConvILTypeRefApp cenv m fspec.DeclaringTypeRef enclTypeArgs let objR = ConvLValueExpr cenv env obj let argR = ConvExpr cenv env arg E.ILFieldSet(Some objR, typR, fspec.Name, argR) | TOp.ILAsm([ I_stsfld(_, fspec) ], _), enclTypeArgs, [arg] -> - let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let typR = ConvILTypeRefApp cenv m fspec.DeclaringTypeRef enclTypeArgs let argR = ConvExpr cenv env arg E.ILFieldSet(None, typR, fspec.Name, argR) @@ -694,9 +694,9 @@ module FSharpExprConvert = // this does not matter currently, type checking fails to resolve it when a TP references a union case subclass try // if the type is an union case class, lookup will fail - Import.ImportILTypeRef cenv.amap m ilMethRef.EnclosingTypeRef, None + Import.ImportILTypeRef cenv.amap m ilMethRef.DeclaringTypeRef, None with _ -> - let e = ilMethRef.EnclosingTypeRef + let e = ilMethRef.DeclaringTypeRef let parent = ILTypeRef.Create(e.Scope, e.Enclosing.Tail, e.Enclosing.Head) Import.ImportILTypeRef cenv.amap m parent, Some e.Name @@ -843,7 +843,7 @@ module FSharpExprConvert = let logicalName = ilMethRef.Name let isMember = memberParentName.IsSome if isMember then - match ilMethRef.Name, ilMethRef.EnclosingTypeRef.Name with + match ilMethRef.Name, ilMethRef.DeclaringTypeRef.Name with | "Invoke", "Microsoft.FSharp.Core.FSharpFunc`2" -> let objR = ConvLValueExpr cenv env callArgs.Head let argR = ConvExpr cenv env callArgs.Tail.Head @@ -852,7 +852,7 @@ module FSharpExprConvert = | _ -> let isCtor = (ilMethRef.Name = ".ctor") let isStatic = isCtor || ilMethRef.CallingConv.IsStatic - let scoref = ilMethRef.EnclosingTypeRef.Scope + let scoref = ilMethRef.DeclaringTypeRef.Scope let typars1 = tcref.Typars(m) let typars2 = [ 1 .. ilMethRef.GenericArity ] |> List.map (fun _ -> NewRigidTypar "T" m) let tinst1 = typars1 |> generalizeTypars diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index 6cd917ad609..f7855e11d36 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -393,7 +393,7 @@ module internal SymbolHelpers = | _ -> minfo.ArbitraryValRef |> Option.bind ccuOfValRef - |> Option.orElseWith (fun () -> minfo.DeclaringEntityRef |> computeCcuOfTyconRef) + |> Option.orElseWith (fun () -> minfo.DeclaringTyconRef |> computeCcuOfTyconRef) let rec ccuOfItem (g:TcGlobals) d = @@ -403,13 +403,13 @@ module internal SymbolHelpers = | Item.ActivePatternCase apref -> ccuOfValRef apref.ActivePatternVal | Item.ExnCase tcref -> computeCcuOfTyconRef tcref | Item.RecdField rfinfo -> computeCcuOfTyconRef rfinfo.RecdFieldRef.TyconRef - | Item.Event einfo -> einfo.EnclosingType |> tcrefOfAppTy g |> computeCcuOfTyconRef - | Item.ILField finfo -> finfo.EnclosingType |> tcrefOfAppTy g |> computeCcuOfTyconRef + | Item.Event einfo -> einfo.DeclaringTyconRef |> computeCcuOfTyconRef + | Item.ILField finfo -> finfo.DeclaringTyconRef |> computeCcuOfTyconRef | Item.Property(_, pinfos) -> pinfos |> List.tryPick (fun pinfo -> pinfo.ArbitraryValRef |> Option.bind ccuOfValRef - |> Option.orElseWith (fun () -> pinfo.EnclosingType |> tcrefOfAppTy g |> computeCcuOfTyconRef)) + |> Option.orElseWith (fun () -> pinfo.DeclaringTyconRef |> computeCcuOfTyconRef)) | Item.ArgName (_, _, Some (ArgumentContainer.Method minfo)) -> ccuOfMethInfo g minfo @@ -520,7 +520,7 @@ module internal SymbolHelpers = let amap = infoReader.amap match minfo with | FSMeth (g, _, vref, _) -> - GetXmlDocSigOfScopedValRef g minfo.DeclaringEntityRef vref + GetXmlDocSigOfScopedValRef g minfo.DeclaringTyconRef vref | ILMeth (g, ilminfo, _) -> let actualTypeName = ilminfo.DeclaringTyconRef.CompiledRepresentationForNamedType.FullName let fmtps = ilminfo.FormalMethodTypars @@ -555,19 +555,18 @@ module internal SymbolHelpers = else None - let GetXmlDocSigOfProp infoReader m pinfo = + let GetXmlDocSigOfProp infoReader m (pinfo: PropInfo) = + let g = pinfo.TcGlobals match pinfo with #if !NO_EXTENSIONTYPING | ProvidedProp _ -> None // No signature is possible. If an xml comment existed it would have been returned by PropInfo.XmlDoc in infos.fs #endif - | FSProp (g, typ, _, _) as fspinfo -> - let tcref = tcrefOfAppTy g typ + | FSProp _ as fspinfo -> match fspinfo.ArbitraryValRef with | None -> None - | Some vref -> GetXmlDocSigOfScopedValRef g tcref vref - | ILProp(g, (ILPropInfo(tinfo, pdef))) -> - let tcref = tinfo.TyconRefOfRawMetadata - match metaInfoOfEntityRef infoReader m tcref with + | Some vref -> GetXmlDocSigOfScopedValRef g pinfo.DeclaringTyconRef vref + | ILProp(ILPropInfo(_, pdef)) -> + match metaInfoOfEntityRef infoReader m pinfo.DeclaringTyconRef with | Some (ccuFileName, formalTypars, formalTypeInfo) -> let filpinfo = ILPropInfo(formalTypeInfo, pdef) Some (ccuFileName, "P:"+formalTypeInfo.ILTypeRef.FullName+"."+pdef.Name+XmlDocArgsEnc g (formalTypars, []) (filpinfo.GetParamTypes(infoReader.amap, m))) @@ -575,17 +574,15 @@ module internal SymbolHelpers = let GetXmlDocSigOfEvent infoReader m (einfo:EventInfo) = match einfo with - | ILEvent(_, ilEventInfo) -> - let tinfo = ilEventInfo.ILTypeInfo - let tcref = tinfo.TyconRefOfRawMetadata - match metaInfoOfEntityRef infoReader m tcref with + | ILEvent _ -> + match metaInfoOfEntityRef infoReader m einfo.DeclaringTyconRef with | Some (ccuFileName, _, formalTypeInfo) -> Some(ccuFileName, "E:"+formalTypeInfo.ILTypeRef.FullName+"."+einfo.EventName) | _ -> None | _ -> None let GetXmlDocSigOfILFieldInfo infoReader m (finfo:ILFieldInfo) = - match metaInfoOfEntityRef infoReader m (tcrefOfAppTy infoReader.g finfo.EnclosingType) with + match metaInfoOfEntityRef infoReader m finfo.DeclaringTyconRef with | Some (ccuFileName, _, formalTypeInfo) -> Some(ccuFileName, "F:"+formalTypeInfo.ILTypeRef.FullName+"."+finfo.FieldName) | _ -> None @@ -706,7 +703,7 @@ module internal SymbolHelpers = // This may explore assemblies that are not in the reference set. // In this case just bail out and assume items are not equal protectAssemblyExploration false (fun () -> - let equalTypes(ty1, ty2) = + let equalHeadTypes(ty1, ty2) = if isAppTy g ty1 && isAppTy g ty2 then tyconRefEq g (tcrefOfAppTy g ty1) (tcrefOfAppTy g ty2) else typeEquiv g ty1 ty2 @@ -714,13 +711,13 @@ module internal SymbolHelpers = // Much of this logic is already covered by 'ItemsAreEffectivelyEqual' match item1, item2 with - | Item.DelegateCtor(ty1), Item.DelegateCtor(ty2) -> equalTypes(ty1, ty2) + | Item.DelegateCtor(ty1), Item.DelegateCtor(ty2) -> equalHeadTypes(ty1, ty2) | Item.Types(dn1, [ty1]), Item.Types(dn2, [ty2]) -> // Bug 4403: We need to compare names as well, because 'int' and 'Int32' are physically the same type, but we want to show both - dn1 = dn2 && equalTypes(ty1, ty2) + dn1 = dn2 && equalHeadTypes(ty1, ty2) // Prefer a type to a DefaultStructCtor, a DelegateCtor and a FakeInterfaceCtor - | ItemWhereTypIsPreferred(ty1), ItemWhereTypIsPreferred(ty2) -> equalTypes(ty1, ty2) + | ItemWhereTypIsPreferred(ty1), ItemWhereTypIsPreferred(ty2) -> equalHeadTypes(ty1, ty2) | Item.ExnCase(tcref1), Item.ExnCase(tcref2) -> tyconRefEq g tcref1 tcref2 | Item.ILField(ILFieldInfo(_, fld1)), Item.ILField(ILFieldInfo(_, fld2)) -> @@ -823,7 +820,7 @@ module internal SymbolHelpers = | Item.Types(it, [ty]) -> g.suppressed_types |> List.exists (fun supp -> - if isAppTy g ty then + if isAppTy g ty && isAppTy g (generalizedTyconRef supp) then // check if they are the same logical type (after removing all abbreviations) let tcr1 = tcrefOfAppTy g ty let tcr2 = tcrefOfAppTy g (generalizedTyconRef supp) @@ -861,12 +858,12 @@ module internal SymbolHelpers = | Item.RecdField rfinfo -> fullDisplayTextOfRecdFieldRef rfinfo.RecdFieldRef | Item.NewDef id -> id.idText | Item.ILField finfo -> bufs (fun os -> NicePrint.outputILTypeRef denv os finfo.ILTypeRef; bprintf os ".%s" finfo.FieldName) - | Item.Event einfo -> bufs (fun os -> NicePrint.outputTyconRef denv os (tcrefOfAppTy g einfo.EnclosingType); bprintf os ".%s" einfo.EventName) - | Item.Property(_, (pinfo::_)) -> bufs (fun os -> NicePrint.outputTyconRef denv os (tcrefOfAppTy g pinfo.EnclosingType); bprintf os ".%s" pinfo.PropertyName) + | Item.Event einfo -> bufs (fun os -> NicePrint.outputTyconRef denv os einfo.DeclaringTyconRef; bprintf os ".%s" einfo.EventName) + | Item.Property(_, (pinfo::_)) -> bufs (fun os -> NicePrint.outputTyconRef denv os pinfo.DeclaringTyconRef; bprintf os ".%s" pinfo.PropertyName) | Item.CustomOperation (customOpName, _, _) -> customOpName - | Item.CtorGroup(_, minfo :: _) -> bufs (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringEntityRef) - | Item.MethodGroup(_, _, Some minfo) -> bufs (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringEntityRef; bprintf os ".%s" minfo.DisplayName) - | Item.MethodGroup(_, minfo :: _, _) -> bufs (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringEntityRef; bprintf os ".%s" minfo.DisplayName) + | Item.CtorGroup(_, minfo :: _) -> bufs (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef) + | Item.MethodGroup(_, _, Some minfo) -> bufs (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName) + | Item.MethodGroup(_, minfo :: _, _) -> bufs (fun os -> NicePrint.outputTyconRef denv os minfo.DeclaringTyconRef; bprintf os ".%s" minfo.DisplayName) | Item.UnqualifiedType (tcref :: _) -> bufs (fun os -> NicePrint.outputTyconRef denv os tcref) | Item.FakeInterfaceCtor typ | Item.DelegateCtor typ @@ -1082,7 +1079,7 @@ module internal SymbolHelpers = let rty, _cxs = PrettyTypes.PrettifyType g rty let layout = wordL (tagText (FSComp.SR.typeInfoEvent())) ^^ - NicePrint.layoutTyconRef denv (tcrefOfAppTy g einfo.EnclosingType) ^^ + NicePrint.layoutTyconRef denv (tcrefOfAppTy g einfo.LogicalEnclosingAppType) ^^ SepL.dot ^^ wordL (tagEvent einfo.EventName) ^^ RightL.colon ^^ @@ -1113,7 +1110,7 @@ module internal SymbolHelpers = ) ^^ SepL.lineBreak ^^ SepL.lineBreak ^^ wordL (tagText (FSComp.SR.typeInfoCallsWord())) ^^ - NicePrint.layoutTyconRef denv (tcrefOfAppTy g minfo.EnclosingType) ^^ + NicePrint.layoutTyconRef denv (tcrefOfAppTy g minfo.LogicalEnclosingAppType) ^^ SepL.dot ^^ wordL (tagMethod minfo.DisplayName) @@ -1367,7 +1364,7 @@ module internal SymbolHelpers = (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some | ParentNone -> None - | ILProp(_, (ILPropInfo(tinfo, pdef))) -> + | ILProp(ILPropInfo(tinfo, pdef)) -> let tcref = tinfo.TyconRefOfRawMetadata (tcref |> ticksAndArgCountTextOfTyconRef)+"."+pdef.Name |> Some | FSProp _ -> None @@ -1378,9 +1375,8 @@ module internal SymbolHelpers = | Item.Event einfo -> match einfo with - | ILEvent(_, ilEventInfo) -> - let tinfo = ilEventInfo.ILTypeInfo - let tcref = tinfo.TyconRefOfRawMetadata + | ILEvent _ -> + let tcref = einfo.DeclaringTyconRef (tcref |> ticksAndArgCountTextOfTyconRef)+"."+einfo.EventName |> Some | FSEvent(_, pinfo, _, _) -> match pinfo.ArbitraryValRef with @@ -1400,15 +1396,12 @@ module internal SymbolHelpers = match vref.ActualParent with | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef) + ".#ctor"|> Some | ParentNone -> None - | (ILMeth (_, minfo, _)) :: _ -> - let tcref = minfo.DeclaringTyconRef - (tcref |> ticksAndArgCountTextOfTyconRef)+".#ctor" |> Some - | (DefaultStructCtor (g, typ) :: _) -> - let tcref = tcrefOfAppTy g typ - (ticksAndArgCountTextOfTyconRef tcref) + ".#ctor" |> Some #if !NO_EXTENSIONTYPING | ProvidedMeth _::_ -> None #endif + | minfo :: _ -> + let tcref = minfo.DeclaringTyconRef + (tcref |> ticksAndArgCountTextOfTyconRef)+".#ctor" |> Some | Item.CustomOperation (_, _, Some minfo) -> getKeywordForMethInfo minfo | Item.MethodGroup(_, _, Some minfo) -> getKeywordForMethInfo minfo | Item.MethodGroup(_, minfo :: _, _) -> getKeywordForMethInfo minfo diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index 535007d2c4d..13d0be353d9 100644 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -565,7 +565,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = let formalTypeInfo = ILTypeInfo.FromType cenv.g ty tdef.Fields.AsList |> List.map (fun tdef -> let ilFieldInfo = ILFieldInfo(formalTypeInfo, tdef) - FSharpField(cenv, FSharpFieldData.ILField(cenv.g, ilFieldInfo) )) + FSharpField(cenv, FSharpFieldData.ILField(ilFieldInfo) )) |> makeReadOnlyCollection else @@ -711,19 +711,21 @@ and FSharpUnionCase(cenv, v: UnionCaseRef) = and FSharpFieldData = - | ILField of TcGlobals * ILFieldInfo + | ILField of ILFieldInfo | RecdOrClass of RecdFieldRef | Union of UnionCaseRef * int + member x.TryRecdField = match x with | RecdOrClass v -> v.RecdField |> Choice1Of2 | Union (v, n) -> v.FieldByIndex(n) |> Choice1Of2 - | ILField (_, f) -> f |> Choice2Of2 + | ILField f -> f |> Choice2Of2 + member x.DeclaringTyconRef = match x with | RecdOrClass v -> v.TyconRef | Union (v, _) -> v.TyconRef - | ILField (g, f) -> tcrefOfAppTy g f.EnclosingType + | ILField f -> f.DeclaringTyconRef and FSharpField(cenv: cenv, d: FSharpFieldData) = inherit FSharpSymbol (cenv, @@ -735,8 +737,8 @@ and FSharpField(cenv: cenv, d: FSharpFieldData) = | Union (v, _) -> // This is not correct: there is no "Item" for a named union case field Item.UnionCase(UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange, v), false) - | ILField (_, f) -> - Item.ILField(f)), + | ILField f -> + Item.ILField f), (fun this thisCcu2 ad -> checkForCrossProjectAccessibility (thisCcu2, ad) (cenv.thisCcu, (this :?> FSharpField).Accessibility.Contents)) //&& @@ -812,7 +814,7 @@ and FSharpField(cenv: cenv, d: FSharpFieldData) = | Union (v, _) -> let unionCase = UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange, v) SymbolHelpers.GetXmlDocSigOfUnionCaseInfo unionCase - | ILField (_, f) -> + | ILField f -> SymbolHelpers.GetXmlDocSigOfILFieldInfo cenv.infoReader range0 f match xmlsig with | Some (_, docsig) -> docsig @@ -1258,12 +1260,23 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | Some v -> v | None -> failwith "DeclarationLocation property not available" + member __.EnclosingEntity = + checkIsResolved() + match d with + | E e -> FSharpEntity(cenv, e.DeclaringTyconRef) |> Some + | P p -> FSharpEntity(cenv, p.DeclaringTyconRef) |> Some + | M m | C m -> FSharpEntity(cenv, m.DeclaringTyconRef) |> Some + | V v -> + match v.ActualParent with + | ParentNone -> None + | Parent p -> FSharpEntity(cenv, p) |> Some + member __.LogicalEnclosingEntity = checkIsResolved() match d with - | E m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) - | P m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) - | M m | C m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) + | E m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.LogicalEnclosingAppType) + | P p -> FSharpEntity(cenv, tcrefOfAppTy cenv.g p.LogicalEnclosingAppType) + | M m | C m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.LogicalEnclosingAppType) | V v -> match v.ApparentParent with | ParentNone -> invalidOp "the value or member doesn't have a logical parent" @@ -1296,7 +1309,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = if isUnresolved() then false else match d with - | P m -> m.HasGetter + | P p -> p.HasGetter | E _ | M _ | C _ @@ -1305,19 +1318,35 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member __.GetterMethod = checkIsResolved() match d with - | P m -> mkMethSym m.GetterMethod + | P p -> mkMethSym p.GetterMethod | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated getter method" + member __.HasSetterMethod = + if isUnresolved() then false + else + match d with + | P p -> p.HasSetter + | E _ + | M _ + | C _ + | V _ -> false + + member __.SetterMethod = + checkIsResolved() + match d with + | P p -> mkMethSym p.SetterMethod + | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated setter method" + member __.EventAddMethod = checkIsResolved() match d with - | E e -> mkMethSym (e.GetAddMethod()) + | E e -> mkMethSym e.AddMethod | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated add method" member __.EventRemoveMethod = checkIsResolved() match d with - | E e -> mkMethSym (e.GetRemoveMethod()) + | E e -> mkMethSym e.RemoveMethod | P _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated remove method" member __.EventDelegateType = @@ -1334,33 +1363,6 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = TryDestStandardDelegateTyp cenv.infoReader range0 AccessibleFromSomewhere dty |> Option.isSome | P _ | M _ | C _ | V _ -> invalidOp "the value or member is not an event" - member __.HasSetterMethod = - if isUnresolved() then false - else - match d with - | P m -> m.HasSetter - | E _ - | M _ - | C _ - | V _ -> false - - member __.SetterMethod = - checkIsResolved() - match d with - | P m -> mkMethSym m.SetterMethod - | E _ | M _ | C _ | V _ -> invalidOp "the value or member doesn't have an associated setter method" - - member __.EnclosingEntity = - checkIsResolved() - match d with - | E m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) |> Some - | P m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) |> Some - | M m | C m -> FSharpEntity(cenv, m.DeclaringEntityRef) |> Some - | V v -> - match v.ActualParent with - | ParentNone -> None - | Parent p -> FSharpEntity(cenv, p) |> Some - member __.IsCompilerGenerated = if isUnresolved() then false else match fsharpInfo() with @@ -1400,7 +1402,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member __.IsDispatchSlot = if isUnresolved() then false else match d with - | E e -> e.GetAddMethod().IsDispatchSlot + | E e -> e.AddMethod.IsDispatchSlot | P p -> p.IsDispatchSlot | M m | C m -> m.IsDispatchSlot | V v -> v.IsDispatchSlot @@ -1418,8 +1420,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member x.EventForFSharpProperty = match d with | P p when p.IsFSharpEventProperty -> - let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.EnclosingType - let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.EnclosingType + let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.LogicalEnclosingType + let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.LogicalEnclosingType match minfos1, minfos2 with | [addMeth], [removeMeth] -> match addMeth.ArbitraryValRef, removeMeth.ArbitraryValRef with @@ -1433,9 +1435,9 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match d with | M m when m.LogicalName.StartsWith("add_") -> let eventName = m.LogicalName.[4..] - let entityTy = generalizedTyconRef m.DeclaringEntityRef + let entityTy = generalizedTyconRef m.DeclaringTyconRef not (isNil (cenv.infoReader.GetImmediateIntrinsicEventsOfType (Some eventName, AccessibleFromSomeFSharpCode, range0, entityTy))) || - let declaringTy = generalizedTyconRef m.DeclaringEntityRef + let declaringTy = generalizedTyconRef m.DeclaringTyconRef match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with | pinfo :: _ -> pinfo.IsFSharpEventProperty | _ -> false @@ -1447,9 +1449,9 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match d with | M m when m.LogicalName.StartsWith("remove_") -> let eventName = m.LogicalName.[7..] - let entityTy = generalizedTyconRef m.DeclaringEntityRef + let entityTy = generalizedTyconRef m.DeclaringTyconRef not (isNil (cenv.infoReader.GetImmediateIntrinsicEventsOfType (Some eventName, AccessibleFromSomeFSharpCode, range0, entityTy))) || - let declaringTy = generalizedTyconRef m.DeclaringEntityRef + let declaringTy = generalizedTyconRef m.DeclaringTyconRef match GetImmediateIntrinsicPropInfosOfType (Some eventName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy with | pinfo :: _ -> pinfo.IsFSharpEventProperty | _ -> false @@ -1474,7 +1476,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match d with | M m when m.LogicalName.StartsWith("get_") -> let propName = PrettyNaming.ChopPropertyName(m.LogicalName) - let declaringTy = generalizedTyconRef m.DeclaringEntityRef + let declaringTy = generalizedTyconRef m.DeclaringTyconRef not (isNil (GetImmediateIntrinsicPropInfosOfType (Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy)) | V v -> v.IsPropertyGetterMethod | _ -> false @@ -1485,7 +1487,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = // Look for a matching property with the right name. | M m when m.LogicalName.StartsWith("set_") -> let propName = PrettyNaming.ChopPropertyName(m.LogicalName) - let declaringTy = generalizedTyconRef m.DeclaringEntityRef + let declaringTy = generalizedTyconRef m.DeclaringTyconRef not (isNil (GetImmediateIntrinsicPropInfosOfType (Some propName, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 declaringTy)) | V v -> v.IsPropertySetterMethod | _ -> false @@ -1510,7 +1512,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member __.IsExtensionMember = if isUnresolved() then false else match d with - | E e -> e.GetAddMethod().IsExtensionMember + | E e -> e.AddMethod.IsExtensionMember | P p -> p.IsExtensionMember | M m -> m.IsExtensionMember | V v -> v.IsExtensionMember @@ -1520,7 +1522,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member __.IsOverrideOrExplicitInterfaceImplementation = if isUnresolved() then false else match d with - | E e -> e.GetAddMethod().IsDefiniteFSharpOverride + | E e -> e.AddMethod.IsDefiniteFSharpOverride | P p -> p.IsDefiniteFSharpOverride | M m -> m.IsDefiniteFSharpOverride | V v -> @@ -1530,7 +1532,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member __.IsExplicitInterfaceImplementation = if isUnresolved() then false else match d with - | E e -> e.GetAddMethod().IsFSharpExplicitInterfaceImplementation + | E e -> e.AddMethod.IsFSharpExplicitInterfaceImplementation | P p -> p.IsFSharpExplicitInterfaceImplementation | M m -> m.IsFSharpExplicitInterfaceImplementation | V v -> v.IsFSharpExplicitInterfaceImplementation cenv.g @@ -1540,7 +1542,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = checkIsResolved() let sigs = match d with - | E e -> e.GetAddMethod().ImplementedSlotSignatures + | E e -> e.AddMethod.ImplementedSlotSignatures | P p -> p.ImplementedSlotSignatures | M m | C m -> m.ImplementedSlotSignatures | V v -> v.ImplementedSlotSignatures @@ -1770,9 +1772,9 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = // For IL events, we get an approximate accessiblity that at least reports "internal" as "internal" and "private" as "private" let access = match e with - | ILEvent (_, x) -> - let ilAccess = AccessibilityLogic.GetILAccessOfILEventInfo x - getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess + | ILEvent ileinfo -> + let ilAccess = AccessibilityLogic.GetILAccessOfILEventInfo ileinfo + getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess | _ -> taccessPublic FSharpAccessibility(access) @@ -1781,8 +1783,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = // For IL properties, we get an approximate accessiblity that at least reports "internal" as "internal" and "private" as "private" let access = match p with - | ILProp (_, x) -> - let ilAccess = AccessibilityLogic.GetILAccessOfILPropInfo x + | ILProp ilpinfo -> + let ilAccess = AccessibilityLogic.GetILAccessOfILPropInfo ilpinfo getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess | _ -> taccessPublic @@ -2064,7 +2066,7 @@ and FSharpAttribute(cenv: cenv, attrib: AttribInfo) = NicePrint.stringOfFSAttrib (denv.Contents g) attrib | AttribInfo.ILAttribInfo (g, _, _scoref, cattr, _) -> let parms, _args = decodeILAttribData g.ilg cattr - NicePrint.stringOfILAttrib (denv.Contents g) (cattr.Method.EnclosingType, parms) + NicePrint.stringOfILAttrib (denv.Contents g) (cattr.Method.DeclaringType, parms) override __.ToString() = if entityIsUnresolved attrib.TyconRef then "attribute ???" else "attribute " + attrib.TyconRef.CompiledName + "(...)" @@ -2212,7 +2214,7 @@ type FSharpSymbol with | Item.ExnCase tcref -> FSharpEntity(cenv, tcref) :>_ | Item.RecdField rfinfo -> FSharpField(cenv, RecdOrClass rfinfo.RecdFieldRef) :> _ - | Item.ILField finfo -> FSharpField(cenv, ILField (cenv.g, finfo)) :> _ + | Item.ILField finfo -> FSharpField(cenv, ILField finfo) :> _ | Item.Event einfo -> FSharpMemberOrFunctionOrValue(cenv, E einfo, item) :> _ diff --git a/src/ilx/EraseUnions.fs b/src/ilx/EraseUnions.fs index c75ab90f05f..b7f284dbf84 100644 --- a/src/ilx/EraseUnions.fs +++ b/src/ilx/EraseUnions.fs @@ -168,7 +168,7 @@ let cuspecRepr = (fun cuspec -> cuspec.HasHelpers = IlxUnionHasHelpers.SpecialFSharpListHelpers), (fun cuspec -> cuspec.Boxity = ILBoxity.AsValue), (fun (alt:IlxUnionAlternative) -> alt.Name), - (fun cuspec -> cuspec.EnclosingType), + (fun cuspec -> cuspec.DeclaringType), (fun (cuspec,nm) -> mkILNamedTy cuspec.Boxity (mkILTyRefInTyRef (mkCasesTypeRef cuspec, nm)) cuspec.GenericArgs)) type NoTypesGeneratedViaThisReprDecider = NoTypesGeneratedViaThisReprDecider From abfa1aa0b6d6d3d5c4aad6368cfd14107999c671 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 15:07:59 +0000 Subject: [PATCH 12/17] update test cases --- fcs/RELEASE_NOTES.md | 9 +++++++ fcs/docsrc/content/ja/symbols.fsx | 4 +-- fcs/docsrc/content/symbols.fsx | 4 +-- src/fsharp/service/ServiceAnalysis.fs | 2 +- src/fsharp/service/ServiceAssemblyContent.fs | 2 +- .../service/ServiceInterfaceStubGenerator.fs | 2 +- src/fsharp/symbols/SymbolPatterns.fs | 2 +- src/fsharp/symbols/Symbols.fs | 8 +++--- src/fsharp/symbols/Symbols.fsi | 12 ++++----- tests/service/CSharpProjectAnalysis.fs | 4 +-- tests/service/EditorTests.fs | 4 +-- tests/service/ExprTests.fs | 4 +-- tests/service/MultiProjectAnalysisTests.fs | 4 +-- tests/service/ProjectAnalysisTests.fs | 26 +++++++++---------- .../FSharpCheckerExtensions.fs | 6 ++--- .../unittests/CompletionProviderTests.fs | 2 +- 16 files changed, 52 insertions(+), 43 deletions(-) diff --git a/fcs/RELEASE_NOTES.md b/fcs/RELEASE_NOTES.md index 44eeb9ef347..677addced72 100644 --- a/fcs/RELEASE_NOTES.md +++ b/fcs/RELEASE_NOTES.md @@ -1,3 +1,12 @@ +#### 19.0.1 + * Rename ``EnclosingEntity`` to ``DeclaringEntity``. In the case of extension properties, ``EnclosingEntity`` was incorrectly returning the logical enclosing entity (i.e. the type the property appears to extend), and in this case ``LogicalEnclosingEntity`` should be used instead. + +#### 18.0.1 + * Integrate visualfsharp master + +#### 17.0.2 + * Integrate visualfsharp master + #### 16.0.3 * [File name deduplication not working with ParseAndCheckFileInProject](https://github.com/fsharp/FSharp.Compiler.Service/issues/819) diff --git a/fcs/docsrc/content/ja/symbols.fsx b/fcs/docsrc/content/ja/symbols.fsx index 15ebfab65b0..c962a2b8f62 100644 --- a/fcs/docsrc/content/ja/symbols.fsx +++ b/fcs/docsrc/content/ja/symbols.fsx @@ -113,8 +113,8 @@ fnVal.CurriedParameterGroups.[0].[0].Name // "x" fnVal.CurriedParameterGroups.[0].[1].Name // "y" fnVal.DeclarationLocation.StartLine // 3 fnVal.DisplayName // "foo" -fnVal.EnclosingEntity.DisplayName // "Test" -fnVal.EnclosingEntity.DeclarationLocation.StartLine // 1 +fnVal.DeclaringEntity.DisplayName // "Test" +fnVal.DeclaringEntity.DeclarationLocation.StartLine // 1 fnVal.GenericParameters.Count // 0 fnVal.InlineAnnotation // FSharpInlineAnnotation.OptionalInline fnVal.IsActivePattern // false diff --git a/fcs/docsrc/content/symbols.fsx b/fcs/docsrc/content/symbols.fsx index a4e118df1b0..fb6275fd37c 100644 --- a/fcs/docsrc/content/symbols.fsx +++ b/fcs/docsrc/content/symbols.fsx @@ -109,8 +109,8 @@ fnVal.CurriedParameterGroups.[0].[0].Name // "x" fnVal.CurriedParameterGroups.[0].[1].Name // "y" fnVal.DeclarationLocation.StartLine // 3 fnVal.DisplayName // "foo" -fnVal.EnclosingEntity.DisplayName // "Test" -fnVal.EnclosingEntity.DeclarationLocation.StartLine // 1 +fnVal.DeclaringEntity.DisplayName // "Test" +fnVal.DeclaringEntity.DeclarationLocation.StartLine // 1 fnVal.GenericParameters.Count // 0 fnVal.InlineAnnotation // FSharpInlineAnnotation.OptionalInline fnVal.IsActivePattern // false diff --git a/src/fsharp/service/ServiceAnalysis.fs b/src/fsharp/service/ServiceAnalysis.fs index 5923459c031..d8b05a2d063 100644 --- a/src/fsharp/service/ServiceAnalysis.fs +++ b/src/fsharp/service/ServiceAnalysis.fs @@ -130,7 +130,7 @@ module UnusedOpens = let usedByEnclosingEntity = match symbolUse.Symbol with | :? FSharpMemberOrFunctionOrValue as f -> - match f.EnclosingEntity with + match f.DeclaringEntity with | Some ent when ent.IsNamespace || ent.IsFSharpModule -> Some (ent.IsEffectivelySameAs modul.Entity) | _ -> None diff --git a/src/fsharp/service/ServiceAssemblyContent.fs b/src/fsharp/service/ServiceAssemblyContent.fs index 6020e59c787..f4a7ac416c3 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fs +++ b/src/fsharp/service/ServiceAssemblyContent.fs @@ -88,7 +88,7 @@ module Extensions = member x.TryGetFullCompiledOperatorNameIdents() : Idents option = // For operator ++ displayName is ( ++ ) compiledName is op_PlusPlus if isOperator x.DisplayName && x.DisplayName <> x.CompiledName then - x.EnclosingEntity + x.DeclaringEntity |> Option.bind (fun e -> e.TryGetFullName()) |> Option.map (fun enclosingEntityFullName -> Array.append (enclosingEntityFullName.Split '.') [| x.CompiledName |]) diff --git a/src/fsharp/service/ServiceInterfaceStubGenerator.fs b/src/fsharp/service/ServiceInterfaceStubGenerator.fs index 4f62581f1bf..47c0de31e32 100644 --- a/src/fsharp/service/ServiceInterfaceStubGenerator.fs +++ b/src/fsharp/service/ServiceInterfaceStubGenerator.fs @@ -448,7 +448,7 @@ module internal InterfaceStubGenerator = let internal (|TypeOfMember|_|) (m: FSharpMemberOrFunctionOrValue) = match m.FullTypeSafe with - | Some (MemberFunctionType typ) when m.IsProperty && m.EnclosingEntity.IsSome && m.EnclosingEntity.Value.IsFSharp -> + | Some (MemberFunctionType typ) when m.IsProperty && m.DeclaringEntity.IsSome && m.DeclaringEntity.Value.IsFSharp -> Some typ | Some typ -> Some typ | None -> None diff --git a/src/fsharp/symbols/SymbolPatterns.fs b/src/fsharp/symbols/SymbolPatterns.fs index 8ae4b90bf9d..22b406e12fb 100644 --- a/src/fsharp/symbols/SymbolPatterns.fs +++ b/src/fsharp/symbols/SymbolPatterns.fs @@ -202,7 +202,7 @@ module Symbol = /// Constructor (enclosingEntity) let (|Constructor|_|) (func: FSharpMemberOrFunctionOrValue) = match func.CompiledName with - | ".ctor" | ".cctor" -> func.EnclosingEntity + | ".ctor" | ".cctor" -> func.DeclaringEntity | _ -> None let (|Function|_|) excluded (func: FSharpMemberOrFunctionOrValue) = diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index 13d0be353d9..e08148a670b 100644 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -939,7 +939,7 @@ and FSharpActivePatternGroup(cenv, apinfo:PrettyNaming.ActivePatternInfo, typ, v member __.OverallType = FSharpType(cenv, typ) - member __.EnclosingEntity = + member __.DeclaringEntity = valOpt |> Option.bind (fun vref -> match vref.ActualParent with @@ -1260,7 +1260,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | Some v -> v | None -> failwith "DeclarationLocation property not available" - member __.EnclosingEntity = + member __.DeclaringEntity = checkIsResolved() match d with | E e -> FSharpEntity(cenv, e.DeclaringTyconRef) |> Some @@ -1774,7 +1774,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match e with | ILEvent ileinfo -> let ilAccess = AccessibilityLogic.GetILAccessOfILEventInfo ileinfo - getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess + getApproxFSharpAccessibilityOfMember this.DeclaringEntity.Value.Entity ilAccess | _ -> taccessPublic FSharpAccessibility(access) @@ -1785,7 +1785,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match p with | ILProp ilpinfo -> let ilAccess = AccessibilityLogic.GetILAccessOfILPropInfo ilpinfo - getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess + getApproxFSharpAccessibilityOfMember this.DeclaringEntity.Value.Entity ilAccess | _ -> taccessPublic FSharpAccessibility(access) diff --git a/src/fsharp/symbols/Symbols.fsi b/src/fsharp/symbols/Symbols.fsi index 5d9c1b9417c..152be3b33ac 100644 --- a/src/fsharp/symbols/Symbols.fsi +++ b/src/fsharp/symbols/Symbols.fsi @@ -641,8 +641,11 @@ and [] public FSharpMemberOrFunctionOrValue = member IsUnresolved : bool /// Get the enclosing entity for the definition - member EnclosingEntity : FSharpEntity option + member DeclaringEntity : FSharpEntity option + /// Get the logical enclosing entity, which for an extension member is type being extended + member LogicalEnclosingEntity: FSharpEntity + /// Get the declaration location of the member, function or value member DeclarationLocation: range @@ -768,9 +771,6 @@ and [] public FSharpMemberOrFunctionOrValue = /// Get the logical name of the member member LogicalName: string - /// Get the logical enclosing entity, which for an extension member is type being extended - member LogicalEnclosingEntity: FSharpEntity - /// Get the name as presented in F# error messages and documentation member DisplayName : string @@ -882,8 +882,8 @@ and [] public FSharpActivePatternGroup = /// Get the type indicating signature of the active pattern member OverallType : FSharpType - /// Try to get the enclosing entity of the active pattern - member EnclosingEntity : FSharpEntity option + /// Try to get the entity in which the active pattern is declared + member DeclaringEntity : FSharpEntity option and [] public FSharpType = diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs index 2d7ff27ad6f..83e2adf51bd 100644 --- a/tests/service/CSharpProjectAnalysis.fs +++ b/tests/service/CSharpProjectAnalysis.fs @@ -130,10 +130,10 @@ let _ = CSharpClass(0) |> Async.RunSynchronously |> Seq.map (fun su -> su.Symbol) |> Seq.find (function :? FSharpMemberOrFunctionOrValue as mfv -> mfv.IsConstructor | _ -> false) - match (ctor :?> FSharpMemberOrFunctionOrValue).EnclosingEntity with + match (ctor :?> FSharpMemberOrFunctionOrValue).DeclaringEntity with | Some e -> let members = e.MembersFunctionsAndValues Seq.exists (fun (mfv : FSharpMemberOrFunctionOrValue) -> mfv.IsConstructor) members |> should be True Seq.exists (fun (mfv : FSharpMemberOrFunctionOrValue) -> mfv.IsEffectivelySameAs ctor) members |> should be True - | None -> failwith "Expected Some for EnclosingEntity" + | None -> failwith "Expected Some for DeclaringEntity" diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index f0207609b26..b81c0d18a5e 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -212,8 +212,8 @@ let ``Symbols many tests`` () = fnVal.CurriedParameterGroups.[0].[1].Name.Value |> shouldEqual "y" fnVal.DeclarationLocation.StartLine |> shouldEqual 3 fnVal.DisplayName |> shouldEqual "foo" - fnVal.EnclosingEntity.Value.DisplayName |> shouldEqual "Test" - fnVal.EnclosingEntity.Value.DeclarationLocation.StartLine |> shouldEqual 1 + fnVal.DeclaringEntity.Value.DisplayName |> shouldEqual "Test" + fnVal.DeclaringEntity.Value.DeclarationLocation.StartLine |> shouldEqual 1 fnVal.GenericParameters.Count |> shouldEqual 0 fnVal.InlineAnnotation |> shouldEqual FSharpInlineAnnotation.OptionalInline fnVal.IsActivePattern |> shouldEqual false diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index bf955c5aa63..5eea4c1a6e1 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -32,7 +32,7 @@ module internal Utils = | BasicPatterns.Application(f,tyargs,args) -> quote low (printExpr 10 f + printTyargs tyargs + " " + printCurriedArgs args) | BasicPatterns.BaseValue(_) -> "base" | BasicPatterns.Call(Some obj,v,tyargs1,tyargs2,argsL) -> printObjOpt (Some obj) + v.CompiledName + printTyargs tyargs2 + printTupledArgs argsL - | BasicPatterns.Call(None,v,tyargs1,tyargs2,argsL) -> v.EnclosingEntity.Value.CompiledName + printTyargs tyargs1 + "." + v.CompiledName + printTyargs tyargs2 + " " + printTupledArgs argsL + | BasicPatterns.Call(None,v,tyargs1,tyargs2,argsL) -> v.DeclaringEntity.Value.CompiledName + printTyargs tyargs1 + "." + v.CompiledName + printTyargs tyargs2 + " " + printTupledArgs argsL | BasicPatterns.Coerce(ty1,e1) -> quote low (printExpr 10 e1 + " :> " + printTy ty1) | BasicPatterns.DefaultValue(ty1) -> "dflt" | BasicPatterns.FastIntegerForLoop _ -> "for-loop" @@ -45,7 +45,7 @@ module internal Utils = | BasicPatterns.LetRec(vse,b) -> "let rec ... in " + printExpr 0 b | BasicPatterns.NewArray(ty,es) -> "[|" + (es |> Seq.map (printExpr 0) |> String.concat "; ") + "|]" | BasicPatterns.NewDelegate(ty,es) -> "new-delegate" - | BasicPatterns.NewObject(v,tys,args) -> "new " + v.EnclosingEntity.Value.CompiledName + printTupledArgs args + | BasicPatterns.NewObject(v,tys,args) -> "new " + v.DeclaringEntity.Value.CompiledName + printTupledArgs args | BasicPatterns.NewRecord(v,args) -> let fields = v.TypeDefinition.FSharpFields "{" + ((fields, args) ||> Seq.map2 (fun f a -> f.Name + " = " + printExpr 0 a) |> String.concat "; ") + "}" diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index aa38fa58457..1de6ab54757 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -233,7 +233,7 @@ let ``Test multi project 1 xmldoc`` () = | _ -> failwith "odd symbol!" match ctorFromProjectMultiProject with - | :? FSharpMemberOrFunctionOrValue as c -> c.EnclosingEntity.Value.XmlDoc.Count |> shouldEqual 1 + | :? FSharpMemberOrFunctionOrValue as c -> c.DeclaringEntity.Value.XmlDoc.Count |> shouldEqual 1 | _ -> failwith "odd symbol!" match case1FromProjectMultiProject with @@ -808,7 +808,7 @@ let ``Test active patterns' XmlDocSig declared in referenced projects`` () = divisibleByGroup.IsTotal |> shouldEqual false divisibleByGroup.Names |> Seq.toList |> shouldEqual ["DivisibleBy"] divisibleByGroup.OverallType.Format(divisibleBySymbolUse.Value.DisplayContext) |> shouldEqual "int -> int -> unit option" - let divisibleByEntity = divisibleByGroup.EnclosingEntity.Value + let divisibleByEntity = divisibleByGroup.DeclaringEntity.Value divisibleByEntity.ToString() |> shouldEqual "Project3A" //------------------------------------------------------------------------------------ diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 93463d6a203..1992ce8ba1a 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -1550,7 +1550,7 @@ let ``Test complete active patterns' exact ranges from uses of symbols`` () = oddGroup.IsTotal |> shouldEqual true oddGroup.Names |> Seq.toList |> shouldEqual ["Even"; "Odd"] oddGroup.OverallType.Format(oddSymbolUse.Value.DisplayContext) |> shouldEqual "int -> Choice" - let oddEntity = oddGroup.EnclosingEntity.Value + let oddEntity = oddGroup.DeclaringEntity.Value oddEntity.ToString() |> shouldEqual "ActivePatterns" let evenSymbolUse = backgroundTypedParse1.GetSymbolUseAtLocation(10,9,"",["Even"]) |> Async.RunSynchronously @@ -1564,7 +1564,7 @@ let ``Test complete active patterns' exact ranges from uses of symbols`` () = evenGroup.IsTotal |> shouldEqual true evenGroup.Names |> Seq.toList |> shouldEqual ["Even"; "Odd"] evenGroup.OverallType.Format(evenSymbolUse.Value.DisplayContext) |> shouldEqual "int -> Choice" - let evenEntity = evenGroup.EnclosingEntity.Value + let evenEntity = evenGroup.DeclaringEntity.Value evenEntity.ToString() |> shouldEqual "ActivePatterns" let usesOfEvenSymbol = @@ -1608,7 +1608,7 @@ let ``Test partial active patterns' exact ranges from uses of symbols`` () = floatGroup.IsTotal |> shouldEqual false floatGroup.Names |> Seq.toList |> shouldEqual ["Float"] floatGroup.OverallType.Format(floatSymbolUse.Value.DisplayContext) |> shouldEqual "string -> float option" - let evenEntity = floatGroup.EnclosingEntity.Value + let evenEntity = floatGroup.DeclaringEntity.Value evenEntity.ToString() |> shouldEqual "ActivePatterns" let usesOfFloatSymbol = @@ -3251,16 +3251,16 @@ let ``Test Project23 property`` () = extensionProps |> Array.collect (fun f -> [| if f.HasGetterMethod then - yield (f.EnclosingEntity.Value.FullName, f.GetterMethod.CompiledName, f.GetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.GetterMethod.CompiledName, f.GetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.EnclosingEntity.Value.FullName, f.SetterMethod.CompiledName, f.SetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.SetterMethod.CompiledName, f.SetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) |]) |> Array.toList extensionPropsRelated |> shouldEqual - [("System.Int32", "Int32.get_Zero.Static", "Impl.Getter", + [("Impl.Getter", "System.Int32", "Int32.get_Zero.Static", "Impl.Getter", ["member"; "prop"; "extmem"]); - ("System.Int32", "Int32.get_Value", "Impl.Getter", + ("Impl.Getter", "System.Int32", "Int32.get_Value", "Impl.Getter", ["member"; "prop"; "extmem"])] allSymbolsUses @@ -3297,17 +3297,17 @@ let ``Test Project23 extension properties' getters/setters should refer to the c match x.Symbol with | :? FSharpMemberOrFunctionOrValue as f -> if f.HasGetterMethod then - yield (f.EnclosingEntity.Value.FullName, f.GetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.GetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.GetterMethod.LogicalEnclosingEntity.Value.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.EnclosingEntity.Value.FullName, f.SetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.SetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.SetterMethod.LogicalEnclosingEntity.Value.FullName, attribsOfSymbol f) | _ -> () |]) |> Array.toList |> shouldEqual - [ ("System.Int32", "Impl.Setter", ["member"; "prop"; "extmem"]); - ("System.Int32", "Impl.Setter", ["member"; "prop"; "extmem"]); - ("System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) - ("System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) ] + [ ("Impl.Setter", "Impl.Setter", "System.Int32", "Impl.Setter", ["member"; "prop"; "extmem"]); + ("Impl.Setter", "Impl.Setter", "System.Int32", "Impl.Setter", ["member"; "prop"; "extmem"]); + ("Impl.Getter", "Impl.Getter", "System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) + ("Impl.Getter", "Impl.Getter", "System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) ] // Misc - property symbols module internal Project24 = diff --git a/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerExtensions.fs index 14719b17d23..f05b13423dd 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerExtensions.fs @@ -111,11 +111,11 @@ type FSharpChecker with if func.IsProperty then let fullNames = [| if func.HasGetterMethod then - match func.GetterMethod.EnclosingEntity with + match func.GetterMethod.DeclaringEntity with | Some e -> yield e.TryGetFullName() | None -> () if func.HasSetterMethod then - match func.SetterMethod.EnclosingEntity with + match func.SetterMethod.DeclaringEntity with | Some e -> yield e.TryGetFullName() | None -> () |] @@ -124,7 +124,7 @@ type FSharpChecker with | [||] -> None | _ -> Some fullNames else - match func.EnclosingEntity with + match func.DeclaringEntity with // C# extension method | Some (Symbol.FSharpEntity Symbol.Class) -> let fullName = symbolUse.Symbol.FullName.Split '.' diff --git a/vsintegration/tests/unittests/CompletionProviderTests.fs b/vsintegration/tests/unittests/CompletionProviderTests.fs index 5e0212f62bd..718e34b5ba2 100644 --- a/vsintegration/tests/unittests/CompletionProviderTests.fs +++ b/vsintegration/tests/unittests/CompletionProviderTests.fs @@ -441,7 +441,7 @@ type List<'a> with List(). """ - let expected = ["Capacity"; "Count"; "ExtensionProp"; "Item"; "Add"; "AddRange"; "AsReadOnly"; "BinarySearch"; "Clear"; "Contains"; "ConvertAll"; "CopyTo"; "Exists" + let expected = ["Capacity"; "Count"; "Item"; "ExtensionProp"; "Add"; "AddRange"; "AsReadOnly"; "BinarySearch"; "Clear"; "Contains"; "ConvertAll"; "CopyTo"; "Exists" "Find"; "FindAll"; "FindIndex"; "FindLast"; "FindLastIndex"; "ForEach"; "GetEnumerator"; "GetRange"; "IndexOf"; "Insert"; "InsertRange"; "LastIndexOf" "Remove"; "RemoveAll"; "RemoveAt"; "RemoveRange"; "Reverse"; "Sort"; "ToArray"; "TrimExcess"; "TrueForAll"; "Equals"; "GetHashCode"; "GetType"; "ToString" "ExtensionMeth"] From 4695edd59288e3c83dfc0838b0f8040cdaef4393 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 15:21:33 +0000 Subject: [PATCH 13/17] fix build --- tests/service/ProjectAnalysisTests.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 1992ce8ba1a..aa0726047f9 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -3251,9 +3251,9 @@ let ``Test Project23 property`` () = extensionProps |> Array.collect (fun f -> [| if f.HasGetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.GetterMethod.CompiledName, f.GetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.GetterMethod.CompiledName, f.GetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.SetterMethod.CompiledName, f.SetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.SetterMethod.CompiledName, f.SetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) |]) |> Array.toList @@ -3297,9 +3297,9 @@ let ``Test Project23 extension properties' getters/setters should refer to the c match x.Symbol with | :? FSharpMemberOrFunctionOrValue as f -> if f.HasGetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.GetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.GetterMethod.LogicalEnclosingEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.GetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.GetterMethod.LogicalEnclosingEntity.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.SetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.Value.FullName, f.SetterMethod.LogicalEnclosingEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.SetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.SetterMethod.LogicalEnclosingEntity.FullName, attribsOfSymbol f) | _ -> () |]) |> Array.toList From e312b2bf5ad0ec55f58508e62785dfd77635c0a9 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 15:46:56 +0000 Subject: [PATCH 14/17] update test cases --- tests/service/ProjectAnalysisTests.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index aa0726047f9..392df321eae 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -3304,10 +3304,10 @@ let ``Test Project23 extension properties' getters/setters should refer to the c |]) |> Array.toList |> shouldEqual - [ ("Impl.Setter", "Impl.Setter", "System.Int32", "Impl.Setter", ["member"; "prop"; "extmem"]); - ("Impl.Setter", "Impl.Setter", "System.Int32", "Impl.Setter", ["member"; "prop"; "extmem"]); - ("Impl.Getter", "Impl.Getter", "System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) - ("Impl.Getter", "Impl.Getter", "System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) ] + [ ("Impl.Setter", "Impl.Setter", "System.Int32", "System.Int32", ["member"; "prop"; "extmem"]); + ("Impl.Setter", "Impl.Setter", "System.Int32", "System.Int32", ["member"; "prop"; "extmem"]); + ("Impl.Getter", "Impl.Getter", "System.Int32", "System.Int32", ["member"; "prop"; "extmem"]) + ("Impl.Getter", "Impl.Getter", "System.Int32", "System.Int32", ["member"; "prop"; "extmem"]) ] // Misc - property symbols module internal Project24 = From 5f07c87a493c79fc842199efa4fb1293e206a7dd Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 17:41:24 +0000 Subject: [PATCH 15/17] bump FCS version consistently --- fcs/README.md | 6 +++--- fcs/fcs.props | 2 +- fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec | 4 ++-- fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec | 4 ++-- fcs/nuget/FSharp.Compiler.Service.nuspec | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fcs/README.md b/fcs/README.md index 51aa24fbbef..ffe9546e802 100644 --- a/fcs/README.md +++ b/fcs/README.md @@ -60,9 +60,9 @@ which does things like: Yu can push the packages if you have permissions, either automatically using ``build Release`` or manually set APIKEY=... - .nuget\nuget.exe push Release\FSharp.Compiler.Service.16.0.3.nupkg %APIKEY% -Source https://nuget.org - .nuget\nuget.exe push Release\FSharp.Compiler.Service.MSBuild.v12.16.0.3.nupkg %APIKEY% -Source https://nuget.org - .nuget\nuget.exe push Release\FSharp.Compiler.Service.ProjectCracker.16.0.3.nupkg %APIKEY% -Source https://nuget.org + .nuget\nuget.exe push Release\FSharp.Compiler.Service.19.0.1.nupkg %APIKEY% -Source https://nuget.org + .nuget\nuget.exe push Release\FSharp.Compiler.Service.MSBuild.v12.19.0.1.nupkg %APIKEY% -Source https://nuget.org + .nuget\nuget.exe push Release\FSharp.Compiler.Service.ProjectCracker.19.0.1.nupkg %APIKEY% -Source https://nuget.org ### Use of Paket and FAKE diff --git a/fcs/fcs.props b/fcs/fcs.props index 88fb2f42ac1..3c813b2b341 100644 --- a/fcs/fcs.props +++ b/fcs/fcs.props @@ -3,7 +3,7 @@ - 16.0.3 + 19.0.1 $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools diff --git a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec index ae9c17a7819..6c20765492a 100644 --- a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec +++ b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec @@ -5,7 +5,7 @@ Adds legacy MSBuild 12.0 support to the F# compiler services package for resolving references such as #r "System, Version=4.1.0.0,..." en-US false - 16.0.3 + 19.0.1 Microsoft Corporation and F# community contributors https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE https://github.com/fsharp/FSharp.Compiler.Service @@ -14,7 +14,7 @@ F# compiler services for creating IDE tools, language extensions and for F# embedding. - + diff --git a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec index e45bb835728..9b2f6ea823a 100644 --- a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec +++ b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec @@ -5,7 +5,7 @@ The F# compiler services package contains a custom build of the F# compiler that exposes additional functionality for implementing F# language bindings, additional tools based on the compiler or refactoring tools. The package also includes F# interactive service that can be used for embedding F# scripting into your applications. en-US false - 16.0.3 + 19.0.1 Microsoft Corporation and F# community contributors https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE https://github.com/fsharp/FSharp.Compiler.Service @@ -14,7 +14,7 @@ F# compiler services for creating IDE tools, language extensions and for F# embedding. - + diff --git a/fcs/nuget/FSharp.Compiler.Service.nuspec b/fcs/nuget/FSharp.Compiler.Service.nuspec index ba4c2e7c3d5..37229cf4a39 100644 --- a/fcs/nuget/FSharp.Compiler.Service.nuspec +++ b/fcs/nuget/FSharp.Compiler.Service.nuspec @@ -5,7 +5,7 @@ The F# compiler services package contains a custom build of the F# compiler that exposes additional functionality for implementing F# language bindings, additional tools based on the compiler or refactoring tools. The package also includes F# interactive service that can be used for embedding F# scripting into your applications. en-US false - 16.0.3 + 19.0.1 Microsoft Corporation and F# community contributors https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE https://github.com/fsharp/FSharp.Compiler.Service From 76b38cf69668a69b46523373b0a538179f4299e7 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 18:34:49 +0000 Subject: [PATCH 16/17] use consistent names --- fcs/RELEASE_NOTES.md | 3 +- src/fsharp/AccessibilityLogic.fs | 6 +- src/fsharp/AttributeChecking.fs | 2 +- src/fsharp/AugmentWithHashCompare.fs | 4 +- src/fsharp/CompileOps.fs | 6 +- src/fsharp/ConstraintSolver.fs | 14 +- src/fsharp/IlxGen.fs | 12 +- src/fsharp/MethodCalls.fs | 14 +- src/fsharp/MethodOverrides.fs | 18 +-- src/fsharp/NameResolution.fs | 24 +-- src/fsharp/NicePrint.fs | 14 +- src/fsharp/Optimizer.fs | 6 +- src/fsharp/PatternMatchCompilation.fs | 8 +- src/fsharp/PostInferenceChecks.fs | 14 +- src/fsharp/QuotationTranslator.fs | 14 +- src/fsharp/TastOps.fs | 16 +- src/fsharp/TastPickle.fs | 8 +- src/fsharp/TypeChecker.fs | 36 ++--- src/fsharp/infos.fs | 142 +++++++++--------- .../service/ServiceInterfaceStubGenerator.fs | 2 +- src/fsharp/service/service.fs | 4 +- src/fsharp/symbols/Exprs.fs | 2 +- src/fsharp/symbols/SymbolHelpers.fs | 24 +-- src/fsharp/symbols/Symbols.fs | 22 +-- src/fsharp/symbols/Symbols.fsi | 2 +- src/fsharp/tast.fs | 48 +++--- tests/fsharp/core/members/absil.fsi | 2 +- tests/service/ProjectAnalysisTests.fs | 8 +- 28 files changed, 242 insertions(+), 233 deletions(-) diff --git a/fcs/RELEASE_NOTES.md b/fcs/RELEASE_NOTES.md index 677addced72..0084a0367d8 100644 --- a/fcs/RELEASE_NOTES.md +++ b/fcs/RELEASE_NOTES.md @@ -1,5 +1,6 @@ #### 19.0.1 - * Rename ``EnclosingEntity`` to ``DeclaringEntity``. In the case of extension properties, ``EnclosingEntity`` was incorrectly returning the logical enclosing entity (i.e. the type the property appears to extend), and in this case ``LogicalEnclosingEntity`` should be used instead. + * Rename ``LogicalEnclosingEntity`` to ``ApparentEnclosingEntity`` for consistency int he F# codebase terminology. + * Rename ``EnclosingEntity`` to ``DeclaringEntity``. In the case of extension properties, ``EnclosingEntity`` was incorrectly returning the logical enclosing entity (i.e. the type the property appears to extend), and in this case ``ApparentEnclosingEntity`` should be used instead. #### 18.0.1 * Integrate visualfsharp master diff --git a/src/fsharp/AccessibilityLogic.fs b/src/fsharp/AccessibilityLogic.fs index 5f72c2a7577..9bd6efd5b12 100644 --- a/src/fsharp/AccessibilityLogic.fs +++ b/src/fsharp/AccessibilityLogic.fs @@ -228,7 +228,7 @@ let IsILFieldInfoAccessible g amap m ad x = #if !NO_EXTENSIONTYPING | ProvidedField (amap, tpfi, m) -> let access = tpfi.PUntaint((fun fi -> ComputeILAccess fi.IsPublic fi.IsFamily fi.IsFamilyOrAssembly fi.IsFamilyAndAssembly), m) - IsProvidedMemberAccessible amap m ad x.LogicalEnclosingType access + IsProvidedMemberAccessible amap m ad x.ApparentEnclosingType access #endif let GetILAccessOfILEventInfo (ILEventInfo (tinfo,edef)) = @@ -314,7 +314,7 @@ let IsTypeAndMethInfoAccessible amap m adTyp ad = function #if !NO_EXTENSIONTYPING | ProvidedMeth(amap,tpmb,_,m) as etmi -> let access = tpmb.PUntaint((fun mi -> ComputeILAccess mi.IsPublic mi.IsFamily mi.IsFamilyOrAssembly mi.IsFamilyAndAssembly), m) - IsProvidedMemberAccessible amap m ad etmi.LogicalEnclosingType access + IsProvidedMemberAccessible amap m ad etmi.ApparentEnclosingType access #endif let IsMethInfoAccessible amap m ad minfo = IsTypeAndMethInfoAccessible amap m ad ad minfo @@ -334,7 +334,7 @@ let IsPropInfoAccessible g amap m ad = function | None -> tryGetILAccessForProvidedMethodBase(ppi.GetSetMethod()) | x -> x), m) defaultArg a ILMemberAccess.Public - IsProvidedMemberAccessible amap m ad pp.LogicalEnclosingType access + IsProvidedMemberAccessible amap m ad pp.ApparentEnclosingType access #endif | _ -> false diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index 2f7b8a2014d..50f0bb15189 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -436,7 +436,7 @@ let MethInfoIsUnseen g m typ minfo = #if !NO_EXTENSIONTYPING not (isObjTy g typ) && isAppTy g typ && - isObjTy g minfo.LogicalEnclosingType && + isObjTy g minfo.ApparentEnclosingType && let tcref = tcrefOfAppTy g typ match tcref.TypeReprInfo with | TProvidedTypeExtensionPoint info -> diff --git a/src/fsharp/AugmentWithHashCompare.fs b/src/fsharp/AugmentWithHashCompare.fs index 901edf9d6f5..7e914267bdf 100644 --- a/src/fsharp/AugmentWithHashCompare.fs +++ b/src/fsharp/AugmentWithHashCompare.fs @@ -858,7 +858,7 @@ let slotImplMethod (final,c,slotsig) : ValMemberInfo = IsOverrideOrExplicitImpl=true MemberKind=MemberKind.Member} IsImplemented=false - ApparentParent=c} + ApparentEnclosingEntity=c} let nonVirtualMethod c : ValMemberInfo = { ImplementedSlotSigs=[] @@ -868,7 +868,7 @@ let nonVirtualMethod c : ValMemberInfo = IsOverrideOrExplicitImpl=false MemberKind=MemberKind.Member} IsImplemented=false - ApparentParent=c} + ApparentEnclosingEntity=c} let unitArg = ValReprInfo.unitArgData let unaryArg = [ ValReprInfo.unnamedTopArg ] diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 294521a4e3c..d95a68a394c 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1249,7 +1249,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = | _ :: ts -> hasUnitTType_app ts | [] -> false - match minfoVirt.LogicalEnclosingType with + match minfoVirt.ApparentEnclosingType with | TType_app (t, types) when t.IsFSharpInterfaceTycon && hasUnitTType_app types -> // match abstract member with 'unit' passed as generic argument os.Append(OverrideDoesntOverride4E().Format sig1) |> ignore @@ -1347,8 +1347,8 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = | NonUniqueInferredAbstractSlot(_, denv, bindnm, bvirt1, bvirt2, _) -> os.Append(NonUniqueInferredAbstractSlot1E().Format bindnm) |> ignore - let ty1 = bvirt1.LogicalEnclosingType - let ty2 = bvirt2.LogicalEnclosingType + let ty1 = bvirt1.ApparentEnclosingType + let ty2 = bvirt2.ApparentEnclosingType // REVIEW: consider if we need to show _cxs (the type parameter constraints) let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2 os.Append(NonUniqueInferredAbstractSlot2E().Format) |> ignore diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index db032852db2..9758d9859b4 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -1035,7 +1035,7 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep | _, _, false, ("op_Addition" | "op_Subtraction" | "op_Modulus"), [argty1;argty2] when // Ignore any explicit +/- overloads from any basic integral types - (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.LogicalEnclosingType ) && + (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.ApparentEnclosingType ) && ( (IsNumericOrIntegralEnumType g argty1 || (nm = "op_Addition" && (isCharTy g argty1 || isStringTy g argty1))) && (permitWeakResolution || not (isTyparTy g argty2)) || (IsNumericOrIntegralEnumType g argty2 || (nm = "op_Addition" && (isCharTy g argty2 || isStringTy g argty2))) && (permitWeakResolution || not (isTyparTy g argty1)))) -> SolveTypEqualsTypKeepAbbrevs csenv ndeep m2 trace argty2 argty1 ++ (fun () -> @@ -1044,7 +1044,7 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep | _, _, false, ("op_LessThan" | "op_LessThanOrEqual" | "op_GreaterThan" | "op_GreaterThanOrEqual" | "op_Equality" | "op_Inequality" ), [argty1;argty2] when // Ignore any explicit overloads from any basic integral types - (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.LogicalEnclosingType ) && + (minfos |> List.forall (fun minfo -> isIntegerTy g minfo.ApparentEnclosingType ) && ( (IsRelationalType g argty1 && (permitWeakResolution || not (isTyparTy g argty2))) || (IsRelationalType g argty2 && (permitWeakResolution || not (isTyparTy g argty1))))) -> SolveTypEqualsTypKeepAbbrevs csenv ndeep m2 trace argty2 argty1 ++ (fun () -> @@ -1286,9 +1286,9 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep let isInstance = minfo.IsInstance if isInstance <> memFlags.IsInstance then if isInstance then - ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsNotStatic((NicePrint.minimalStringOfType denv minfo.LogicalEnclosingType), (DecompileOpName nm), nm), m, m2 )) + ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsNotStatic((NicePrint.minimalStringOfType denv minfo.ApparentEnclosingType), (DecompileOpName nm), nm), m, m2 )) else - ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsStatic((NicePrint.minimalStringOfType denv minfo.LogicalEnclosingType), (DecompileOpName nm), nm), m, m2 )) + ErrorD(ConstraintSolverError(FSComp.SR.csMethodFoundButIsStatic((NicePrint.minimalStringOfType denv minfo.ApparentEnclosingType), (DecompileOpName nm), nm), m, m2 )) else CheckMethInfoAttributes g m None minfo ++ (fun () -> ResultD (TTraitSolved (minfo, calledMeth.CalledTyArgs)))) @@ -1338,7 +1338,7 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst = | ILMeth(_, ilMeth, _) -> let mref = IL.mkRefToILMethod (ilMeth.DeclaringTyconRef.CompiledRepresentationForNamedType, ilMeth.RawMetadata) let iltref = ilMeth.ILExtensionMethodDeclaringTyconRef |> Option.map (fun tcref -> tcref.CompiledRepresentationForNamedType) - ILMethSln(ilMeth.LogicalEnclosingType, iltref, mref, minst) + ILMethSln(ilMeth.ApparentEnclosingType, iltref, mref, minst) | FSMeth(_, typ, vref, _) -> FSMethSln(typ, vref, minst) | MethInfo.DefaultStructCtor _ -> @@ -1348,7 +1348,7 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst = let g = amap.g let minst = [] // GENERIC TYPE PROVIDERS: for generics, we would have an minst here let allArgVars, allArgs = minfo.GetParamTypes(amap, m, minst) |> List.concat |> List.mapi (fun i ty -> mkLocal m ("arg"+string i) ty) |> List.unzip - let objArgVars, objArgs = (if minfo.IsInstance then [mkLocal m "this" minfo.LogicalEnclosingType] else []) |> List.unzip + let objArgVars, objArgs = (if minfo.IsInstance then [mkLocal m "this" minfo.ApparentEnclosingType] else []) |> List.unzip let callMethInfoOpt, callExpr, callExprTy = ProvidedMethodCalls.BuildInvokerExpressionForProvidedMethodCall css.TcVal (g, amap, mi, objArgs, NeverMutates, false, ValUseFlag.NormalValUse, allArgs, m) let closedExprSln = ClosedExprSln (mkLambdas m [] (objArgVars@allArgVars) (callExpr, callExprTy) ) // If the call is a simple call to an IL method with all the arguments in the natural order, then revert to use ILMethSln. @@ -2207,7 +2207,7 @@ and ResolveOverloading if isOpConversion then match calledMethGroup, reqdRetTyOpt with | h :: _, Some rty -> - Some (h.Method.LogicalEnclosingType, rty) + Some (h.Method.ApparentEnclosingType, rty) | _ -> None else None diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 3b91db9f700..4de82a8d7e6 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -767,7 +767,7 @@ let GetMethodSpecForMemberVal amap g (memberInfo:ValMemberInfo) (vref:ValRef) = let flatArgInfos = List.concat curriedArgInfos let isCtor = (memberInfo.MemberFlags.MemberKind = MemberKind.Constructor) let cctor = (memberInfo.MemberFlags.MemberKind = MemberKind.ClassConstructor) - let parentTcref = vref.TopValActualParent + let parentTcref = vref.TopValDeclaringEntity let parentTypars = parentTcref.TyparsNoRange let numParentTypars = parentTypars.Length if tps.Length < numParentTypars then error(InternalError("CodeGen check: type checking did not ensure that this method is sufficiently generic", m)) @@ -2603,7 +2603,7 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = let numEnclILTypeArgs = match vref.MemberInfo with | Some _ when not (vref.IsExtensionMember) -> - List.length(vref.MemberApparentParent.TyparsNoRange |> DropErasedTypars) + List.length(vref.MemberApparentEntity.TyparsNoRange |> DropErasedTypars) | _ -> 0 let (ilEnclArgTys,ilMethArgTys) = @@ -4699,7 +4699,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec,rhsExpr,_)) sta // Workaround for .NET and Visual Studio restriction w.r.t debugger type proxys // Mark internal constructors in internal classes as public. let access = - if access = ILMemberAccess.Assembly && vspec.IsConstructor && IsHiddenTycon eenv.sigToImplRemapInfo vspec.MemberApparentParent.Deref then + if access = ILMemberAccess.Assembly && vspec.IsConstructor && IsHiddenTycon eenv.sigToImplRemapInfo vspec.MemberApparentEntity.Deref then ILMemberAccess.Public else access @@ -4713,7 +4713,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec,rhsExpr,_)) sta CommitStartScope cgbuf startScopeMarkOpt // The initialization code for static 'let' and 'do' bindings gets compiled into the initialization .cctor for the whole file - | _ when vspec.IsClassConstructor && isNil vspec.TopValActualParent.TyparsNoRange -> + | _ when vspec.IsClassConstructor && isNil vspec.TopValDeclaringEntity.TyparsNoRange -> let tps,_,_,_,cctorBody,_ = IteratedAdjustArityOfLambda cenv.g cenv.amap vspec.ValReprInfo.Value rhsExpr let eenv = EnvForTypars tps eenv CommitStartScope cgbuf startScopeMarkOpt @@ -5087,7 +5087,7 @@ and ComputeFlagFixupsForMemberBinding cenv (v:Val,memberInfo:ValMemberInfo) = memberInfo.ImplementedSlotSigs |> List.map (fun slotsig -> let oty = slotsig.ImplementedType let otcref,_ = destAppTy cenv.g oty - let tcref = v.MemberApparentParent + let tcref = v.MemberApparentEntity let useMethodImpl = // REVIEW: it would be good to get rid of this special casing of Compare and GetHashCode during code generation @@ -5309,7 +5309,7 @@ and GenMethodForBinding let isAbstract = memberInfo.MemberFlags.IsDispatchSlot && - let tcref = v.MemberApparentParent + let tcref = v.MemberApparentEntity not tcref.Deref.IsFSharpDelegateTycon let mdef = diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index cffc3d43fc1..31e2c960f32 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -295,7 +295,7 @@ type CalledMeth<'T> [] let assignedNamedProps,unassignedNamedItems = - let returnedObjTy = if minfo.IsConstructor then minfo.LogicalEnclosingType else methodRetTy + let returnedObjTy = if minfo.IsConstructor then minfo.ApparentEnclosingType else methodRetTy unassignedNamedItems |> List.splitChoose (fun (CallerNamedArg(id,e) as arg) -> let nm = id.idText let pinfos = GetIntrinsicPropInfoSetsOfType infoReader (Some(nm),ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides id.idRange returnedObjTy @@ -509,7 +509,7 @@ let IsBaseCall objArgs = let ComputeConstrainedCallInfo g amap m (objArgs,minfo:MethInfo) = match objArgs with | [objArgExpr] when not minfo.IsExtensionMember -> - let methObjTy = minfo.LogicalEnclosingType + let methObjTy = minfo.ApparentEnclosingType let objArgTy = tyOfExpr g objArgExpr if TypeDefinitelySubsumesTypeNoCoercion 0 g amap m methObjTy objArgTy // Constrained calls to class types can only ever be needed for the three class types that @@ -546,8 +546,8 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f = // Extension members and calls to class constraints may need a coercion for their object argument let objArgExpr' = if Option.isNone ccallInfo && // minfo.IsExtensionMember && minfo.IsStruct && - not (TypeDefinitelySubsumesTypeNoCoercion 0 g amap m minfo.LogicalEnclosingType objArgTy) then - mkCoerceExpr(objArgExpr',minfo.LogicalEnclosingType,m,objArgTy) + not (TypeDefinitelySubsumesTypeNoCoercion 0 g amap m minfo.ApparentEnclosingType objArgTy) then + mkCoerceExpr(objArgExpr',minfo.ApparentEnclosingType,m,objArgTy) else objArgExpr' @@ -569,7 +569,7 @@ let TakeObjAddrForMethodCall g amap (minfo:MethInfo) isMutable m objArgs f = /// Build an expression node that is a call to a .NET method. let BuildILMethInfoCall g amap m isProp (minfo:ILMethInfo) valUseFlags minst direct args = - let valu = isStructTy g minfo.LogicalEnclosingType + let valu = isStructTy g minfo.ApparentEnclosingType let ctor = minfo.IsConstructor if minfo.IsClassConstructor then error (InternalError (minfo.ILName+": cannot call a class constructor",m)) @@ -578,7 +578,7 @@ let BuildILMethInfoCall g amap m isProp (minfo:ILMethInfo) valUseFlags minst dir let isProtected = minfo.IsProtectedAccessibility let ilMethRef = minfo.ILMethodRef let newobj = ctor && (match valUseFlags with NormalValUse -> true | _ -> false) - let exprTy = if ctor then minfo.LogicalEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) + let exprTy = if ctor then minfo.ApparentEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) let retTy = (if not ctor && (ilMethRef.ReturnType = ILType.Void) then [] else [exprTy]) let isDllImport = minfo.IsDllImport g Expr.Op(TOp.ILCall(useCallvirt,isProtected,valu,newobj,valUseFlags,isProp,isDllImport,ilMethRef,minfo.DeclaringTypeInst,minst,retTy),[],args,m), @@ -717,7 +717,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA // TODO: there is a fair bit of duplication here with mk_il_minfo_call. We should be able to merge these /// Build an expression node that is a call to a extension method in a generated assembly - let enclTy = minfo.LogicalEnclosingType + let enclTy = minfo.ApparentEnclosingType // prohibit calls to methods that are declared in specific array types (Get,Set,Address) // these calls are provided by the runtime and should not be called from the user code if isArrayTy g enclTy then diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 1859b693545..2b550f89482 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -83,7 +83,7 @@ module DispatchSlotChecking = let (CompiledSig (argTys,retTy,fmtps,ttpinst)) = CompiledSigOfMeth g amap m minfo let isFakeEventProperty = minfo.IsFSharpEventPropertyMethod - Override(parentType,tcrefOfAppTy g minfo.LogicalEnclosingAppType,mkSynId m nm, (fmtps,ttpinst),argTys,retTy,isFakeEventProperty,false) + Override(parentType, minfo.ApparentEnclosingTyconRef, mkSynId m nm, (fmtps,ttpinst),argTys,retTy,isFakeEventProperty,false) /// Get the override info for a value being used to implement a dispatch slot. let GetTypeMemberOverrideInfo g reqdTy (overrideBy:ValRef) = @@ -121,7 +121,7 @@ module DispatchSlotChecking = //CanImplementAnySlot <<----- Change to this to enable implicit interface implementation let isFakeEventProperty = overrideBy.IsFSharpEventProperty(g) - Override(implKind,overrideBy.MemberApparentParent, mkSynId overrideBy.Range nm, (memberMethodTypars,memberToParentInst),argTys,retTy,isFakeEventProperty, overrideBy.IsCompilerGenerated) + Override(implKind,overrideBy.MemberApparentEntity, mkSynId overrideBy.Range nm, (memberMethodTypars,memberToParentInst),argTys,retTy,isFakeEventProperty, overrideBy.IsCompilerGenerated) /// Get the override information for an object expression method being used to implement dispatch slots let GetObjectExprOverrideInfo g amap (implty, id:Ident, memberFlags, ty, arityInfo, bindingAttribs, rhsExpr) = @@ -160,9 +160,9 @@ module DispatchSlotChecking = (match overrideBy.CanImplement with | CanImplementNoSlots -> false | CanImplementAnySlot -> true - | CanImplementAnyClassHierarchySlot -> not (isInterfaceTy g dispatchSlot.LogicalEnclosingType) - //| CanImplementSpecificInterfaceSlot parentTy -> isInterfaceTy g dispatchSlot.LogicalEnclosingType && typeEquiv g parentTy dispatchSlot.LogicalEnclosingType - | CanImplementAnyInterfaceSlot -> isInterfaceTy g dispatchSlot.LogicalEnclosingType) + | CanImplementAnyClassHierarchySlot -> not (isInterfaceTy g dispatchSlot.ApparentEnclosingType) + //| CanImplementSpecificInterfaceSlot parentTy -> isInterfaceTy g dispatchSlot.ApparentEnclosingType && typeEquiv g parentTy dispatchSlot.ApparentEnclosingType + | CanImplementAnyInterfaceSlot -> isInterfaceTy g dispatchSlot.ApparentEnclosingType) /// Check if the kinds of type parameters match between a dispatch slot and an override. let IsTyparKindMatch g amap m (dispatchSlot:MethInfo) (Override(_,_,_,(mtps,_),_,_,_,_)) = @@ -363,11 +363,11 @@ module DispatchSlotChecking = | [dispatchSlot] -> - if dispatchSlot.IsFinal && (isObjExpr || not (typeEquiv g reqdTy dispatchSlot.LogicalEnclosingType)) then + if dispatchSlot.IsFinal && (isObjExpr || not (typeEquiv g reqdTy dispatchSlot.ApparentEnclosingType)) then errorR(Error(FSComp.SR.typrelMethodIsSealed(NicePrint.stringOfMethInfo amap m denv dispatchSlot),m)) | dispatchSlots -> match dispatchSlots |> List.filter (fun dispatchSlot -> - isInterfaceTy g dispatchSlot.LogicalEnclosingType || + isInterfaceTy g dispatchSlot.ApparentEnclosingType || not (DispatchSlotIsAlreadyImplemented g amap m availPriorOverridesKeyed dispatchSlot)) with | h1 :: h2 :: _ -> errorR(Error(FSComp.SR.typrelOverrideImplementsMoreThenOneSlot((FormatOverride denv overrideBy), (NicePrint.stringOfMethInfo amap m denv h1), (NicePrint.stringOfMethInfo amap m denv h2)),m)) @@ -375,7 +375,7 @@ module DispatchSlotChecking = // dispatch slots are ordered from the derived classes to base // so we can check the topmost dispatch slot if it is final match dispatchSlots with - | meth::_ when meth.IsFinal -> errorR(Error(FSComp.SR.tcCannotOverrideSealedMethod((sprintf "%s::%s" (meth.LogicalEnclosingType.ToString()) (meth.LogicalName))), m)) + | meth::_ when meth.IsFinal -> errorR(Error(FSComp.SR.tcCannotOverrideSealedMethod((sprintf "%s::%s" (meth.ApparentEnclosingType.ToString()) (meth.LogicalName))), m)) | _ -> () @@ -506,7 +506,7 @@ module DispatchSlotChecking = // We also collect up the properties. This is used for abstract slot inference when overriding properties let isRelevantRequiredProperty (x:PropInfo) = (x.IsVirtualProperty && not (isInterfaceTy g reqdTy)) || - isImpliedInterfaceType x.LogicalEnclosingType + isImpliedInterfaceType x.ApparentEnclosingType let reqdProperties = GetIntrinsicPropInfosOfType infoReader (None,AccessibleFromSomewhere,AllowMultiIntfInstantiations.Yes) IgnoreOverrides reqdTyRange reqdTy diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 54ad14b4191..dcbc1f074ec 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -517,7 +517,7 @@ let AddValRefsToItems (bulkAddMode: BulkAdd) (eUnqualifiedItems: LayeredMap<_,_> /// Add an F# value to the table of available extension members, if necessary, as an FSharp-style extension member let AddValRefToExtensionMembers pri (eIndexedExtensionMembers: TyconRefMultiMap<_>) (vref:ValRef) = if vref.IsMember && vref.IsExtensionMember then - eIndexedExtensionMembers.Add (vref.MemberApparentParent, FSExtMem (vref,pri)) + eIndexedExtensionMembers.Add (vref.MemberApparentEntity, FSExtMem (vref,pri)) else eIndexedExtensionMembers @@ -1300,7 +1300,7 @@ let (|EntityUse|_|) (item: Item) = | Item.DelegateCtor(AbbrevOrAppTy tcref) | Item.FakeInterfaceCtor(AbbrevOrAppTy tcref) -> Some tcref | Item.CtorGroup(_, ctor::_) -> - match ctor.LogicalEnclosingType with + match ctor.ApparentEnclosingType with | AbbrevOrAppTy tcref -> Some tcref | _ -> None | _ -> None @@ -1610,7 +1610,7 @@ let CheckAllTyparsInferrable amap m item = | Item.Property(_,pinfos) -> pinfos |> List.forall (fun pinfo -> pinfo.IsExtensionMember || - let freeInDeclaringType = freeInType CollectTyparsNoCaching pinfo.LogicalEnclosingType + let freeInDeclaringType = freeInType CollectTyparsNoCaching pinfo.ApparentEnclosingType let freeInArgsAndRetType = accFreeInTypes CollectTyparsNoCaching (pinfo.GetParamTypes(amap,m)) (freeInType CollectTyparsNoCaching (pinfo.GetPropertyType(amap,m))) @@ -1621,7 +1621,7 @@ let CheckAllTyparsInferrable amap m item = minfos |> List.forall (fun minfo -> minfo.IsExtensionMember || let fminst = minfo.FormalMethodInst - let freeInDeclaringType = freeInType CollectTyparsNoCaching minfo.LogicalEnclosingType + let freeInDeclaringType = freeInType CollectTyparsNoCaching minfo.ApparentEnclosingType let freeInArgsAndRetType = List.foldBack (accFreeInTypes CollectTyparsNoCaching) (minfo.GetParamTypes(amap, m, fminst)) (accFreeInTypes CollectTyparsNoCaching (minfo.GetObjArgTypes(amap, m, fminst)) @@ -2021,8 +2021,8 @@ let DecodeFSharpEvent (pinfos:PropInfo list) ad g (ncenv:NameResolver) m = match pinfos with | [pinfo] when pinfo.IsFSharpEventProperty -> let nm = CoreDisplayName(pinfo) - let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+nm),ad) g ncenv.amap m pinfo.LogicalEnclosingType - let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+nm),ad) g ncenv.amap m pinfo.LogicalEnclosingType + let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+nm),ad) g ncenv.amap m pinfo.ApparentEnclosingType + let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+nm),ad) g ncenv.amap m pinfo.ApparentEnclosingType match minfos1,minfos2 with | [FSMeth(_,_,addValRef,_)],[FSMeth(_,_,removeValRef,_)] -> // FOUND PROPERTY-AS-EVENT AND CORRESPONDING ADD/REMOVE METHODS @@ -3534,10 +3534,10 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso not minfo.IsExtensionMember && match minfo.LogicalName with | "GetType" -> false - | "GetHashCode" -> isObjTy g minfo.LogicalEnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) + | "GetHashCode" -> isObjTy g minfo.ApparentEnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) | "ToString" -> false | "Equals" -> - if not (isObjTy g minfo.LogicalEnclosingType) then + if not (isObjTy g minfo.ApparentEnclosingType) then // declaring type is not System.Object - show it false elif minfo.IsInstance then @@ -3548,7 +3548,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso true | _ -> // filter out self methods of obj type - isObjTy g minfo.LogicalEnclosingType + isObjTy g minfo.ApparentEnclosingType let result = not isUnseenDueToBasicObjRules && @@ -4168,10 +4168,10 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ not minfo.IsExtensionMember && match minfo.LogicalName with | "GetType" -> false - | "GetHashCode" -> isObjTy g minfo.LogicalEnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) + | "GetHashCode" -> isObjTy g minfo.ApparentEnclosingType && not (AugmentWithHashCompare.TypeDefinitelyHasEquality g typ) | "ToString" -> false | "Equals" -> - if not (isObjTy g minfo.LogicalEnclosingType) then + if not (isObjTy g minfo.ApparentEnclosingType) then // declaring type is not System.Object - show it false elif minfo.IsInstance then @@ -4182,7 +4182,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ true | _ -> // filter out self methods of obj type - isObjTy g minfo.LogicalEnclosingType + isObjTy g minfo.ApparentEnclosingType let result = not isUnseenDueToBasicObjRules && not minfo.IsInstance = statics && diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index ac5afb3973f..85415c05901 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -1111,7 +1111,7 @@ module private PrintTastMemberOrVals = DemangleOperatorNameAsLayout (tagFunction >> mkNav v.DefinitionRange) name let nameL = if denv.showMemberContainers then - layoutTyconRef denv v.MemberApparentParent ^^ SepL.dot ^^ nameL + layoutTyconRef denv v.MemberApparentEntity ^^ SepL.dot ^^ nameL else nameL let nameL = if denv.showTyparBinding then layoutTyparDecls denv nameL true niceMethodTypars else nameL @@ -1296,14 +1296,14 @@ module InfoMemberPrinting = // Container(argName1:argType1, ..., argNameN:argTypeN) : retType // Container.Method(argName1:argType1, ..., argNameN:argTypeN) : retType let private layoutMethInfoCSharpStyle amap m denv (minfo:MethInfo) minst = - let retTy = if minfo.IsConstructor then minfo.LogicalEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) + let retTy = if minfo.IsConstructor then minfo.ApparentEnclosingType else minfo.GetFSharpReturnTy(amap, m, minst) let layout = if minfo.IsExtensionMember then LeftL.leftParen ^^ wordL (tagKeyword (FSComp.SR.typeInfoExtension())) ^^ RightL.rightParen else emptyL let layout = layout ^^ - let tcref = tcrefOfAppTy amap.g minfo.LogicalEnclosingAppType + let tcref = minfo.ApparentEnclosingTyconRef PrintTypes.layoutTyconRef denv tcref let layout = layout ^^ @@ -1354,9 +1354,9 @@ module InfoMemberPrinting = // ApparentContainer.Method(argName1:argType1, ..., argNameN:argTypeN) : retType let prettyLayoutOfMethInfoFreeStyle (amap: Import.ImportMap) m denv typarInst methInfo = match methInfo with - | DefaultStructCtor(g,_typ) -> + | DefaultStructCtor _ -> let prettyTyparInst, _ = PrettyTypes.PrettifyInst amap.g typarInst - prettyTyparInst, PrintTypes.layoutTyconRef denv (tcrefOfAppTy g methInfo.LogicalEnclosingAppType) ^^ wordL (tagPunctuation "()") + prettyTyparInst, PrintTypes.layoutTyconRef denv methInfo.ApparentEnclosingTyconRef ^^ wordL (tagPunctuation "()") | FSMeth(_,_,vref,_) -> let prettyTyparInst, resL = PrintTastMemberOrVals.prettyLayoutOfValOrMember { denv with showMemberContainers=true } typarInst vref.Deref prettyTyparInst, resL @@ -1380,7 +1380,7 @@ module InfoMemberPrinting = | Some vref -> tagProperty >> mkNav vref.DefinitionRange let nameL = DemangleOperatorNameAsLayout tagProp pinfo.PropertyName wordL (tagText (FSComp.SR.typeInfoProperty())) ^^ - layoutTyconRef denv (tcrefOfAppTy g pinfo.LogicalEnclosingAppType) ^^ + layoutTyconRef denv pinfo.ApparentEnclosingTyconRef ^^ SepL.dot ^^ nameL ^^ RightL.colon ^^ @@ -1401,7 +1401,7 @@ module private TastDefinitionPrinting = open PrintTypes let layoutExtensionMember denv (v:Val) = - let tycon = v.MemberApparentParent.Deref + let tycon = v.MemberApparentEntity.Deref let nameL = tagMethod tycon.DisplayName |> mkNav v.DefinitionRange |> wordL let nameL = layoutAccessibility denv tycon.Accessibility nameL // "type-accessibility" let tps = diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 77a1be55adf..88784272d39 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -1513,7 +1513,7 @@ let (|AnyRefTupleTrans|) e = /// Look for any QueryBuilder.* operation and transform let (|AnyQueryBuilderOpTrans|_|) g = function | Expr.App((Expr.Val (vref, _, _) as v), vty, tyargs, [builder; AnyRefTupleTrans( (src::rest), replaceArgs) ], m) when - (match vref.ApparentParent with Parent tcref -> tyconRefEq g tcref g.query_builder_tcref | ParentNone -> false) -> + (match vref.ApparentEnclosingEntity with Parent tcref -> tyconRefEq g tcref g.query_builder_tcref | ParentNone -> false) -> Some (src, (fun newSource -> Expr.App(v, vty, tyargs, [builder; replaceArgs(newSource::rest)], m))) | _ -> None @@ -2523,7 +2523,7 @@ and TryInlineApplication cenv env finfo (tyargs: TType list, args: Expr list, m) else match finfo.Info with | ValValue(vref, _) -> - match vref.ApparentParent with + match vref.ApparentEnclosingEntity with | Parent(tcr) when (tyconRefEq cenv.g cenv.g.lazy_tcr_canon tcr) -> match tcr.CompiledRepresentation with | CompiledTypeRepr.ILAsmNamed(iltr, _, _) -> iltr.Scope.AssemblyRef.Name = "FSharp.Core" @@ -2971,7 +2971,7 @@ and OptimizeBinding cenv isRec env (TBind(vref, expr, spBind)) = (vref.InlineInfo = ValInline.Never) || // MarshalByRef methods may not be inlined - (match vref.ActualParent with + (match vref.DeclaringEntity with | Parent tcref -> match cenv.g.system_MarshalByRefObject_tcref with | None -> false diff --git a/src/fsharp/PatternMatchCompilation.fs b/src/fsharp/PatternMatchCompilation.fs index 7c42d19b7ce..a40292a3565 100644 --- a/src/fsharp/PatternMatchCompilation.fs +++ b/src/fsharp/PatternMatchCompilation.fs @@ -873,7 +873,7 @@ let CompilePatternBasic let v,vexp = mkCompGenLocal m "typeTestResult" tgty if topv.IsMemberOrModuleBinding then - AdjustValToTopVal v topv.ActualParent ValReprInfo.emptyValData + AdjustValToTopVal v topv.DeclaringEntity ValReprInfo.emptyValData let argexp = GetSubExprOfInput subexpr let appexp = mkIsInst tgty argexp matchm Some(vexp),Some(mkInvisibleBind v appexp) @@ -888,7 +888,7 @@ let CompilePatternBasic | None -> Some addrexp, None | Some (v,e) -> if topv.IsMemberOrModuleBinding then - AdjustValToTopVal v topv.ActualParent ValReprInfo.emptyValData + AdjustValToTopVal v topv.DeclaringEntity ValReprInfo.emptyValData Some addrexp, Some (mkInvisibleBind v e) @@ -904,7 +904,7 @@ let CompilePatternBasic let ucaseTy = (mkProvenUnionCaseTy g.cons_ucref tinst) let v,vexp = mkCompGenLocal m "unionTestResult" ucaseTy if topv.IsMemberOrModuleBinding then - AdjustValToTopVal v topv.ActualParent ValReprInfo.emptyValData + AdjustValToTopVal v topv.DeclaringEntity ValReprInfo.emptyValData let argexp = GetSubExprOfInput subexpr let appexp = mkIsInst ucaseTy argexp matchm Some vexp,Some (mkInvisibleBind v appexp) @@ -917,7 +917,7 @@ let CompilePatternBasic let rty = apinfo.ResultType g m resTys let v,vexp = mkCompGenLocal m ("activePatternResult"^string (newUnique())) rty if topv.IsMemberOrModuleBinding then - AdjustValToTopVal v topv.ActualParent ValReprInfo.emptyValData + AdjustValToTopVal v topv.DeclaringEntity ValReprInfo.emptyValData let argexp = GetSubExprOfInput subexpr let appexp = mkApps g ((pexp,tyOfExpr g pexp), [], [argexp],m) diff --git a/src/fsharp/PostInferenceChecks.fs b/src/fsharp/PostInferenceChecks.fs index d0d2ef8da25..e999a80912a 100644 --- a/src/fsharp/PostInferenceChecks.fs +++ b/src/fsharp/PostInferenceChecks.fs @@ -540,7 +540,7 @@ and CheckExpr (cenv:cenv) (env:env) expr (context:ByrefContext) = errorR(Error(FSComp.SR.chkLimitationsOfBaseKeyword(), m)) if (match vFlags with NormalValUse -> true | _ -> false) && v.IsConstructor && - (match v.ActualParent with Parent tcref -> isAbstractTycon tcref.Deref | _ -> false) then + (match v.DeclaringEntity with Parent tcref -> isAbstractTycon tcref.Deref | _ -> false) then errorR(Error(FSComp.SR.tcAbstractTypeCannotBeInstantiated(),m)) if isByrefTy cenv.g v.Type && @@ -1157,7 +1157,7 @@ and CheckBinding cenv env alwaysCheckNoReraise (TBind(v,bindRhs,_) as bind) = // Check accessibility if (v.IsMemberOrModuleBinding || v.IsMember) && not v.IsIncrClassGeneratedMember then - let access = AdjustAccess (IsHiddenVal env.sigToImplRemapInfo v) (fun () -> v.TopValActualParent.CompilationPath) v.Accessibility + let access = AdjustAccess (IsHiddenVal env.sigToImplRemapInfo v) (fun () -> v.TopValDeclaringEntity.CompilationPath) v.Accessibility CheckTypeForAccess cenv env (fun () -> NicePrint.stringOfQualifiedValOrMember cenv.denv v) access v.Range v.Type let env = if v.IsConstructor && not v.IsIncrClassConstructor then { env with limited=true } else env @@ -1183,9 +1183,9 @@ and CheckBinding cenv env alwaysCheckNoReraise (TBind(v,bindRhs,_) as bind) = // Also check the enclosing type for members - for historical reasons, in the TAST member values // are stored in the entity that encloses the type, hence we will not have noticed the ReflectedDefinition // on the enclosing type at this point. - HasFSharpAttribute cenv.g cenv.g.attrib_ReflectedDefinitionAttribute v.TopValActualParent.Attribs) then + HasFSharpAttribute cenv.g cenv.g.attrib_ReflectedDefinitionAttribute v.TopValDeclaringEntity.Attribs) then - if v.IsInstanceMember && v.MemberApparentParent.IsStructOrEnumTycon then + if v.IsInstanceMember && v.MemberApparentEntity.IsStructOrEnumTycon then errorR(Error(FSComp.SR.chkNoReflectedDefinitionOnStructMember(),v.Range)) cenv.usesQuotations <- true @@ -1264,10 +1264,10 @@ let CheckModuleBinding cenv env (TBind(v,e,_) as bind) = // Skip explicit implementations of interface methods if ValIsExplicitImpl cenv.g v then () else - match v.ActualParent with + match v.DeclaringEntity with | ParentNone -> () // this case can happen after error recovery from earlier error | Parent _ -> - let tcref = v.TopValActualParent + let tcref = v.TopValDeclaringEntity let hasDefaultAugmentation = tcref.IsUnionTycon && match TryFindFSharpAttribute cenv.g cenv.g.attrib_DefaultAugmentationAttribute tcref.Attribs with @@ -1336,7 +1336,7 @@ let CheckModuleBinding cenv env (TBind(v,e,_) as bind) = if v2.IsExtensionMember && not (valEq v v2) && v.CompiledName = v2.CompiledName then let minfo1 = FSMeth(cenv.g, generalizedTyconRef tcref, mkLocalValRef v, Some 0UL) let minfo2 = FSMeth(cenv.g, generalizedTyconRef tcref, mkLocalValRef v2, Some 0UL) - if tyconRefEq cenv.g v.MemberApparentParent v2.MemberApparentParent && + if tyconRefEq cenv.g v.MemberApparentEntity v2.MemberApparentEntity && MethInfosEquivByNameAndSig EraseAll true cenv.g cenv.amap v.Range minfo1 minfo2 then errorR(Duplicate(kind,v.DisplayName,v.Range))) diff --git a/src/fsharp/QuotationTranslator.fs b/src/fsharp/QuotationTranslator.fs index 81f50d17de8..7216a700158 100644 --- a/src/fsharp/QuotationTranslator.fs +++ b/src/fsharp/QuotationTranslator.fs @@ -130,7 +130,7 @@ let (|ModuleValueOrMemberUse|_|) g expr = Some(vref,vFlags,f,fty,tyargs,actualArgs @ args) | Expr.App(f,_fty,[],actualArgs,_) -> loop f (actualArgs @ args) - | (Expr.Val(vref,vFlags,_m) as f) when (match vref.ActualParent with ParentNone -> false | _ -> true) -> + | (Expr.Val(vref,vFlags,_m) as f) when (match vref.DeclaringEntity with ParentNone -> false | _ -> true) -> let fty = tyOfExpr g f Some(vref,vFlags,f,fty,[],args) | _ -> @@ -301,7 +301,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. // We only count one argument block for these. let callArgs = (objArgs::untupledCurriedArgs) |> List.concat - let parentTyconR = ConvTyconRef cenv vref.TopValActualParent m + let parentTyconR = ConvTyconRef cenv vref.TopValDeclaringEntity m let isNewObj = isNewObj || valUseFlags || isSelfInit // The signature types are w.r.t. to the formal context let envinner = BindFormalTypars env tps @@ -528,7 +528,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | TOp.LValueOp(LSet,vref),[],[e] -> // Sets of module values become property sets - match vref.ActualParent with + match vref.DeclaringEntity with | Parent tcref when IsCompiledAsStaticProperty cenv.g vref.Deref -> let parentTyconR = ConvTyconRef cenv tcref m let propName = vref.CompiledName @@ -716,7 +716,7 @@ and ConvModuleValueApp cenv env m (vref:ValRef) tyargs (args: Expr list list) = EmitDebugInfoIfNecessary cenv env m (ConvModuleValueAppCore cenv env m vref tyargs args) and ConvModuleValueAppCore cenv env m (vref:ValRef) tyargs (args: Expr list list) = - match vref.ActualParent with + match vref.DeclaringEntity with | ParentNone -> failwith "ConvModuleValueApp" | Parent(tcref) -> let isProperty = IsCompiledAsStaticProperty cenv.g vref.Deref @@ -747,7 +747,7 @@ and private ConvValRefCore holeOk cenv env m (vref:ValRef) tyargs = QP.mkThisVar(ConvType cenv env m v.Type) else let vty = v.Type - match v.ActualParent with + match v.DeclaringEntity with | ParentNone -> // References to local values are embedded by value if not holeOk then wfail(Error(FSComp.SR.crefNoSetOfHole(),m)) @@ -1030,14 +1030,14 @@ let ConvExprPublic cenv env e = let ConvMethodBase cenv env (methName, v:Val) = let m = v.Range - let parentTyconR = ConvTyconRef cenv v.TopValActualParent m + let parentTyconR = ConvTyconRef cenv v.TopValDeclaringEntity m match v.MemberInfo with | Some vspr when not v.IsExtensionMember -> let vref = mkLocalValRef v let tps,argInfos,retTy,_ = GetTypeOfMemberInMemberForm cenv.g vref - let numEnclTypeArgs = vref.MemberApparentParent.TyparsNoRange.Length + let numEnclTypeArgs = vref.MemberApparentEntity.TyparsNoRange.Length let argTys = argInfos |> List.concat |> List.map fst let isNewObj = (vspr.MemberFlags.MemberKind = MemberKind.Constructor) diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 7ff96982e3e..8b0b40299f8 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -2161,7 +2161,7 @@ let PartitionValTyparsForApparentEnclosingType g (v:Val) = | None -> error(InternalError("PartitionValTypars: not a top value", v.Range)) | Some arities -> let fullTypars, _ = destTopForallTy g arities v.Type - let parent = v.MemberApparentParent + let parent = v.MemberApparentEntity let parentTypars = parent.TyparsNoRange let nparentTypars = parentTypars.Length if nparentTypars <= fullTypars.Length then @@ -4636,7 +4636,7 @@ and remapValData g tmenv (d: ValData) = let ty' = ty |> remapPossibleForallTy g tmenv { d with val_type = ty'; - val_actual_parent = d.val_actual_parent |> remapParentRef tmenv; + val_declaring_entity = d.val_declaring_entity |> remapParentRef tmenv; val_repr_info = d.val_repr_info |> Option.map (remapValReprInfo g tmenv); val_member_info = d.val_member_info |> Option.map (remapMemberInfo g d.val_range topValInfo ty ty' tmenv); val_attribs = d.val_attribs |> remapAttribs g tmenv } @@ -4954,7 +4954,7 @@ and remapMemberInfo g m topValInfo ty ty' tmenv x = let renaming, _ = mkTyparToTyparRenaming tpsOrig tps let tmenv = { tmenv with tpinst = tmenv.tpinst @ renaming } { x with - ApparentParent = x.ApparentParent |> remapTyconRef tmenv.tyconRefRemap ; + ApparentEnclosingEntity = x.ApparentEnclosingEntity |> remapTyconRef tmenv.tyconRefRemap ; ImplementedSlotSigs = x.ImplementedSlotSigs |> List.map (remapSlotSig (remapAttribs g tmenv) tmenv); } @@ -6936,7 +6936,7 @@ let etaExpandTypeLambda g m tps (tm, ty) = let AdjustValToTopVal (tmp:Val) parent valData = tmp.SetValReprInfo (Some valData); - tmp.val_actual_parent <- parent; + tmp.val_declaring_entity <- parent; tmp.SetIsMemberOrModuleBinding() /// For match with only one non-failing target T0, the other targets, T1... failing (say, raise exception). @@ -7105,7 +7105,7 @@ let XmlDocSigOfVal g path (v:Val) = | MemberKind.PropertyGetSet | MemberKind.PropertySet | MemberKind.PropertyGet -> "P:", v.PropertyName - let path = if v.HasTopValActualParent then prependPath path v.TopValActualParent.CompiledName else path + let path = if v.HasDeclaringEntity then prependPath path v.TopValDeclaringEntity.CompiledName else path let parentTypars, methTypars = match PartitionValTypars g v with | Some(_, memberParentTypars, memberMethodTypars, _, _) -> memberParentTypars, memberMethodTypars @@ -7367,10 +7367,10 @@ let isComInteropTy g ty = let ValSpecIsCompiledAsInstance g (v:Val) = match v.MemberInfo with | Some(membInfo) -> - // Note it doesn't matter if we pass 'v.TopValActualParent' or 'v.MemberApparentParent' here. + // Note it doesn't matter if we pass 'v.TopValDeclaringEntity' or 'v.MemberApparentEntity' here. // These only differ if the value is an extension member, and in that case MemberIsCompiledAsInstance always returns // false anyway - MemberIsCompiledAsInstance g v.MemberApparentParent v.IsExtensionMember membInfo v.Attribs + MemberIsCompiledAsInstance g v.MemberApparentEntity v.IsExtensionMember membInfo v.Attribs | _ -> false let ValRefIsCompiledAsInstanceMember g (vref: ValRef) = ValSpecIsCompiledAsInstance g vref.Deref @@ -7383,7 +7383,7 @@ let ValRefIsCompiledAsInstanceMember g (vref: ValRef) = ValSpecIsCompiledAsInsta let GetMemberCallInfo g (vref:ValRef, vFlags) = match vref.MemberInfo with | Some(membInfo) when not vref.IsExtensionMember -> - let numEnclTypeArgs = vref.MemberApparentParent.TyparsNoRange.Length + let numEnclTypeArgs = vref.MemberApparentEntity.TyparsNoRange.Length let virtualCall = (membInfo.MemberFlags.IsOverrideOrExplicitImpl || membInfo.MemberFlags.IsDispatchSlot) && diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index 3c7e70ca283..3eb3ea37a48 100755 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -1778,7 +1778,7 @@ and p_attrib_arg (AttribNamedArg(a,b,c,d)) st = and p_member_info (x:ValMemberInfo) st = p_tup4 (p_tcref "member_info") p_MemberFlags (p_list p_slotsig) p_bool - (x.ApparentParent,x.MemberFlags,x.ImplementedSlotSigs,x.IsImplemented) st + (x.ApparentEnclosingEntity,x.MemberFlags,x.ImplementedSlotSigs,x.IsImplemented) st and p_tycon_objmodel_kind x st = match x with @@ -1822,7 +1822,7 @@ and p_ValData x st = p_option p_ValReprInfo x.val_repr_info st p_string x.val_xmldocsig st p_access x.val_access st - p_parentref x.val_actual_parent st + p_parentref x.val_declaring_entity st p_option p_const x.val_const st if st.oInMem then p_used_space1 (p_xmldoc x.val_xmldoc) st @@ -2063,7 +2063,7 @@ and u_attrib_arg st = and u_member_info st : ValMemberInfo = let x2,x3,x4,x5 = u_tup4 u_tcref u_MemberFlags (u_list u_slotsig) u_bool st - { ApparentParent=x2 + { ApparentEnclosingEntity=x2 MemberFlags=x3 ImplementedSlotSigs=x4 IsImplemented=x5 } @@ -2134,7 +2134,7 @@ and u_ValData st = val_xmldoc= defaultArg x15 XmlDoc.Empty val_xmldocsig=x12 val_access=x13 - val_actual_parent=x13b + val_declaring_entity=x13b val_const=x14 } diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 6e259f8f705..fda1dbda1ab 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -174,7 +174,7 @@ let MethInfoChecks g amap isInstance tyargsOpt objArgs ad m (minfo:MethInfo) = if not (IsTypeAndMethInfoAccessible amap m adOriginal ad minfo) then error (Error (FSComp.SR.tcMethodNotAccessible(minfo.LogicalName), m)) - if isAnyTupleTy g minfo.LogicalEnclosingType then + if isAnyTupleTy g minfo.ApparentEnclosingType then warning (Error (FSComp.SR.tcTupleMemberNotNormallyUsed(), m)) CheckMethInfoAttributes g m tyargsOpt minfo |> CommitOperationResult @@ -644,7 +644,7 @@ let MakeInnerEnvForTyconRef _cenv env tcref isExtrinsicExtension = let MakeInnerEnvForMember cenv env (v:Val) = match v.MemberInfo with | None -> env - | Some _ -> MakeInnerEnvForTyconRef cenv env v.MemberApparentParent v.IsExtensionMember + | Some _ -> MakeInnerEnvForTyconRef cenv env v.MemberApparentEntity v.IsExtensionMember let GetCurrAccumulatedModuleOrNamespaceType env = !(env.eModuleOrNamespaceTypeAccumulator) let SetCurrAccumulatedModuleOrNamespaceType env x = env.eModuleOrNamespaceTypeAccumulator := x @@ -801,7 +801,7 @@ let ReportImplicitlyIgnoredBoolExpression denv m ty expr = if propRef.IsPropertyGetterMethod then let propertyName = propRef.PropertyName let hasCorrespondingSetter = - match propRef.ActualParent with + match propRef.DeclaringEntity with | Parent entityRef -> entityRef.MembersOfFSharpTyconSorted |> List.exists (fun valRef -> valRef.IsPropertySetterMethod && valRef.PropertyName = propertyName) @@ -1046,7 +1046,7 @@ let MakeMemberDataAndMangledNameForMemberVal(g, tcref, isExtrinsic, attrs, optIm let logicalName = ComputeLogicalName id memberFlags let optIntfSlotTys = if optImplSlotTys |> List.forall (isInterfaceTy g) then optImplSlotTys else [] let memberInfo : ValMemberInfo = - { ApparentParent=tcref + { ApparentEnclosingEntity=tcref MemberFlags=memberFlags IsImplemented=false // NOTE: This value is initially only set for interface implementations and those overrides @@ -1349,7 +1349,7 @@ let PublishValueDefn cenv env declKind (vspec:Val) = // // Static initializers don't get published to the tcaug // not (memberInfo.MemberFlags.MemberKind = MemberKind.ClassConstructor)) -> - let tcaug = vspec.MemberApparentParent.TypeContents + let tcaug = vspec.MemberApparentEntity.TypeContents let vref = mkLocalValRef vspec tcaug.tcaug_adhoc <- NameMultiMap.add vspec.LogicalName vref tcaug.tcaug_adhoc tcaug.tcaug_adhoc_list.Add (ValRefIsExplicitImpl cenv.g vref, vref) @@ -1434,7 +1434,7 @@ let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValSche // If it's an extrinsic extension member or not a member then use the containing module. match memberInfoOpt with | Some (ValMemberInfoTransient(memberInfo, _, _)) when not isExtrinsic -> - if memberInfo.ApparentParent.IsModuleOrNamespace then + if memberInfo.ApparentEnclosingEntity.IsModuleOrNamespace then errorR(InternalError(FSComp.SR.tcExpectModuleOrNamespaceParent(id.idText), m)) // Members of interface implementations have the accessibility of the interface @@ -1447,7 +1447,7 @@ let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValSche | _ -> None else None - Parent(memberInfo.ApparentParent), vis + Parent(memberInfo.ApparentEnclosingEntity), vis | _ -> altActualParent, None let vis, _ = ComputeAccessAndCompPath env (Some declKind) id.idRange vis overrideVis actualParent @@ -1955,7 +1955,7 @@ let FreshenAbstractSlot g amap m synTyparDecls absMethInfo = // If the virtual method is a generic method then copy its type parameters let typarsFromAbsSlot, typarInstFromAbsSlot, _ = let ttps = absMethInfo.GetFormalTyparsOfDeclaringType m - let ttinst = argsOfAppTy g absMethInfo.LogicalEnclosingType + let ttinst = argsOfAppTy g absMethInfo.ApparentEnclosingType let rigid = if typarsFromAbsSlotAreRigid then TyparRigidity.Rigid else TyparRigidity.Flexible ConstraintSolver.FreshenAndFixupTypars m rigid ttps ttinst fmtps @@ -8659,7 +8659,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del | Item.CtorGroup(nm, minfos) -> let objTy = match minfos with - | (minfo :: _) -> minfo.LogicalEnclosingType + | (minfo :: _) -> minfo.ApparentEnclosingType | [] -> error(Error(FSComp.SR.tcTypeHasNoAccessibleConstructor(), mItem)) match delayed with | ((DelayedApp (_, arg, mExprAndArg))::otherDelayed) -> @@ -8685,7 +8685,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del #endif item, minfos - minfosAfterTyArgs |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.LogicalEnclosingType objTyAfterTyArgs) + minfosAfterTyArgs |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.ApparentEnclosingType objTyAfterTyArgs) TcCtorCall true cenv env tpenv overallTy objTyAfterTyArgs (Some mExprAndTypeArgs) itemAfterTyArgs false [arg] mExprAndArg otherDelayed (Some afterResolution) | ((DelayedTypeApp(tyargs, _mTypeArgs, mExprAndTypeArgs))::otherDelayed) -> @@ -8696,7 +8696,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del let resolvedItem = Item.Types(nm, [objTy]) CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs, env.NameEnv, resolvedItem, resolvedItem, emptyTyparInst, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights) - minfos |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.LogicalEnclosingType objTy) + minfos |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.ApparentEnclosingType objTy) TcCtorCall true cenv env tpenv overallTy objTy (Some mExprAndTypeArgs) item false [] mExprAndTypeArgs otherDelayed (Some afterResolution) | _ -> @@ -9630,20 +9630,20 @@ and TcMethodApplication // if (isInstance && finalCalledMethInfo.IsInstance && - typeEquiv cenv.g finalCalledMethInfo.LogicalEnclosingType cenv.g.obj_ty && + typeEquiv cenv.g finalCalledMethInfo.ApparentEnclosingType cenv.g.obj_ty && (finalCalledMethInfo.LogicalName = "GetHashCode" || finalCalledMethInfo.LogicalName = "Equals")) then objArgs |> List.iter (fun expr -> ConstraintSolver.AddCxTypeMustSupportEquality env.DisplayEnv cenv.css mMethExpr NoTrace (tyOfExpr cenv.g expr)) // Uses of a Dictionary() constructor without an IEqualityComparer argument imply an equality constraint // on the first type argument. - if HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.LogicalEnclosingType && + if HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.ApparentEnclosingType && finalCalledMethInfo.IsConstructor && not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs) |> List.existsSquared (fun (ParamData(_, _, _, _, _, _, ty)) -> HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_IEqualityComparer ty)) then - match argsOfAppTy cenv.g finalCalledMethInfo.LogicalEnclosingType with + match argsOfAppTy cenv.g finalCalledMethInfo.ApparentEnclosingType with | [dty; _] -> ConstraintSolver.AddCxTypeMustSupportEquality env.DisplayEnv cenv.css mMethExpr NoTrace dty | _ -> () end @@ -10763,7 +10763,7 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (binds, bindsm, sco // This assignment forces representation as module value, to maintain the invariant from the // type checker that anything related to binding module-level values is marked with an - // val_repr_info, val_actual_parent and is_topbind + // val_repr_info, val_declaring_entity and is_topbind if (DeclKind.MustHaveArity declKind) then AdjustValToTopVal tmp altActualParent (InferArityOfExprBinding cenv.g AllowTypeDirectedDetupling.Yes tmp rhsExpr) tmp, pat' @@ -10932,7 +10932,7 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy, m, synTy let optInferredImplSlotTys = match optIntfSlotTy with | Some (x, _) -> [x] - | None -> uniqueAbstractMethSigs |> List.map (fun x -> x.LogicalEnclosingType) + | None -> uniqueAbstractMethSigs |> List.map (fun x -> x.ApparentEnclosingType) optInferredImplSlotTys, declaredTypars @@ -10994,7 +10994,7 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy, m, synTy let optInferredImplSlotTys = match optIntfSlotTy with | Some (x, _) -> [ x ] - | None -> uniqueAbstractPropSigs |> List.map (fun pinfo -> pinfo.LogicalEnclosingType) + | None -> uniqueAbstractPropSigs |> List.map (fun pinfo -> pinfo.ApparentEnclosingType) optInferredImplSlotTys, declaredTypars @@ -14308,7 +14308,7 @@ module TcExceptionDeclarations = minfo.GenericArity = 0) match candidates with | [minfo] -> - match minfo.LogicalEnclosingType with + match minfo.ApparentEnclosingType with | AppTy cenv.g (tcref, _) as ety when (TypeDefinitelySubsumesTypeNoCoercion 0 cenv.g cenv.amap m cenv.g.exn_ty ety) -> let tref = tcref.CompiledRepresentationForNamedType TExnAsmRepr tref diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 145ae93e513..843a7f5d2cb 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -410,7 +410,7 @@ let GetCompiledReturnTyOfProvidedMethodInfo amap m (mi:Tainted - let parentToMemberInst,_ = mkTyparToTyparRenaming (ovByMethValRef.MemberApparentParent.Typars(m)) enclosingTypars + let parentToMemberInst,_ = mkTyparToTyparRenaming (ovByMethValRef.MemberApparentEntity.Typars(m)) enclosingTypars let res = instSlotSig parentToMemberInst slotsig res | None -> @@ -662,21 +662,26 @@ type ILTypeInfo = | ILTypeInfo of TcGlobals * TType * ILTypeRef * ILTypeDef member x.TcGlobals = let (ILTypeInfo(g,_,_,_)) = x in g - member x.ILTypeRef = let (ILTypeInfo(_,_,tref,_)) = x in tref + + member x.ILTypeRef = let (ILTypeInfo(_,_,tref,_)) = x in tref + + member x.RawMetadata = let (ILTypeInfo(_,_,_,tdef)) = x in tdef + + member x.ToType = let (ILTypeInfo(_,ty,_,_)) = x in ty /// Get the compiled nominal type. In the case of tuple types, this is a .NET tuple type - member x.ToAppType = - let (ILTypeInfo(g, ty, _, _)) = x - helpEnsureTypeHasMetadata g ty + member x.ToAppType = helpEnsureTypeHasMetadata x.TcGlobals x.ToType member x.TyconRefOfRawMetadata = tcrefOfAppTy x.TcGlobals x.ToAppType + member x.TypeInstOfRawMetadata = argsOfAppTy x.TcGlobals x.ToAppType - member x.RawMetadata = let (ILTypeInfo(_,_,_,tdef)) = x in tdef - member x.ToType = let (ILTypeInfo(_,ty,_,_)) = x in ty member x.ILScopeRef = x.ILTypeRef.Scope + member x.Name = x.ILTypeRef.Name + member x.IsValueType = x.RawMetadata.IsStructOrEnum + member x.Instantiate inst = let (ILTypeInfo(g,ty,tref,tdef)) = x ILTypeInfo(g,instType inst ty,tref,tdef) @@ -719,12 +724,10 @@ type ILMethInfo = /// Get the apparent declaring type of the method as an F# type. /// If this is a C#-style extension method then this is the type which the method /// appears to extend. This may be a variable type. - member x.LogicalEnclosingType = match x with ILMethInfo(_,ty,_,_,_) -> ty + member x.ApparentEnclosingType = match x with ILMethInfo(_,ty,_,_,_) -> ty - /// Like LogicalEnclosingType but use the compiled nominal type if this is a method on a tuple type - member x.LogicalEnclosingAppType = - let enclTy = x.LogicalEnclosingType - helpEnsureTypeHasMetadata x.TcGlobals enclTy + /// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type + member x.ApparentEnclosingAppType = helpEnsureTypeHasMetadata x.TcGlobals x.ApparentEnclosingType /// Get the declaring type associated with an extension member, if any. member x.ILExtensionMethodDeclaringTyconRef = match x with ILMethInfo(_,_,tcrefOpt,_,_) -> tcrefOpt @@ -746,14 +749,14 @@ type ILMethInfo = member x.DeclaringTyconRef = match x.ILExtensionMethodDeclaringTyconRef with | Some tcref -> tcref - | None -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + | None -> tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the instantiation of the declaring type of the method. /// If this is an C#-style extension method then this is empty because extension members /// are never in generic classes. member x.DeclaringTypeInst = if x.IsILExtensionMethod then [] - else argsOfAppTy x.TcGlobals x.LogicalEnclosingAppType + else argsOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the Abstract IL scope information associated with interpreting the Abstract IL metadata that backs this method. member x.MetadataScope = x.DeclaringTyconRef.CompiledRepresentationForNamedType.Scope @@ -843,7 +846,7 @@ type ILMethInfo = if x.IsILExtensionMethod then [ImportILTypeFromMetadata amap m x.MetadataScope x.DeclaringTypeInst minst x.RawMetadata.Parameters.Head.Type] else if x.IsInstance then - [ x.LogicalEnclosingType ] + [ x.ApparentEnclosingType ] else [] @@ -888,9 +891,9 @@ type MethInfo = /// /// If this is an extension member, then this is the apparent parent, i.e. the type the method appears to extend. /// This may be a variable type. - member x.LogicalEnclosingType = + member x.ApparentEnclosingType = match x with - | ILMeth(_,ilminfo,_) -> ilminfo.LogicalEnclosingType + | ILMeth(_,ilminfo,_) -> ilminfo.ApparentEnclosingType | FSMeth(_,typ,_,_) -> typ | DefaultStructCtor(_,typ) -> typ #if !NO_EXTENSIONTYPING @@ -899,10 +902,13 @@ type MethInfo = #endif /// Get the enclosing type of the method info, using a nominal type for tuple types - member x.LogicalEnclosingAppType = + member x.ApparentEnclosingAppType = match x with - | ILMeth(_,ilminfo,_) -> ilminfo.LogicalEnclosingAppType - | _ -> x.LogicalEnclosingType + | ILMeth(_,ilminfo,_) -> ilminfo.ApparentEnclosingAppType + | _ -> x.ApparentEnclosingType + + member x.ApparentEnclosingTyconRef = + tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the declaring type or module holding the method. If this is an C#-style extension method then this is the type /// holding the static member that is the extension method. If this is an F#-style extension method it is the logical module @@ -910,8 +916,8 @@ type MethInfo = member x.DeclaringTyconRef = match x with | ILMeth(_,ilminfo,_) when x.IsExtensionMember -> ilminfo.DeclaringTyconRef - | FSMeth(_,_,vref,_) when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent - | _ -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + | FSMeth(_,_,vref,_) when x.IsExtensionMember && vref.HasDeclaringEntity -> vref.TopValDeclaringEntity + | _ -> x.ApparentEnclosingTyconRef /// Get the information about provided static parameters, if any member x.ProvidedStaticParameterInfo = @@ -981,13 +987,13 @@ type MethInfo = #endif | _ -> false - override x.ToString() = x.LogicalEnclosingType.ToString() + x.LogicalName + override x.ToString() = x.ApparentEnclosingType.ToString() + x.LogicalName /// Get the actual type instantiation of the declaring type associated with this use of the method. /// /// For extension members this is empty (the instantiation of the declaring type). member x.DeclaringTypeInst = - if x.IsExtensionMember then [] else argsOfAppTy x.TcGlobals x.LogicalEnclosingAppType + if x.IsExtensionMember then [] else argsOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the TcGlobals value that governs the method declaration member x.TcGlobals = @@ -1107,7 +1113,7 @@ type MethInfo = match x with | ILMeth(_g,ilmeth,_) -> ilmeth.IsVirtual | FSMeth(g,_,vref,_) as x -> - isInterfaceTy g x.LogicalEnclosingType || + isInterfaceTy g x.ApparentEnclosingType || vref.MemberInfo.Value.MemberFlags.IsDispatchSlot | DefaultStructCtor _ -> false #if !NO_EXTENSIONTYPING @@ -1134,14 +1140,14 @@ type MethInfo = member minfo.IsAbstract = match minfo with | ILMeth(_,ilmeth,_) -> ilmeth.IsAbstract - | FSMeth(g,_,vref,_) -> isInterfaceTy g minfo.LogicalEnclosingType || vref.IsDispatchSlotMember + | FSMeth(g,_,vref,_) -> isInterfaceTy g minfo.ApparentEnclosingType || vref.IsDispatchSlotMember | DefaultStructCtor _ -> false #if !NO_EXTENSIONTYPING | ProvidedMeth(_,mi,_,m) -> mi.PUntaint((fun mi -> mi.IsAbstract), m) #endif member x.IsNewSlot = - isInterfaceTy x.TcGlobals x.LogicalEnclosingType || + isInterfaceTy x.TcGlobals x.ApparentEnclosingType || (x.IsVirtual && (match x with | ILMeth(_,x,_) -> x.IsNewSlot @@ -1200,7 +1206,7 @@ type MethInfo = // but is compiled as a generic methods with two type arguments // Map<'T,'U>(this: List<'T>, f : 'T -> 'U) member x.AdjustUserTypeInstForFSharpStyleIndexedExtensionMembers(tyargs) = - (if x.IsFSharpStyleExtensionMember then argsOfAppTy x.TcGlobals x.LogicalEnclosingAppType else []) @ tyargs + (if x.IsFSharpStyleExtensionMember then argsOfAppTy x.TcGlobals x.ApparentEnclosingAppType else []) @ tyargs /// Indicates if this method is a generated method associated with an F# CLIEvent property compiled as a .NET event member x.IsFSharpEventPropertyMethod = @@ -1218,7 +1224,7 @@ type MethInfo = /// /// For an extension method, this indicates if the method extends a struct type. member x.IsStruct = - isStructTy x.TcGlobals x.LogicalEnclosingType + isStructTy x.TcGlobals x.ApparentEnclosingType /// Build IL method infos. static member CreateILMeth (amap:Import.ImportMap, m, typ:TType, md: ILMethodDef) = @@ -1458,15 +1464,14 @@ type MethInfo = let allTyparsFromMethod,_,retTy,_ = GetTypeOfMemberInMemberForm g vref // A slot signature is w.r.t. the type variables of the type it is associated with. // So we have to rename from the member type variables to the type variables of the type. - let tcref = tcrefOfAppTy g x.LogicalEnclosingAppType - let formalEnclosingTypars = tcref.Typars(m) + let formalEnclosingTypars = x.ApparentEnclosingTyconRef.Typars(m) let formalEnclosingTyparsFromMethod,formalMethTypars = List.chop formalEnclosingTypars.Length allTyparsFromMethod let methodToParentRenaming,_ = mkTyparToTyparRenaming formalEnclosingTyparsFromMethod formalEnclosingTypars let formalParams = GetArgInfosOfMember x.IsCSharpStyleExtensionMember g vref |> List.mapSquared (map1Of2 (instType methodToParentRenaming) >> MakeSlotParam ) let formalRetTy = Option.map (instType methodToParentRenaming) retTy - MakeSlotSig(x.LogicalName, x.LogicalEnclosingType, formalEnclosingTypars, formalMethTypars, formalParams, formalRetTy) + MakeSlotSig(x.LogicalName, x.ApparentEnclosingType, formalEnclosingTypars, formalMethTypars, formalParams, formalRetTy) | DefaultStructCtor _ -> error(InternalError("no slotsig for DefaultStructCtor",m)) | _ -> let g = x.TcGlobals @@ -1476,7 +1481,7 @@ type MethInfo = // happens to make the return type 'unit' (i.e. it was originally a variable type // then that does not correspond to a slotsig compiled as a 'void' return type. // REVIEW: should we copy down attributes to slot params? - let tcref = tcrefOfAppTy g x.LogicalEnclosingAppType + let tcref = tcrefOfAppTy g x.ApparentEnclosingAppType let formalEnclosingTyparsOrig = tcref.Typars(m) let formalEnclosingTypars = copyTypars formalEnclosingTyparsOrig let _,formalEnclosingTyparTys = FixupNewTypars m [] [] formalEnclosingTyparsOrig formalEnclosingTypars @@ -1508,7 +1513,7 @@ type MethInfo = formalRetTy, formalParams #endif | _ -> failwith "unreachable" - MakeSlotSig(x.LogicalName, x.LogicalEnclosingType, formalEnclosingTypars, formalMethTypars,formalParams, formalRetTy) + MakeSlotSig(x.LogicalName, x.ApparentEnclosingType, formalEnclosingTypars, formalMethTypars,formalParams, formalRetTy) /// Get the ParamData objects for the parameters of a MethInfo member x.GetParamDatas(amap, m, minst) = @@ -1577,16 +1582,18 @@ type ILFieldInfo = #endif /// Get the enclosing ("parent"/"declaring") type of the field. - member x.LogicalEnclosingType = + member x.ApparentEnclosingType = match x with | ILFieldInfo(tinfo,_) -> tinfo.ToType #if !NO_EXTENSIONTYPING | ProvidedField(amap,fi,m) -> (Import.ImportProvidedType amap m (fi.PApply((fun fi -> fi.DeclaringType),m))) #endif - member x.LogicalEnclosingAppType = x.LogicalEnclosingType + member x.ApparentEnclosingAppType = x.ApparentEnclosingType - member x.DeclaringTyconRef = tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + member x.ApparentEnclosingTyconRef = tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType + + member x.DeclaringTyconRef = x.ApparentEnclosingTyconRef member x.TcGlobals = match x with @@ -1635,7 +1642,7 @@ type ILFieldInfo = match x with | ILFieldInfo(tinfo,_) -> tinfo.IsValueType #if !NO_EXTENSIONTYPING - | ProvidedField(amap,_,_) -> isStructTy amap.g x.LogicalEnclosingType + | ProvidedField(amap,_,_) -> isStructTy amap.g x.ApparentEnclosingType #endif /// Indicates if the field is static @@ -1774,12 +1781,10 @@ type ILPropInfo = /// Get the apparent declaring type of the method as an F# type. /// If this is a C#-style extension method then this is the type which the method /// appears to extend. This may be a variable type. - member x.LogicalEnclosingType = match x with ILPropInfo(tinfo,_) -> tinfo.ToType + member x.ApparentEnclosingType = match x with ILPropInfo(tinfo,_) -> tinfo.ToType - /// Like LogicalEnclosingType but use the compiled nominal type if this is a method on a tuple type - member x.LogicalEnclosingAppType = - let enclTy = x.LogicalEnclosingType - helpEnsureTypeHasMetadata x.TcGlobals enclTy + /// Like ApparentEnclosingType but use the compiled nominal type if this is a method on a tuple type + member x.ApparentEnclosingAppType = helpEnsureTypeHasMetadata x.TcGlobals x.ApparentEnclosingType /// Get the raw Abstract IL metadata for the IL property member x.RawMetadata = match x with ILPropInfo(_,pd) -> pd @@ -1858,7 +1863,7 @@ type PropInfo = /// Get the enclosing type of the property. /// /// If this is an extension member, then this is the apparent parent, i.e. the type the property appears to extend. - member x.LogicalEnclosingType = + member x.ApparentEnclosingType = match x with | ILProp ilpinfo -> ilpinfo.ILTypeInfo.ToType | FSProp(_,typ,_,_) -> typ @@ -1868,10 +1873,12 @@ type PropInfo = #endif /// Get the enclosing type of the method info, using a nominal type for tuple types - member x.LogicalEnclosingAppType = + member x.ApparentEnclosingAppType = match x with - | ILProp ilpinfo -> ilpinfo.LogicalEnclosingAppType - | _ -> x.LogicalEnclosingType + | ILProp ilpinfo -> ilpinfo.ApparentEnclosingAppType + | _ -> x.ApparentEnclosingType + + member x.ApparentEnclosingTyconRef = tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the declaring type or module holding the method. /// Note that C#-style extension properties don't exist in the C# design as yet. @@ -1879,9 +1886,8 @@ type PropInfo = /// holding the value for the extension method. member x.DeclaringTyconRef = match x.ArbitraryValRef with - | Some vref when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent - | _ -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType - + | Some vref when x.IsExtensionMember && vref.HasDeclaringEntity -> vref.TopValDeclaringEntity + | _ -> x.ApparentEnclosingTyconRef /// Try to get an arbitrary F# ValRef associated with the member. This is to determine if the member is virtual, amongst other things. member x.ArbitraryValRef : ValRef option = @@ -2077,7 +2083,7 @@ type PropInfo = /// Indicates if the enclosing type for the property is a value type. /// /// For an extension property, this indicates if the property extends a struct type. - member x.IsValueType = isStructTy x.TcGlobals x.LogicalEnclosingType + member x.IsValueType = isStructTy x.TcGlobals x.ApparentEnclosingType /// Get the result type of the property @@ -2188,13 +2194,13 @@ type ILEventInfo = | ILEventInfo of ILTypeInfo * ILEventDef /// Get the enclosing ("parent"/"declaring") type of the field. - member x.LogicalEnclosingType = match x with ILEventInfo(tinfo,_) -> tinfo.ToType + member x.ApparentEnclosingType = match x with ILEventInfo(tinfo,_) -> tinfo.ToType // Note: events are always assocaited with nominal types - member x.LogicalEnclosingAppType = x.LogicalEnclosingType + member x.ApparentEnclosingAppType = x.ApparentEnclosingType // Note: IL Events are never extension members as C# has no notion of extension events as yet - member x.DeclaringTyconRef = tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + member x.DeclaringTyconRef = tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType member x.TcGlobals = match x with ILEventInfo(tinfo,_) -> tinfo.TcGlobals @@ -2272,27 +2278,29 @@ type EventInfo = /// Get the enclosing type of the event. /// /// If this is an extension member, then this is the apparent parent, i.e. the type the event appears to extend. - member x.LogicalEnclosingType = + member x.ApparentEnclosingType = match x with - | ILEvent ileinfo -> ileinfo.LogicalEnclosingType - | FSEvent (_,p,_,_) -> p.LogicalEnclosingType + | ILEvent ileinfo -> ileinfo.ApparentEnclosingType + | FSEvent (_,p,_,_) -> p.ApparentEnclosingType #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,ei,m) -> Import.ImportProvidedType amap m (ei.PApply((fun ei -> ei.DeclaringType),m)) #endif /// Get the enclosing type of the method info, using a nominal type for tuple types - member x.LogicalEnclosingAppType = + member x.ApparentEnclosingAppType = match x with - | ILEvent ileinfo -> ileinfo.LogicalEnclosingAppType - | _ -> x.LogicalEnclosingType + | ILEvent ileinfo -> ileinfo.ApparentEnclosingAppType + | _ -> x.ApparentEnclosingType + + member x.ApparentEnclosingTyconRef = tcrefOfAppTy x.TcGlobals x.ApparentEnclosingAppType /// Get the declaring type or module holding the method. /// Note that C#-style extension properties don't exist in the C# design as yet. /// If this is an F#-style extension method it is the logical module /// holding the value for the extension method. - member x.DeclaringTyconRef = + member x.DeclaringTyconRef = match x.ArbitraryValRef with - | Some vref when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent - | _ -> tcrefOfAppTy x.TcGlobals x.LogicalEnclosingAppType + | Some vref when x.IsExtensionMember && vref.HasDeclaringEntity -> vref.TopValDeclaringEntity + | _ -> x.ApparentEnclosingTyconRef /// Indicates if this event has an associated XML comment authored in this assembly. @@ -2355,13 +2363,13 @@ type EventInfo = /// Indicates if the enclosing type for the event is a value type. /// /// For an extension event, this indicates if the event extends a struct type. - member x.IsValueType = isStructTy x.TcGlobals x.LogicalEnclosingType + member x.IsValueType = isStructTy x.TcGlobals x.ApparentEnclosingType /// Get the 'add' method associated with an event member x.AddMethod = match x with | ILEvent ileinfo -> ILMeth(ileinfo.TcGlobals, ileinfo.AddMethod, None) - | FSEvent(g,p,addValRef,_) -> FSMeth(g,p.LogicalEnclosingType,addValRef,None) + | FSEvent(g,p,addValRef,_) -> FSMeth(g,p.ApparentEnclosingType,addValRef,None) #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,ei,m) -> let meth = GetAndSanityCheckProviderMethod m ei (fun ei -> ei.GetAddMethod()) FSComp.SR.etEventNoAdd @@ -2372,7 +2380,7 @@ type EventInfo = member x.RemoveMethod = match x with | ILEvent ileinfo -> ILMeth(x.TcGlobals, ileinfo.RemoveMethod, None) - | FSEvent(g,p,_,removeValRef) -> FSMeth(g,p.LogicalEnclosingType,removeValRef,None) + | FSEvent(g,p,_,removeValRef) -> FSMeth(g,p.ApparentEnclosingType,removeValRef,None) #if !NO_EXTENSIONTYPING | ProvidedEvent (amap,ei,m) -> let meth = GetAndSanityCheckProviderMethod m ei (fun ei -> ei.GetRemoveMethod()) FSComp.SR.etEventNoRemove @@ -2442,7 +2450,7 @@ let CompiledSigOfMeth g amap m (minfo:MethInfo) = // of the enclosing type. For example, they may have constraints involving the _formal_ type parameters // of the enclosing type. This instantiations can be used to interpret those type parameters let fmtpinst = - let parentTyArgs = argsOfAppTy g minfo.LogicalEnclosingAppType + let parentTyArgs = argsOfAppTy g minfo.ApparentEnclosingAppType let memberParentTypars = minfo.GetFormalTyparsOfDeclaringType m mkTyparInst memberParentTypars parentTyArgs diff --git a/src/fsharp/service/ServiceInterfaceStubGenerator.fs b/src/fsharp/service/ServiceInterfaceStubGenerator.fs index 47c0de31e32..04b09ec157b 100644 --- a/src/fsharp/service/ServiceInterfaceStubGenerator.fs +++ b/src/fsharp/service/ServiceInterfaceStubGenerator.fs @@ -325,7 +325,7 @@ module internal InterfaceStubGenerator = | _, true, _, name -> name + parArgs // Ordinary functions or values | false, _, _, name when - not (Symbol.hasAttribute v.LogicalEnclosingEntity.Attributes) -> + not (Symbol.hasAttribute v.ApparentEnclosingEntity.Attributes) -> name + " " + parArgs // Ordinary static members or things (?) that require fully qualified access | _, _, _, name -> name + parArgs diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 56263fe9de5..a2561d73fb6 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -364,7 +364,7 @@ type TypeCheckInfo let result = match cnrs with | CNR(_, Item.CtorGroup(_, ((ctor::_) as ctors)), _, denv, nenv, ad, m) ::_ -> - let props = ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ctor.LogicalEnclosingType + let props = ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ctor.ApparentEnclosingType let parameters = CollectParameters ctors amap m let items = props @ parameters Some (denv, m, items) @@ -1353,7 +1353,7 @@ type TypeCheckInfo Some (m, SemanticClassificationType.ValueType) else Some (m, SemanticClassificationType.ReferenceType) | CNR(_, Item.CtorGroup(_, minfos), LegitTypeOccurence, _, _, _, m) -> - if minfos |> List.exists (fun minfo -> isStructTy g minfo.LogicalEnclosingType) then + if minfos |> List.exists (fun minfo -> isStructTy g minfo.ApparentEnclosingType) then Some (m, SemanticClassificationType.ValueType) else Some (m, SemanticClassificationType.ReferenceType) | CNR(_, Item.ExnCase _, LegitTypeOccurence, _, _, _, m) -> diff --git a/src/fsharp/symbols/Exprs.fs b/src/fsharp/symbols/Exprs.fs index 13717ece55e..405ae4e7e96 100644 --- a/src/fsharp/symbols/Exprs.fs +++ b/src/fsharp/symbols/Exprs.fs @@ -736,7 +736,7 @@ module FSharpExprConvert = enclosingEntity.ModuleOrNamespaceType.AllValsAndMembers |> Seq.filter (fun v -> v.CompiledName = vName && - match v.ActualParent with + match v.DeclaringEntity with | Parent p -> p.PublicPath = enclosingEntity.PublicPath | _ -> false ) |> List.ofSeq diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index f7855e11d36..a2997654b74 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -498,8 +498,8 @@ module internal SymbolHelpers = let GetXmlDocSigOfScopedValRef g (tcref:TyconRef) (vref:ValRef) = let ccuFileName = libFileOfEntityRef tcref let v = vref.Deref - if v.XmlDocSig = "" && v.HasTopValActualParent then - v.XmlDocSig <- XmlDocSigOfVal g (buildAccessPath vref.TopValActualParent.CompilationPathOpt) v + if v.XmlDocSig = "" && v.HasDeclaringEntity then + v.XmlDocSig <- XmlDocSigOfVal g (buildAccessPath vref.TopValDeclaringEntity.CompilationPathOpt) v Some (ccuFileName, v.XmlDocSig) let GetXmlDocSigOfRecdFieldInfo (rfinfo:RecdFieldInfo) = @@ -549,8 +549,8 @@ module internal SymbolHelpers = if not vref.IsLocalRef then let ccuFileName = vref.nlr.Ccu.FileName let v = vref.Deref - if v.XmlDocSig = "" && v.HasTopValActualParent then - v.XmlDocSig <- XmlDocSigOfVal g vref.TopValActualParent.CompiledRepresentationForNamedType.Name v + if v.XmlDocSig = "" && v.HasDeclaringEntity then + v.XmlDocSig <- XmlDocSigOfVal g vref.TopValDeclaringEntity.CompiledRepresentationForNamedType.Name v Some (ccuFileName, v.XmlDocSig) else None @@ -1079,7 +1079,7 @@ module internal SymbolHelpers = let rty, _cxs = PrettyTypes.PrettifyType g rty let layout = wordL (tagText (FSComp.SR.typeInfoEvent())) ^^ - NicePrint.layoutTyconRef denv (tcrefOfAppTy g einfo.LogicalEnclosingAppType) ^^ + NicePrint.layoutTyconRef denv einfo.ApparentEnclosingTyconRef ^^ SepL.dot ^^ wordL (tagEvent einfo.EventName) ^^ RightL.colon ^^ @@ -1110,7 +1110,7 @@ module internal SymbolHelpers = ) ^^ SepL.lineBreak ^^ SepL.lineBreak ^^ wordL (tagText (FSComp.SR.typeInfoCallsWord())) ^^ - NicePrint.layoutTyconRef denv (tcrefOfAppTy g minfo.LogicalEnclosingAppType) ^^ + NicePrint.layoutTyconRef denv minfo.ApparentEnclosingTyconRef ^^ SepL.dot ^^ wordL (tagMethod minfo.DisplayName) @@ -1270,7 +1270,7 @@ module internal SymbolHelpers = let getKeywordForMethInfo (minfo : MethInfo) = match minfo with | FSMeth(_, _, vref, _) -> - match vref.ActualParent with + match vref.DeclaringEntity with | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.CompiledName|> Some | ParentNone -> None @@ -1290,8 +1290,8 @@ module internal SymbolHelpers = match item with | Item.Value vref | Item.CustomBuilder (_, vref) -> let v = vref.Deref - if v.IsModuleBinding && v.HasTopValActualParent then - let tyconRef = v.TopValActualParent + if v.IsModuleBinding && v.HasDeclaringEntity then + let tyconRef = v.TopValDeclaringEntity let paramsString = match v.Typars with | [] -> "" @@ -1359,7 +1359,7 @@ module internal SymbolHelpers = | FSProp(_, _, Some vref, _) | FSProp(_, _, _, Some vref) -> // per spec, extension members in F1 keywords are qualified with definition class - match vref.ActualParent with + match vref.DeclaringEntity with | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some | ParentNone -> None @@ -1382,7 +1382,7 @@ module internal SymbolHelpers = match pinfo.ArbitraryValRef with | Some vref -> // per spec, members in F1 keywords are qualified with definition class - match vref.ActualParent with + match vref.DeclaringEntity with | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some | ParentNone -> None | None -> None @@ -1393,7 +1393,7 @@ module internal SymbolHelpers = match minfos with | [] -> None | FSMeth(_, _, vref, _) :: _ -> - match vref.ActualParent with + match vref.DeclaringEntity with | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef) + ".#ctor"|> Some | ParentNone -> None #if !NO_EXTENSIONTYPING diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index e08148a670b..b3da397df6b 100644 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -505,7 +505,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = // For F#-declared extension members, yield a value-backed member and a property info if possible let vref = mkNestedValRef entity v yield FSharpMemberOrFunctionOrValue(cenv, V vref, Item.Value vref) - match v.MemberInfo.Value.MemberFlags.MemberKind, v.ApparentParent with + match v.MemberInfo.Value.MemberFlags.MemberKind, v.ApparentEnclosingEntity with | MemberKind.PropertyGet, Parent p -> let pinfo = FSProp(cenv.g, generalizedTyconRef p, Some vref, None) yield FSharpMemberOrFunctionOrValue(cenv, P pinfo, Item.Property (pinfo.PropertyName, [pinfo])) @@ -942,7 +942,7 @@ and FSharpActivePatternGroup(cenv, apinfo:PrettyNaming.ActivePatternInfo, typ, v member __.DeclaringEntity = valOpt |> Option.bind (fun vref -> - match vref.ActualParent with + match vref.DeclaringEntity with | ParentNone -> None | Parent p -> Some (FSharpEntity(cenv, p))) @@ -1267,18 +1267,18 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | P p -> FSharpEntity(cenv, p.DeclaringTyconRef) |> Some | M m | C m -> FSharpEntity(cenv, m.DeclaringTyconRef) |> Some | V v -> - match v.ActualParent with + match v.DeclaringEntity with | ParentNone -> None | Parent p -> FSharpEntity(cenv, p) |> Some - member __.LogicalEnclosingEntity = + member __.ApparentEnclosingEntity = checkIsResolved() match d with - | E m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.LogicalEnclosingAppType) - | P p -> FSharpEntity(cenv, tcrefOfAppTy cenv.g p.LogicalEnclosingAppType) - | M m | C m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.LogicalEnclosingAppType) + | E e -> FSharpEntity(cenv, e.ApparentEnclosingTyconRef) + | P p -> FSharpEntity(cenv, p.ApparentEnclosingTyconRef) + | M m | C m -> FSharpEntity(cenv, m.ApparentEnclosingTyconRef) | V v -> - match v.ApparentParent with + match v.ApparentEnclosingEntity with | ParentNone -> invalidOp "the value or member doesn't have a logical parent" | Parent p -> FSharpEntity(cenv, p) @@ -1420,8 +1420,8 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member x.EventForFSharpProperty = match d with | P p when p.IsFSharpEventProperty -> - let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.LogicalEnclosingType - let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.LogicalEnclosingType + let minfos1 = GetImmediateIntrinsicMethInfosOfType (Some("add_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.ApparentEnclosingType + let minfos2 = GetImmediateIntrinsicMethInfosOfType (Some("remove_"+p.PropertyName), AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 p.ApparentEnclosingType match minfos1, minfos2 with | [addMeth], [removeMeth] -> match addMeth.ArbitraryValRef, removeMeth.ArbitraryValRef with @@ -1609,7 +1609,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | Some (_, docsig) -> docsig | _ -> "" | V v -> - match v.ActualParent with + match v.DeclaringEntity with | Parent entityRef -> match SymbolHelpers.GetXmlDocSigOfScopedValRef cenv.g entityRef v with | Some (_, docsig) -> docsig diff --git a/src/fsharp/symbols/Symbols.fsi b/src/fsharp/symbols/Symbols.fsi index 152be3b33ac..462544bd208 100644 --- a/src/fsharp/symbols/Symbols.fsi +++ b/src/fsharp/symbols/Symbols.fsi @@ -644,7 +644,7 @@ and [] public FSharpMemberOrFunctionOrValue = member DeclaringEntity : FSharpEntity option /// Get the logical enclosing entity, which for an extension member is type being extended - member LogicalEnclosingEntity: FSharpEntity + member ApparentEnclosingEntity: FSharpEntity /// Get the declaration location of the member, function or value member DeclarationLocation: range diff --git a/src/fsharp/tast.fs b/src/fsharp/tast.fs index 8e5ba69dcd7..5912bb1ea3d 100755 --- a/src/fsharp/tast.fs +++ b/src/fsharp/tast.fs @@ -2220,7 +2220,7 @@ and [] // -- LinearizeTopMatch // // The fresh temporary should just be created with the right parent - mutable val_actual_parent: ParentRef + mutable val_declaring_entity: ParentRef /// XML documentation attached to a value. /// MUTABILITY: for unpickle linkage @@ -2294,7 +2294,7 @@ and [] member x.LinkagePartialKey : ValLinkagePartialKey = assert x.IsCompiledAsTopLevel { LogicalName = x.LogicalName - MemberParentMangledName = (if x.IsMember then Some x.MemberApparentParent.LogicalName else None) + MemberParentMangledName = (if x.IsMember then Some x.MemberApparentEntity.LogicalName else None) MemberIsOverride = x.IsOverrideOrExplicitImpl TotalArgCount = if x.IsMember then x.ValReprInfo.Value.TotalArgCount else 0 } @@ -2412,26 +2412,26 @@ and [] and set(v) = x.val_xmldocsig <- v /// The parent type or module, if any (None for expression bindings and parameters) - member x.ActualParent = x.val_actual_parent + member x.DeclaringEntity = x.val_declaring_entity /// Get the actual parent entity for the value (a module or a type), i.e. the entity under which the /// value will appear in compiled code. For extension members this is the module where the extension member /// is declared. - member x.TopValActualParent = - match x.ActualParent with + member x.TopValDeclaringEntity = + match x.DeclaringEntity with | Parent tcref -> tcref - | ParentNone -> error(InternalError("TopValActualParent: does not have a parent",x.Range)) + | ParentNone -> error(InternalError("TopValDeclaringEntity: does not have a parent",x.Range)) - member x.HasTopValActualParent = - match x.ActualParent with + member x.HasDeclaringEntity = + match x.DeclaringEntity with | Parent _ -> true | ParentNone -> false /// Get the apparent parent entity for a member - member x.MemberApparentParent : TyconRef = + member x.MemberApparentEntity : TyconRef = match x.MemberInfo with - | Some membInfo -> membInfo.ApparentParent - | None -> error(InternalError("MemberApparentParent",x.Range)) + | Some membInfo -> membInfo.ApparentEnclosingEntity + | None -> error(InternalError("MemberApparentEntity",x.Range)) /// Get the number of 'this'/'self' object arguments for the member. Instance extension members return '1'. member v.NumObjArgs = @@ -2442,10 +2442,10 @@ and [] /// Get the apparent parent entity for the value, i.e. the entity under with which the /// value is associated. For extension members this is the nominal type the member extends. /// For other values it is just the actual parent. - member x.ApparentParent = + member x.ApparentEnclosingEntity = match x.MemberInfo with - | Some membInfo -> Parent(membInfo.ApparentParent) - | None -> x.ActualParent + | Some membInfo -> Parent(membInfo.ApparentEnclosingEntity) + | None -> x.DeclaringEntity /// Get the public path to the value, if any? Should be set if and only if /// IsMemberOrModuleBinding is set. @@ -2459,7 +2459,7 @@ and [] // - in ilxgen.fs: as a boolean to detect public values for saving quotations // - in MakeExportRemapping, to build non-local references for values member x.PublicPath = - match x.ActualParent with + match x.DeclaringEntity with | Parent eref -> match eref.PublicPath with | None -> None @@ -2587,7 +2587,7 @@ and [] val_member_info = Unchecked.defaultof<_> val_attribs = Unchecked.defaultof<_> val_repr_info = Unchecked.defaultof<_> - val_actual_parent = Unchecked.defaultof<_> + val_declaring_entity = Unchecked.defaultof<_> val_xmldoc = Unchecked.defaultof<_> val_xmldocsig = Unchecked.defaultof<_> } @@ -2613,7 +2613,7 @@ and [] x.val_member_info <- tg.val_member_info x.val_attribs <- tg.val_attribs x.val_repr_info <- tg.val_repr_info - x.val_actual_parent <- tg.val_actual_parent + x.val_declaring_entity <- tg.val_declaring_entity x.val_xmldoc <- tg.val_xmldoc x.val_xmldocsig <- tg.val_xmldocsig @@ -2627,7 +2627,7 @@ and [] ValMemberInfo = { /// The parent type. For an extension member this is the type being extended - ApparentParent: TyconRef + ApparentEnclosingEntity: TyconRef /// Updated with the full implemented slotsig after interface implementation relation is checked mutable ImplementedSlotSigs: SlotSig list @@ -3240,12 +3240,12 @@ and member x.Accessibility = x.Deref.Accessibility /// The parent type or module, if any (None for expression bindings and parameters) - member x.ActualParent = x.Deref.ActualParent + member x.DeclaringEntity = x.Deref.DeclaringEntity /// Get the apparent parent entity for the value, i.e. the entity under with which the /// value is associated. For extension members this is the nominal type the member extends. /// For other values it is just the actual parent. - member x.ApparentParent = x.Deref.ApparentParent + member x.ApparentEnclosingEntity = x.Deref.ApparentEnclosingEntity member x.DefinitionRange = x.Deref.DefinitionRange @@ -3373,13 +3373,13 @@ and /// Get the actual parent entity for the value (a module or a type), i.e. the entity under which the /// value will appear in compiled code. For extension members this is the module where the extension member /// is declared. - member x.TopValActualParent = x.Deref.TopValActualParent + member x.TopValDeclaringEntity = x.Deref.TopValDeclaringEntity // Can be false for members after error recovery - member x.HasTopValActualParent = x.Deref.HasTopValActualParent + member x.HasDeclaringEntity = x.Deref.HasDeclaringEntity /// Get the apparent parent entity for a member - member x.MemberApparentParent = x.Deref.MemberApparentParent + member x.MemberApparentEntity = x.Deref.MemberApparentEntity /// Get the number of 'this'/'self' object arguments for the member. Instance extension members return '1'. member x.NumObjArgs = x.Deref.NumObjArgs @@ -4988,7 +4988,7 @@ let NewVal (logicalName:string,m:range,compiledName,ty,isMutable,isCompGen,arity val_other_range=None val_defn=None val_repr_info= arity - val_actual_parent= actualParent + val_declaring_entity= actualParent val_flags = ValFlags(recValInfo,baseOrThis,isCompGen,inlineInfo,isMutable,isModuleOrMemberBinding,isExtensionMember,isIncrClassSpecialMember,isTyFunc,allowTypeInst,isGeneratedEventVal) val_const= konst val_access=access diff --git a/tests/fsharp/core/members/absil.fsi b/tests/fsharp/core/members/absil.fsi index ed03372264d..02c730d0d86 100644 --- a/tests/fsharp/core/members/absil.fsi +++ b/tests/fsharp/core/members/absil.fsi @@ -274,7 +274,7 @@ open System member FormalCallsig: CallSig member ActualReturnType: Type member ActualArgTypes: List - member ActualParent: TypeRef + member DeclaringEntity: TypeRef member ActualCallsig: CallSig member GenericArity: int diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 392df321eae..826491c8aa9 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -3251,9 +3251,9 @@ let ``Test Project23 property`` () = extensionProps |> Array.collect (fun f -> [| if f.HasGetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.GetterMethod.CompiledName, f.GetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.ApparentEnclosingEntity.FullName, f.GetterMethod.CompiledName, f.GetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.SetterMethod.CompiledName, f.SetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.ApparentEnclosingEntity.FullName, f.SetterMethod.CompiledName, f.SetterMethod.DeclaringEntity.Value.FullName, attribsOfSymbol f) |]) |> Array.toList @@ -3297,9 +3297,9 @@ let ``Test Project23 extension properties' getters/setters should refer to the c match x.Symbol with | :? FSharpMemberOrFunctionOrValue as f -> if f.HasGetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.GetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.GetterMethod.LogicalEnclosingEntity.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.GetterMethod.DeclaringEntity.Value.FullName, f.ApparentEnclosingEntity.FullName, f.GetterMethod.ApparentEnclosingEntity.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.DeclaringEntity.Value.FullName, f.SetterMethod.DeclaringEntity.Value.FullName, f.LogicalEnclosingEntity.FullName, f.SetterMethod.LogicalEnclosingEntity.FullName, attribsOfSymbol f) + yield (f.DeclaringEntity.Value.FullName, f.SetterMethod.DeclaringEntity.Value.FullName, f.ApparentEnclosingEntity.FullName, f.SetterMethod.ApparentEnclosingEntity.FullName, attribsOfSymbol f) | _ -> () |]) |> Array.toList From d972d9d23e9c7911bfb3984ecddcfd7aaab0ace2 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 22 Jan 2018 19:00:03 +0000 Subject: [PATCH 17/17] code review --- fcs/RELEASE_NOTES.md | 2 +- .../FSharp.Compiler.Private/FSComp.fs | 2 +- .../FSharp.Compiler.Private/FSComp.resx | 2 +- src/fsharp/FSComp.txt | 2 +- src/fsharp/MethodOverrides.fs | 1 - src/fsharp/infos.fs | 2 +- src/fsharp/xlf/FSComp.txt.cs.xlf | 4 +- src/fsharp/xlf/FSComp.txt.de.xlf | 4 +- src/fsharp/xlf/FSComp.txt.en.xlf | 4 +- src/fsharp/xlf/FSComp.txt.es.xlf | 4 +- src/fsharp/xlf/FSComp.txt.fr.xlf | 4 +- src/fsharp/xlf/FSComp.txt.it.xlf | 4 +- src/fsharp/xlf/FSComp.txt.ja.xlf | 4 +- src/fsharp/xlf/FSComp.txt.ko.xlf | 4 +- src/fsharp/xlf/FSComp.txt.pl.xlf | 4 +- src/fsharp/xlf/FSComp.txt.pt-BR.xlf | 4 +- src/fsharp/xlf/FSComp.txt.ru.xlf | 4 +- src/fsharp/xlf/FSComp.txt.tr.xlf | 4 +- src/fsharp/xlf/FSComp.txt.zh-Hans.xlf | 4 +- src/fsharp/xlf/FSComp.txt.zh-Hant.xlf | 4 +- tests/fsharp/core/forwarders/a.cs | 2 +- tests/fsharp/core/members/ops-mutrec/test.fs | 2 +- tests/fsharp/core/members/ops/test.fsx | 2 +- tests/fsharp/typecheck/sigs/neg101.bsl | 70 +++++++++---------- .../E_LeftToRightOverloadResolution01.fs | 2 +- 25 files changed, 72 insertions(+), 73 deletions(-) diff --git a/fcs/RELEASE_NOTES.md b/fcs/RELEASE_NOTES.md index 0084a0367d8..8a98636494b 100644 --- a/fcs/RELEASE_NOTES.md +++ b/fcs/RELEASE_NOTES.md @@ -414,7 +414,7 @@ * Return additional 'property' and 'event' methods for F#-defined types to regularize symbols (#108, #143) * Add IsPropertySetterMethod and IsPropertyGetterMethod which only return true for getter/setter methods, not properties. Deprecate IsSetterMethod and IsGetterMethod in favour of these. * Add IsEventAddMethod and IsEventRemoveMethod which return true for add/remove methods with an associated event -* Change IsProperty and IsEvent to only return true for the symbols for properties and events, rather than the methods assocaited with these +* Change IsProperty and IsEvent to only return true for the symbols for properties and events, rather than the methods associated with these * Fix value of Assembly for some symbols (e.g. property symbols) #### 0.0.45 - diff --git a/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs b/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs index 9f35b8006a9..63c331ab68d 100644 --- a/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs +++ b/src/buildfromsource/FSharp.Compiler.Private/FSComp.fs @@ -4300,7 +4300,7 @@ type internal SR private() = /// An error occurred while reading the F# metadata of assembly '%s'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct. /// (Originally from ..\FSComp.txt:1424) static member pickleUnexpectedNonZero(a0 : System.String) = (3219, GetStringFunc("pickleUnexpectedNonZero",",,,%s,,,") a0) - /// This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + /// This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. /// (Originally from ..\FSComp.txt:1425) static member tcTupleMemberNotNormallyUsed() = (3220, GetStringFunc("tcTupleMemberNotNormallyUsed",",,,") ) diff --git a/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx b/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx index 9a392ccdc11..6ea0731264b 100644 --- a/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx +++ b/src/buildfromsource/FSharp.Compiler.Private/FSComp.resx @@ -4304,6 +4304,6 @@ An error occurred while reading the F# metadata of assembly '{0}'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct. - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. \ No newline at end of file diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 3bde50b53d4..2ca518ff532 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1421,4 +1421,4 @@ notAFunctionButMaybeIndexer,"This expression is not a function and cannot be app notAFunctionButMaybeDeclaration,"This value is not a function and cannot be applied. Did you forget to terminate a declaration?" 3218,ArgumentsInSigAndImplMismatch,"The argument names in the signature '%s' and implementation '%s' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling." 3219,pickleUnexpectedNonZero,"An error occurred while reading the F# metadata of assembly '%s'. A reserved construct was utilized. You may need to upgrade your F# compiler or use an earlier version of the assembly that doesn't make use of a specific construct." -3220,tcTupleMemberNotNormallyUsed,"This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead" +3220,tcTupleMemberNotNormallyUsed,"This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead." diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 2b550f89482..fdaab282497 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -161,7 +161,6 @@ module DispatchSlotChecking = | CanImplementNoSlots -> false | CanImplementAnySlot -> true | CanImplementAnyClassHierarchySlot -> not (isInterfaceTy g dispatchSlot.ApparentEnclosingType) - //| CanImplementSpecificInterfaceSlot parentTy -> isInterfaceTy g dispatchSlot.ApparentEnclosingType && typeEquiv g parentTy dispatchSlot.ApparentEnclosingType | CanImplementAnyInterfaceSlot -> isInterfaceTy g dispatchSlot.ApparentEnclosingType) /// Check if the kinds of type parameters match between a dispatch slot and an override. diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 843a7f5d2cb..1a636574fe1 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -2196,7 +2196,7 @@ type ILEventInfo = /// Get the enclosing ("parent"/"declaring") type of the field. member x.ApparentEnclosingType = match x with ILEventInfo(tinfo,_) -> tinfo.ToType - // Note: events are always assocaited with nominal types + // Note: events are always associated with nominal types member x.ApparentEnclosingAppType = x.ApparentEnclosingType // Note: IL Events are never extension members as C# has no notion of extension events as yet diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index 2300e331323..476c099ebdc 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index b093120c4c1..b29c138b025 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.en.xlf b/src/fsharp/xlf/FSComp.txt.en.xlf index 9119d3fd919..9407743447a 100644 --- a/src/fsharp/xlf/FSComp.txt.en.xlf +++ b/src/fsharp/xlf/FSComp.txt.en.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index 235ba8abae7..d8c26154a46 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 3122a4e5ccf..198262498dd 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index caedc58314e..dfd630f6928 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index 42f66abfd41..e2d550f93ba 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index e1734109750..db7e9de8dfd 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index e5c01ff07f9..51e36c34c88 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index a1a075168cb..de3c1d8bc37 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index 39ca0e5bc08..bd4e2fefc18 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index ccf9ab664c0..0519a565c19 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 2e4506f4303..9a280a52579 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 6498d8bb3bf..d051d6988f8 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -6968,8 +6968,8 @@ - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead - This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. + This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. diff --git a/tests/fsharp/core/forwarders/a.cs b/tests/fsharp/core/forwarders/a.cs index 0f6180fe635..0299620719a 100644 --- a/tests/fsharp/core/forwarders/a.cs +++ b/tests/fsharp/core/forwarders/a.cs @@ -9,7 +9,7 @@ // 4. From F#, reference both the _split_ DLLs and the original b.dll and the original c.dll // and use a mix of types and functions from a.dll, b.dll and c.dll // -// The aim is to shake out type identity issues assocaited with type forwarders. +// The aim is to shake out type identity issues associated with type forwarders. #if PART1 public class C diff --git a/tests/fsharp/core/members/ops-mutrec/test.fs b/tests/fsharp/core/members/ops-mutrec/test.fs index 1fa82e5c373..a6605a5dbae 100644 --- a/tests/fsharp/core/members/ops-mutrec/test.fs +++ b/tests/fsharp/core/members/ops-mutrec/test.fs @@ -121,7 +121,7 @@ module OverloadSamples = type 'a GenericVector with - // Nb. For an operator assocaited with a generic type + // Nb. For an operator associated with a generic type // the the type parameters involved in the operator's definition must be the same // as the type parameters of the enclosing class. static member (+) ((x : 'a GenericVector),(y : 'a GenericVector)) = add x y diff --git a/tests/fsharp/core/members/ops/test.fsx b/tests/fsharp/core/members/ops/test.fsx index d4756db4233..677b7f60f88 100644 --- a/tests/fsharp/core/members/ops/test.fsx +++ b/tests/fsharp/core/members/ops/test.fsx @@ -126,7 +126,7 @@ module OverloadSamples = type 'a GenericVector with - // Nb. For an operator assocaited with a generic type + // Nb. For an operator associated with a generic type // the the type parameters involved in the operator's definition must be the same // as the type parameters of the enclosing class. static member (+) ((x : 'a GenericVector),(y : 'a GenericVector)) = add x y diff --git a/tests/fsharp/typecheck/sigs/neg101.bsl b/tests/fsharp/typecheck/sigs/neg101.bsl index fedfd09ffcd..84e53b5e6ab 100644 --- a/tests/fsharp/typecheck/sigs/neg101.bsl +++ b/tests/fsharp/typecheck/sigs/neg101.bsl @@ -1,74 +1,74 @@ neg101.fs(7,11,7,14): typecheck error FS0039: The field, constructor or member 'Foo' is not defined. -neg101.fs(14,6,14,17): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(14,6,14,17): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(15,6,15,17): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(15,6,15,17): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(16,6,16,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(16,6,16,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(17,6,17,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(17,6,17,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(18,6,18,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(18,6,18,19): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(19,6,19,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(19,6,19,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(20,6,20,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(20,6,20,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(21,6,21,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(21,6,21,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(22,6,22,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(22,6,22,21): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(23,6,23,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(23,6,23,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(24,6,24,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(24,6,24,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(25,6,25,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(25,6,25,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(26,6,26,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(26,6,26,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(27,6,27,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(27,6,27,23): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(28,6,28,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(28,6,28,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(29,6,29,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(29,6,29,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(30,6,30,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(30,6,30,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(31,6,31,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(31,6,31,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(32,6,32,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(32,6,32,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(33,6,33,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(33,6,33,25): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(34,6,34,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(34,6,34,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(35,6,35,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(35,6,35,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(36,6,36,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(36,6,36,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(37,6,37,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(37,6,37,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(38,6,38,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(38,6,38,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(39,6,39,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(39,6,39,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(40,6,40,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(40,6,40,27): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(41,6,41,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(41,6,41,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(42,6,42,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(42,6,42,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(43,6,43,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(43,6,43,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(44,6,44,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(44,6,44,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(45,6,45,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(45,6,45,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(46,6,46,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(46,6,46,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(47,6,47,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(47,6,47,29): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. -neg101.fs(49,10,49,32): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead +neg101.fs(49,10,49,32): typecheck error FS3220: This method or property is not normally used from F# code, use an explicit tuple pattern for deconstruction instead. neg101.fs(50,16,50,20): typecheck error FS0039: The field, constructor or member 'Rest' is not defined. diff --git a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/E_LeftToRightOverloadResolution01.fs b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/E_LeftToRightOverloadResolution01.fs index 9a89174ac7f..49f17817d17 100644 --- a/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/E_LeftToRightOverloadResolution01.fs +++ b/tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/E_LeftToRightOverloadResolution01.fs @@ -1,6 +1,6 @@ // #Regression #TypeInference // Regression for FSHARP1.0:5749 -// Better error message for overload resolution to help ease pain assocaited with mismatch of intellisense information +// Better error message for overload resolution to help ease pain associated with mismatch of intellisense information let array = [| "Ted"; "Katie"; |]