Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2302b9e

Browse files
dsymelatkin
authored andcommitted
Allow inheritance of types that have multiple interface instantiations
closesdotnet#18commit b4460b501112836f0ed9c10abb2ab267cea5769fAuthor: latkin <latkin@microsoft.com>Date: Mon Jan 19 10:54:36 2015 -0800 Reverting change to test.lst filecommit 29ea1b495070913ba7c723ba10d487cfc645e297Merge:0b209163f7d322Author: latkin <latkin@microsoft.com>Date: Fri Jan 16 18:12:11 2015 -0800 Merge branch 'multi-intf' ofhttps://github.com/dsyme/visualfsharp into dsyme-multi-intfcommit3f7d322Author: Don Syme <dsyme@microsoft.com>Date: Fri Jan 16 11:15:13 2015 +0000 adjust for more thorough fsharpqa test runs for multiple interfacescommit6d90572Merge:e532a14481890dAuthor: Don Syme <dsyme@microsoft.com>Date: Fri Jan 16 09:02:43 2015 +0000 Merge branch 'fsharp4' ofhttp://github.com/Microsoft/visualfsharp into multi-intfcommite532a14Author: Don Syme <dsyme@microsoft.com>Date: Thu Jan 15 15:09:07 2015 +0000 fix bug exposed by tests (2)commit12ea9f8Author: Don Syme <dsyme@microsoft.com>Date: Thu Jan 15 15:07:31 2015 +0000 fix bug exposed by testscommit1d9928dMerge:e65539551d7b62Author: Don Syme <dsyme@microsoft.com>Date: Thu Jan 15 14:54:25 2015 +0000 Merge branch 'fsharp4' ofhttps://git01.codeplex.com/visualfsharp into multi-intfcommite655395Author: Don Syme <dsyme@microsoft.com>Date: Wed Sep 17 16:54:04 2014 +0100 update tests for multiple instantiations of interfacescommit4adb2ddAuthor: Don Syme <dsyme@microsoft.com>Date: Tue Sep 16 17:45:21 2014 +0100 Allow inheritance of types that have multiple interface instantiations
1 parent0b20916 commit2302b9e

File tree

20 files changed

+119
-43
lines changed

20 files changed

+119
-43
lines changed

‎src/fsharp/FSComp.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ chkUnionCaseDefaultAugmentation,"default augmentation of the union case"
290290
441,chkDuplicatePropertyWithSuffix,"Duplicate property. The property '%s' has the same name and signature as another property in this type once tuples, functions, units of measure and/or provided types are erased."
291291
442,chkDuplicateMethodInheritedType,"Duplicate method. The abstract method '%s' has the same name and signature as an abstract method in an inherited type."
292292
442,chkDuplicateMethodInheritedTypeWithSuffix,"Duplicate method. The abstract method '%s' has the same name and signature as an abstract method in an inherited type once tuples, functions, units of measure and/or provided types are erased."
293-
443,chkMultipleGenericInterfaceInstantiations,"This type implementsor inheritsthe same interface at different generic instantiations '%s' and '%s'. This is not permitted in this version of F#."
293+
443,chkMultipleGenericInterfaceInstantiations,"This type implements the same interface at different generic instantiations '%s' and '%s'. This is not permitted in this version of F#."
294294
444,chkValueWithDefaultValueMustHaveDefaultValue,"The type of a field using the 'DefaultValue' attribute must admit default initialization, i.e. have 'null' as a proper value or be a struct type whose fields all admit default initialization. You can use 'DefaultValue(false)' to disable this check"
295295
445,chkNoByrefInTypeAbbrev,"The type abbreviation contains byrefs. This is not permitted by F#."
296296
# -----------------------------------------------------------------------------

‎src/fsharp/NicePrint.fs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,8 +1390,7 @@ module private TastDefinitionPrinting =
13901390
GetImmediateInterfacesOfType g amap m ty|> List.map(fun ity-> wordL(if isInterfaceTy g tythen"inherit"else"interface")--- layoutType denv ity)
13911391

13921392
letprops=
1393-
//GetImmediateIntrinsicPropInfosOfType (None,ad) g amap m ty
1394-
GetIntrinsicPropInfosOfType infoReader(None,ad,AllowMultiIntfInstantiations.No) PreferOverrides m ty
1393+
GetIntrinsicPropInfosOfType infoReader(None,ad,AllowMultiIntfInstantiations.Yes) PreferOverrides m ty
13951394

13961395
letevents=
13971396
infoReader.GetEventInfosOfType(None,ad,m,ty)

‎src/fsharp/check.fs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,10 @@ and CheckExprInContext (cenv:cenv) (env:env) expr (context:ByrefCallContext) =
490490
CheckInterfaceImpls cenv env basev iimpls;
491491
CheckTypePermitByrefs cenv m typ
492492
letinterfaces=
493-
[yield! AllSuperTypesOfType cenv.g cenv.amap m AllowMultiIntfInstantiations.Yes typ
493+
[if isInterfaceTy cenv.g typthen
494+
yield! AllSuperTypesOfType cenv.g cenv.amap m AllowMultiIntfInstantiations.Yes typ
494495
for(ty,_)in iimplsdo
495-
yield! AllSuperTypesOfType cenv.g cenv.amap m AllowMultiIntfInstantiations.Yes ty]
496+
yield! AllSuperTypesOfType cenv.g cenv.amap m AllowMultiIntfInstantiations.Yes ty]
496497
|> List.filter(isInterfaceTy cenv.g)
497498
CheckMultipleInterfaceInstantiations cenv interfaces m
498499

@@ -1367,6 +1368,11 @@ let CheckEntityDefn cenv env (tycon:Entity) =
13671368

13681369
if cenv.reportErrorsthen
13691370
ifnot tycon.IsTypeAbbrevthen
1371+
lettyp= generalizedTyconRef(mkLocalTyconRef tycon)
1372+
letimmediateInterfaces= GetImmediateInterfacesOfType cenv.g cenv.amap m typ
1373+
letinterfaces=
1374+
[for tyin immediateInterfacesdo
1375+
yield! AllSuperTypesOfType cenv.g cenv.amap m AllowMultiIntfInstantiations.Yes ty]
13701376
CheckMultipleInterfaceInstantiations cenv interfaces m
13711377

13721378
// Check struct fields. We check these late because we have to have first checked that the structs are

‎src/fsharp/infos.fs‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ let ExistsInEntireHierarchyOfType f g amap m allowMultiIntfInst typ =
215215

216216
/// Search for one element where a function returns a 'Some' result, following interfaces
217217
letSearchEntireHierarchyOfType f g amap m typ=
218-
FoldHierarchyOfTypeAuxtrue AllowMultiIntfInstantiations.No
218+
FoldHierarchyOfTypeAuxtrue AllowMultiIntfInstantiations.Yes
219219
(fun ty acc->
220220
match accwith
221221
| None->if f tythen Some(ty)else None
@@ -243,11 +243,11 @@ let HasHeadType g tcref ty2 =
243243

244244
/// Check if a type exists somewhere in the hierarchy which has the same head type as the given type (note, the given type need not have a head type at all)
245245
letExistsSameHeadTypeInHierarchy g amap m typeToSearchFrom typeToLookFor=
246-
ExistsInEntireHierarchyOfType(HaveSameHeadType g typeToLookFor) g amap m AllowMultiIntfInstantiations.No typeToSearchFrom
246+
ExistsInEntireHierarchyOfType(HaveSameHeadType g typeToLookFor) g amap m AllowMultiIntfInstantiations.Yes typeToSearchFrom
247247

248248
/// Check if a type exists somewhere in the hierarchy which has the given head type.
249249
letExistsHeadTypeInEntireHierarchy g amap m typeToSearchFrom tcrefToLookFor=
250-
ExistsInEntireHierarchyOfType(HasHeadType g tcrefToLookFor) g amap m AllowMultiIntfInstantiations.No typeToSearchFrom
250+
ExistsInEntireHierarchyOfType(HasHeadType g tcrefToLookFor) g amap m AllowMultiIntfInstantiations.Yes typeToSearchFrom
251251

252252

253253
/// Read an Abstract IL type from metadata and convert to an F# type.
@@ -3127,13 +3127,13 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) =
31273127
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicPropInfosOfType(optFilter,ad) g amap m typ:: acc) g amap m allowMultiIntfInst typ[]
31283128

31293129
letGetIntrinsicILFieldInfosUncached((optFilter,ad),m,typ)=
3130-
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicILFieldsOfType(optFilter,ad) m typ@ acc) g amap m AllowMultiIntfInstantiations.No typ[]
3130+
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicILFieldsOfType(optFilter,ad) m typ@ acc) g amap m AllowMultiIntfInstantiations.Yes typ[]
31313131

31323132
letGetIntrinsicEventInfosUncached((optFilter,ad),m,typ)=
3133-
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicEventsOfType(optFilter,ad) m typ@ acc) g amap m AllowMultiIntfInstantiations.No typ[]
3133+
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicEventsOfType(optFilter,ad) m typ@ acc) g amap m AllowMultiIntfInstantiations.Yes typ[]
31343134

31353135
letGetIntrinsicRecdOrClassFieldInfosUncached((optFilter,ad),m,typ)=
3136-
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicRecdOrClassFieldsOfType(optFilter,ad) m typ@ acc) g amap m AllowMultiIntfInstantiations.No typ[]
3136+
FoldPrimaryHierarchyOfType(fun typ acc-> GetImmediateIntrinsicRecdOrClassFieldsOfType(optFilter,ad) m typ@ acc) g amap m AllowMultiIntfInstantiations.Yes typ[]
31373137

31383138
letGetEntireTypeHierachyUncached(allowMultiIntfInst,m,typ)=
31393139
FoldEntireHierarchyOfType(fun typ acc-> typ:: acc) g amap m allowMultiIntfInst typ[]
@@ -3164,7 +3164,7 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) =
31643164
|_-> failwith"Unexpected multiple fields with the same name"// Because an explicit name (i.e., nm) was supplied, there will be only one element at most.
31653165
|_-> acc)
31663166
g amap m
3167-
AllowMultiIntfInstantiations.No
3167+
AllowMultiIntfInstantiations.Yes
31683168
typ
31693169
None
31703170

@@ -3506,12 +3506,12 @@ let TryFindIntrinsicNamedItemOfType (infoReader:InfoReader) (nm,ad) findFlag m t
35063506
/// -- getting the Dispose method when resolving the 'use' construct
35073507
/// -- getting the various methods used to desugar the computation expression syntax
35083508
letTryFindIntrinsicMethInfo infoReader m ad nm ty=
3509-
GetIntrinsicMethInfosOfType infoReader(Some nm,ad,AllowMultiIntfInstantiations.No) IgnoreOverrides m ty
3509+
GetIntrinsicMethInfosOfType infoReader(Some nm,ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides m ty
35103510

35113511
/// Try to find a particular named property on a type. Only used to ensure that local 'let' definitions and property names
35123512
/// are distinct, a somewhat adhoc check in tc.fs.
35133513
letTryFindPropInfo infoReader m ad nm ty=
3514-
GetIntrinsicPropInfosOfType infoReader(Some nm,ad,AllowMultiIntfInstantiations.No) IgnoreOverrides m ty
3514+
GetIntrinsicPropInfosOfType infoReader(Some nm,ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides m ty
35153515

35163516
//-------------------------------------------------------------------------
35173517
// Helpers related to delegates and events
@@ -3528,7 +3528,7 @@ let GetSigOfFunctionForDelegate (infoReader:InfoReader) delty m ad =
35283528
letg= infoReader.g
35293529
letamap= infoReader.amap
35303530
letinvokeMethInfo=
3531-
match GetIntrinsicMethInfosOfType infoReader(Some"Invoke",ad,AllowMultiIntfInstantiations.No) IgnoreOverrides m deltywith
3531+
match GetIntrinsicMethInfosOfType infoReader(Some"Invoke",ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides m deltywith
35323532
|[h]-> h
35333533
|[]-> error(Error(FSComp.SR.noInvokeMethodsFound(),m))
35343534
| h::_-> warning(InternalError(FSComp.SR.moreThanOneInvokeMethodFound(),m)); h

‎src/fsharp/nameres.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ let MakeNestedType (ncenv:NameResolver) (tinst:TType list) m (tcrefNested:TyconR
10301030
/// Get all the accessible nested types of an existing type.
10311031
letGetNestedTypesOfType(ad,ncenv:NameResolver,optFilter,staticResInfo,checkForGenerated,m)typ=
10321032
letg= ncenv.g
1033-
ncenv.InfoReader.GetPrimaryTypeHierachy(AllowMultiIntfInstantiations.No,m,typ)|> List.collect(fun typ->
1033+
ncenv.InfoReader.GetPrimaryTypeHierachy(AllowMultiIntfInstantiations.Yes,m,typ)|> List.collect(fun typ->
10341034
if isAppTy g typthen
10351035
lettcref,tinst= destAppTy g typ
10361036
lettycon= tcref.Deref
@@ -1372,7 +1372,7 @@ let ResolveObjectConstructor (ncenv:NameResolver) edenv m ad typ =
13721372
letIntrinsicPropInfosOfTypeInScope(infoReader:InfoReader)(optFilter,ad)findFlag m typ=
13731373
letg= infoReader.g
13741374
letamap= infoReader.amap
1375-
letpinfos= GetIntrinsicPropInfoSetsOfType infoReader(optFilter, ad, AllowMultiIntfInstantiations.No) findFlag m typ
1375+
letpinfos= GetIntrinsicPropInfoSetsOfType infoReader(optFilter, ad, AllowMultiIntfInstantiations.Yes) findFlag m typ
13761376
letpinfos= pinfos|> ExcludeHiddenOfPropInfos g amap m
13771377
pinfos
13781378

@@ -1400,7 +1400,7 @@ let ExtensionPropInfosOfTypeInScope (infoReader:InfoReader) (nenv: NameResolutio
14001400
letg= infoReader.g
14011401

14021402
letextMemsFromHierarchy=
1403-
infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.No,m,typ)|> List.collect(fun typ->
1403+
infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,typ)|> List.collect(fun typ->
14041404
if(isAppTy g typ)then
14051405
lettcref= tcrefOfAppTy g typ
14061406
letextMemInfos= nenv.eIndexedExtensionMembers.Find tcref
@@ -1462,7 +1462,7 @@ let SelectMethInfosFromExtMembers (infoReader:InfoReader) optFilter apparentTy m
14621462
letExtensionMethInfosOfTypeInScope(infoReader:InfoReader)(nenv:NameResolutionEnv)optFilter m typ=
14631463
letextMemsDangling= SelectMethInfosFromExtMembers infoReader optFilter typ m nenv.eUnindexedExtensionMembers
14641464
letextMemsFromHierarchy=
1465-
infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.No,m,typ)|> List.collect(fun typ->
1465+
infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes,m,typ)|> List.collect(fun typ->
14661466
letg= infoReader.g
14671467
if(isAppTy g typ)then
14681468
lettcref= tcrefOfAppTy g typ
@@ -1473,7 +1473,7 @@ let ExtensionMethInfosOfTypeInScope (infoReader:InfoReader) (nenv: NameResolutio
14731473

14741474
/// Get all the available methods of a type (both intrinsic and extension)
14751475
letAllMethInfosOfTypeInScope infoReader nenv(optFilter,ad)findFlag m typ=
1476-
IntrinsicMethInfosOfType infoReader(optFilter,ad,AllowMultiIntfInstantiations.No) findFlag m typ
1476+
IntrinsicMethInfosOfType infoReader(optFilter,ad,AllowMultiIntfInstantiations.Yes) findFlag m typ
14771477
@ ExtensionMethInfosOfTypeInScope infoReader nenv optFilter m typ
14781478

14791479

‎src/fsharp/tastops.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ type TyconRefMultiMap<'T>(contents: TyconRefMap<'T list>) =
12461246
memberm.Find v=if contents.ContainsKey vthen contents.[v]else[]
12471247
memberm.Add(v,x)= TyconRefMultiMap<'T>(contents.Add v(x:: m.Find v))
12481248
static memberEmpty= TyconRefMultiMap<'T>(TyconRefMap<_>.Empty)
1249+
static memberOfList vs=(vs, TyconRefMultiMap<'T>.Empty)||> List.foldBack(fun(x,y)acc-> acc.Add(x, y))
12491250

12501251

12511252
//--------------------------------------------------------------------------

‎src/fsharp/tastops.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ type TyconRefMultiMap<'T> =
279279
memberFind:TyconRef->'T list
280280
memberAdd:TyconRef* 'T-> TyconRefMultiMap<'T>
281281
static member Empty: TyconRefMultiMap<'T>
282+
static member OfList:(TyconRef* 'T) list-> TyconRefMultiMap<'T>
282283

283284

284285
//-------------------------------------------------------------------------

‎src/fsharp/tc.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ let IsSecurityAttribute g amap (casmap : Dictionary<Stamp,bool>) (Attrib(tcref,_
121121
if casmap.ContainsKey(tcs) then
122122
casmap.[tcs]
123123
else
124-
let exists = ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkAppTy attr.TyconRef [])) g amap m AllowMultiIntfInstantiations.No (mkAppTy tcref [])
124+
let exists = ExistsInEntireHierarchyOfType (fun t -> typeEquiv g t (mkAppTy attr.TyconRef [])) g amap m AllowMultiIntfInstantiations.Yes (mkAppTy tcref [])
125125
casmap.[tcs] <- exists
126126
exists
127127
| _ -> false
@@ -5639,7 +5639,7 @@ and TcIndexerThen cenv env overallTy mWholeExpr mDot tpenv wholeExpr e1 indexArg
56395639
cenv.g
56405640
cenv.amap
56415641
mWholeExpr
5642-
AllowMultiIntfInstantiations.No
5642+
AllowMultiIntfInstantiations.Yes
56435643
e1ty
56445644
None
56455645
| _ -> Some "GetSlice"
@@ -14225,7 +14225,7 @@ module EstablishTypeDefinitionCores = begin
1422514225
// validate ConditionalAttribute, should it be applied (it's only valid on a type if the type is an attribute type)
1422614226
match attrs |> List.tryFind (IsMatchingFSharpAttribute cenv.g cenv.g.attrib_ConditionalAttribute) with
1422714227
| Some _ ->
14228-
if not(ExistsInEntireHierarchyOfType (fun t -> typeEquiv cenv.g t (mkAppTy cenv.g.tcref_System_Attribute [])) cenv.g cenv.amap m AllowMultiIntfInstantiations.No thisTy) then
14228+
if not(ExistsInEntireHierarchyOfType (fun t -> typeEquiv cenv.g t (mkAppTy cenv.g.tcref_System_Attribute [])) cenv.g cenv.amap m AllowMultiIntfInstantiations.Yes thisTy) then
1422914229
errorR(Error(FSComp.SR.tcConditionalAttributeUsage(),m))
1423014230
| _ -> ()
1423114231

‎src/fsharp/typrelns.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ module DispatchSlotChecking =
12821282
// This contains the list of required members and the list of available members
12831283
[for(_,reqdTy,reqdTyRange,impliedTys)in reqdTyInfosdo
12841284

1285-
// Build atable of the implied interface types, for quicker lookup
1285+
// Build aset of the implied interface types, for quicker lookup, by nominal type
12861286
letisImpliedInterfaceTable=
12871287
impliedTys
12881288
|> List.filter(isInterfaceTy g)
@@ -1721,7 +1721,7 @@ type CalledMeth<'T>
17211721
letreturnedObjTy=if minfo.IsConstructorthen minfo.EnclosingTypeelse methodRetTy
17221722
unassignedNamedItem|> List.splitChoose(fun(CallerNamedArg(id,e)asarg)->
17231723
letnm= id.idText
1724-
letpinfos= GetIntrinsicPropInfoSetsOfType infoReader(Some(nm),ad,AllowMultiIntfInstantiations.No) IgnoreOverrides id.idRange returnedObjTy
1724+
letpinfos= GetIntrinsicPropInfoSetsOfType infoReader(Some(nm),ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides id.idRange returnedObjTy
17251725
letpinfos= pinfos|> ExcludeHiddenOfPropInfos g infoReader.amap m
17261726
match pinfoswith
17271727
|[pinfo]when pinfo.HasSetter&&not pinfo.IsIndexer->

‎tests/fsharpqa/Source/Conformance/BasicTypeAndModuleDefinitions/GeneratedEqualityHashingComparison/Attributes/New/Test06.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #Regression #Conformance #TypesAndModules #GeneratedEqualityAndHashing #Attributes
2-
//<Expects status="error" span="(9,8-9,9)">This type uses an invalid mix of the attributes 'NoEquality', 'ReferenceEquality', 'StructuralEquality', 'NoComparison' and 'StructuralComparison' attributes$</Expects>
2+
//<Expects status="error" span="(9,8-9,9)">This type uses an invalid mix of the attributes 'NoEquality', 'ReferenceEquality', 'StructuralEquality', 'NoComparison' and 'StructuralComparison'$</Expects>
33
//<Expects status="error" span="(9,8-9,9)" id="FS0385">A type with attribute 'CustomComparison' must have an explicit implementation of at least one of 'System\.IComparable' or 'System\.Collections\.IStructuralComparable'$</Expects>
44

55
moduleM06=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp