diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 05ce83c5f6b..df9037a8d47 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -1268,20 +1268,17 @@ module MutRecBindingChecking = let prelimRecValues = [ for x in defnAs do match x with Phase2AMember bind -> yield bind.RecBindingInfo.Val | _ -> () ] let tyconOpt = - if cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired) then - tyconOpt - |> Option.map (fun tycon -> - tryAddExtensionAttributeIfNotAlreadyPresentForType - g - (fun tryFindExtensionAttribute -> - tycon.MembersOfFSharpTyconSorted - |> Seq.tryPick (fun m -> tryFindExtensionAttribute m.Attribs) - ) - envForTycon.eModuleOrNamespaceTypeAccumulator - tycon - ) - else - tyconOpt + tyconOpt + |> Option.map (fun tycon -> + tryAddExtensionAttributeIfNotAlreadyPresentForType + g + (fun tryFindExtensionAttribute -> + tycon.MembersOfFSharpTyconSorted + |> Seq.tryPick (fun m -> tryFindExtensionAttribute m.Attribs) + ) + envForTycon.eModuleOrNamespaceTypeAccumulator + tycon + ) let defnAs = MutRecShape.Tycon(TyconBindingsPhase2A(tyconOpt, declKind, prelimRecValues, tcref, copyOfTyconTypars, thisTy, defnAs)) defnAs, (tpenv, recBindIdx, uncheckedBindsRev)) @@ -1503,22 +1500,17 @@ module MutRecBindingChecking = Phase2BMember rbind.RecBindingInfo.Index, innerState) let tyconOpt = - if not(cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired)) then - tyconOpt - else - // We need to redo this check, which already happened in TcMutRecBindings_Phase2A_CreateRecursiveValuesAndCheckArgumentPatterns - // Because the environment is being reset in the case of recursive modules. - tyconOpt - |> Option.map (fun tycon -> - tryAddExtensionAttributeIfNotAlreadyPresentForType - g - (fun tryFindExtensionAttribute -> - tycon.MembersOfFSharpTyconSorted - |> Seq.tryPick (fun m -> tryFindExtensionAttribute m.Attribs) - ) - envForTycon.eModuleOrNamespaceTypeAccumulator - tycon - ) + tyconOpt + |> Option.map (fun tycon -> + tryAddExtensionAttributeIfNotAlreadyPresentForType + g + (fun tryFindExtensionAttribute -> + tycon.MembersOfFSharpTyconSorted + |> Seq.tryPick (fun m -> tryFindExtensionAttribute m.Attribs) + ) + envForTycon.eModuleOrNamespaceTypeAccumulator + tycon + ) let defnBs = MutRecShape.Tycon (TyconBindingsPhase2B(tyconOpt, tcref, defnBs)) let outerState = (tpenv, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable, envNonRec) @@ -5039,52 +5031,33 @@ module TcDeclarations = let withBindings, envFinal = TcMutRecDefns_Phase2 cenv envInitial m scopem mutRecNSInfo envMutRecPrelimWithReprs withEnvs isMutRec let withBindings = - if cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired) then - // If any of the types has a member with the System.Runtime.CompilerServices.ExtensionAttribute, - // or a recursive module has a binding with the System.Runtime.CompilerServices.ExtensionAttribute, - // that type/recursive module should also received the ExtensionAttribute if it is not yet present. - // Example: - // open System.Runtime.CompilerServices - // - // type Int32Extensions = - // [] - // static member PlusOne (a:int) : int = a + 1 - // - // or - // - // module rec Foo - // - // [] - // let PlusOne (a:int) = a + 1 - withBindings - |> List.map (function - | MutRecShape.Tycon (Some tycon, bindings) -> - let tycon = - tryAddExtensionAttributeIfNotAlreadyPresentForType - g - (fun tryFindExtensionAttribute -> - tycon.MembersOfFSharpTyconSorted - |> Seq.tryPick (fun m -> tryFindExtensionAttribute m.Attribs) - ) - envFinal.eModuleOrNamespaceTypeAccumulator - tycon - - MutRecShape.Tycon (Some tycon, bindings) - | MutRecShape.Module ((MutRecDefnsPhase2DataForModule(moduleOrNamespaceType, entity), env), shapes) -> - let entity = - tryAddExtensionAttributeIfNotAlreadyPresentForModule - g - (fun tryFindExtensionAttribute -> - moduleOrNamespaceType.Value.AllValsAndMembers - |> Seq.filter(fun v -> v.IsModuleBinding) - |> Seq.tryPick (fun v -> tryFindExtensionAttribute v.Attribs) - ) - entity - - MutRecShape.Module ((MutRecDefnsPhase2DataForModule(moduleOrNamespaceType, entity), env), shapes) - | shape -> shape) - else - withBindings + withBindings + |> List.map (function + | MutRecShape.Tycon (Some tycon, bindings) -> + let tycon = + tryAddExtensionAttributeIfNotAlreadyPresentForType + g + (fun tryFindExtensionAttribute -> + tycon.MembersOfFSharpTyconSorted + |> Seq.tryPick (fun m -> tryFindExtensionAttribute m.Attribs) + ) + envFinal.eModuleOrNamespaceTypeAccumulator + tycon + + MutRecShape.Tycon (Some tycon, bindings) + | MutRecShape.Module ((MutRecDefnsPhase2DataForModule(moduleOrNamespaceType, entity), env), shapes) -> + let entity = + tryAddExtensionAttributeIfNotAlreadyPresentForModule + g + (fun tryFindExtensionAttribute -> + moduleOrNamespaceType.Value.AllValsAndMembers + |> Seq.filter(fun v -> v.IsModuleBinding) + |> Seq.tryPick (fun v -> tryFindExtensionAttribute v.Attribs) + ) + entity + + MutRecShape.Module ((MutRecDefnsPhase2DataForModule(moduleOrNamespaceType, entity), env), shapes) + | shape -> shape) // Generate the hash/compare/equality bindings for all tycons. // @@ -5198,25 +5171,20 @@ module TcDeclarations = let envForTycon = MakeInnerEnvForTyconRef envForTycon tcref (declKind = ExtrinsicExtensionBinding) let vals, env = TcTyconMemberSpecs cenv envForTycon (TyconContainerInfo(innerParent, tcref, declaredTyconTypars, NoSafeInitInfo)) declKind tpenv members - if not(cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired)) then - vals, env - else - // Check if any of the vals has the `[]` attribute - // If this is the case, add it to the type in the env. - let extensionAttributeOnVals = - vals - |> List.tryPick (fun v -> tryFindExtensionAttribute g v.Attribs) - - let typeEntity = - envForTycon.eModuleOrNamespaceTypeAccumulator.Value.AllEntitiesByLogicalMangledName.TryFind(tcref.LogicalName) - - match extensionAttributeOnVals, typeEntity with - | Some extensionAttribute, Some typeEntity -> - if Option.isNone (tryFindExtensionAttribute g typeEntity.Attribs) then - typeEntity.entity_attribs <- typeEntity.EntityAttribs.Add(extensionAttribute, WellKnownEntityAttributes.ExtensionAttribute) - | _ -> () + let extensionAttributeOnVals = + vals + |> List.tryPick (fun v -> tryFindExtensionAttribute g v.Attribs) + + let typeEntity = + envForTycon.eModuleOrNamespaceTypeAccumulator.Value.AllEntitiesByLogicalMangledName.TryFind(tcref.LogicalName) - vals, env + match extensionAttributeOnVals, typeEntity with + | Some extensionAttribute, Some typeEntity -> + if Option.isNone (tryFindExtensionAttribute g typeEntity.Attribs) then + typeEntity.entity_attribs <- typeEntity.EntityAttribs.Add(extensionAttribute, WellKnownEntityAttributes.ExtensionAttribute) + | _ -> () + + vals, env ) // Do this for each 'val' declaration in a module @@ -5850,28 +5818,18 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem moduleEntity.entity_modul_type <- MaybeLazy.Strict moduleTyAcc.Value let moduleEntity = - if cenv.g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired) then - // If any of the let bindings inside the module has the System.Runtime.CompilerServices.ExtensionAttribute, - // that module should also received the ExtensionAttribute if it is not yet present. - // Example: - // module Foo - // - //[] - //let PlusOne (a:int) = a + 1 - tryAddExtensionAttributeIfNotAlreadyPresentForModule - g - (fun tryFindExtensionAttribute -> - match moduleContents with - | ModuleOrNamespaceContents.TMDefs(defs) -> - defs - |> Seq.tryPick (function - | ModuleOrNamespaceContents.TMDefLet (Binding.TBind(var = v),_) -> - tryFindExtensionAttribute v.Attribs - | _ -> None) - | _ -> None - ) - moduleEntity - else + tryAddExtensionAttributeIfNotAlreadyPresentForModule + g + (fun tryFindExtensionAttribute -> + match moduleContents with + | ModuleOrNamespaceContents.TMDefs(defs) -> + defs + |> Seq.tryPick (function + | ModuleOrNamespaceContents.TMDefLet (Binding.TBind(var = v),_) -> + tryFindExtensionAttribute v.Attribs + | _ -> None) + | _ -> None + ) moduleEntity let moduleDef = TMDefRec(false, [], [], [ModuleOrNamespaceBinding.Module(moduleEntity, moduleContents)], m) diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 556f3077da9..000ce348fee 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -658,8 +658,6 @@ let private GetCSharpStyleIndexedExtensionMembersForTyconRef (amap: Import.Impor let isApplicable = IsTyconRefUsedForCSharpStyleExtensionMembers g tcrefOfStaticClass || - - g.langVersion.SupportsFeature(LanguageFeature.CSharpExtensionAttributeNotRequired) && tcrefOfStaticClass.IsLocalRef && not tcrefOfStaticClass.IsTypeAbbrev diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 1fa6ba59402..2ac12b88395 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1554,7 +1554,6 @@ featureFromEndSlicing,"from-end slicing" featureNullnessChecking,"nullness checking" featureRuntimeAsync,"runtime async" featureWitnessPassing,"witness passing for trait constraints in F# quotations" -featureCSharpExtensionAttributeNotRequired,"Allow implicit Extension attribute on declaring types, modules" featurePreferExtensionMethodOverPlainProperty,"prefer extension method over plain property" featureWarningIndexedPropertiesGetSetSameType,"Indexed properties getter and setter must have the same type" featureChkTailCallAttrOnNonRec,"Raises warnings if the 'TailCall' attribute is used on non-recursive functions." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 0a34624112e..bd810e4364d 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -21,7 +21,6 @@ type LanguageFeature = | WitnessPassing | NullnessChecking | UnionIsPropertiesVisible - | CSharpExtensionAttributeNotRequired | UnmanagedConstraintCsharpInterop | ReuseSameFieldsInStructUnions | PreferExtensionMethodOverPlainProperty @@ -110,9 +109,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) // F# 5.0 LanguageFeature.WitnessPassing, languageVersion50 - // F# 8.0 - LanguageFeature.CSharpExtensionAttributeNotRequired, languageVersion80 - // F# 9.0 LanguageFeature.NullnessChecking, languageVersion90 LanguageFeature.ReuseSameFieldsInStructUnions, languageVersion90 @@ -267,7 +263,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) | LanguageFeature.RuntimeAsync -> FSComp.SR.featureRuntimeAsync () | LanguageFeature.WitnessPassing -> FSComp.SR.featureWitnessPassing () | LanguageFeature.UnionIsPropertiesVisible -> FSComp.SR.featureUnionIsPropertiesVisible () - | LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired () | LanguageFeature.UnmanagedConstraintCsharpInterop -> FSComp.SR.featureUnmanagedConstraintCsharpInterop () | LanguageFeature.ReuseSameFieldsInStructUnions -> FSComp.SR.featureReuseSameFieldsInStructUnions () | LanguageFeature.PreferExtensionMethodOverPlainProperty -> FSComp.SR.featurePreferExtensionMethodOverPlainProperty () diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 4afa992cde5..a6bcd1c90a3 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -11,7 +11,6 @@ type LanguageFeature = | WitnessPassing | NullnessChecking | UnionIsPropertiesVisible - | CSharpExtensionAttributeNotRequired | UnmanagedConstraintCsharpInterop | ReuseSameFieldsInStructUnions /// RFC-1137 diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 8bd83440050..2d543946c04 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -322,11 +322,6 @@ Částečné aktivní vzory vracející logickou hodnotu a směrované návratovým typem - - Allow implicit Extension attribute on declaring types, modules - Povolit implicitní atribut Extension pro deklarující typy, moduly - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Vyvolá upozornění, pokud je atribut TailCall použit u nerekurzivních funkcí. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index ab6af560121..6ff06c849cc 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -322,11 +322,6 @@ Teilweise aktive boolesche Rückgabemuster und rückgabetypgesteuerte Muster - - Allow implicit Extension attribute on declaring types, modules - Implizites Erweiterungsattribut für deklarierende Typen und Module zulassen - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Löst Warnungen aus, wenn das Attribut "TailCall" für nicht rekursive Funktionen verwendet wird. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 3f7773686fd..b075c94cc3a 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -322,11 +322,6 @@ Patrones activos parciales de devolución booleana y de tipo devuelto dirigido - - Allow implicit Extension attribute on declaring types, modules - Permitir atributo Extension implícito en tipos declarativo, módulos - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Genera advertencias si el atributo 'TailCall' se usa en funciones no recursivas. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 7a3822ab851..e6166ece789 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -322,11 +322,6 @@ Modèles actifs partiels à retour booléen et orientés par le type de retour - - Allow implicit Extension attribute on declaring types, modules - Autoriser l’attribut implicite Extension lors de la déclaration des types, modules - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Émet des avertissements si l’attribut « TailCall » est utilisé sur des fonctions non récursives. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 21aa6a838be..034f7aa820b 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -322,11 +322,6 @@ Criteri attivi parziali che restituiscono valori booleani e diretti dal tipo restituito - - Allow implicit Extension attribute on declaring types, modules - Consentire l'attributo estensione implicito per i tipi dichiarabili, i moduli - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Genera avvisi se l'attributo 'TailCall' viene utilizzato in funzioni non ricorsive. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index c49b5490212..4e124939608 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -322,11 +322,6 @@ ブール値を返すパターンと、戻り値の型が指定された部分的アクティブパターン - - Allow implicit Extension attribute on declaring types, modules - 型、モジュールの宣言で暗黙的な拡張属性を許可する - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. 'TailCall' 属性が再帰関数以外で使用されている場合、警告が発せられます。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 11cebee14be..e7453979cf9 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -322,11 +322,6 @@ 부울 반환 및 반환 형식 지향 부분 활성 패턴 - - Allow implicit Extension attribute on declaring types, modules - 유형, 모듈 선언에 암시적 확장 속성 허용 - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. 'TailCall' 특성이 비 재귀 함수에 사용되는 경우 경고를 발생합니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 9aa0452706b..2541d9fda67 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -322,11 +322,6 @@ Zwracane wartości logiczne i zwracane częściowe wzorce aktywne kierowane do typu zwrotnego - - Allow implicit Extension attribute on declaring types, modules - Zezwalaj na niejawny atrybut Rozszerzenie dla deklarujących typów, modułów - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Zgłasza ostrzeżenia, jeśli atrybut „TailCall” jest używany w funkcjach niekursywnych. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 388d56c9a0c..0a7b7512a48 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -322,11 +322,6 @@ Padrões ativos parciais com retorno booleano e direcionados por tipo de retorno - - Allow implicit Extension attribute on declaring types, modules - Permitir atributo de Extensão implícito em tipos declarativos, módulos - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Gera avisos se o atributo "TailCall" for usado em funções não recursivas. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index ef935e3d593..96281724fef 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -322,11 +322,6 @@ Логические возвращаемые и направленные на возвращаемый тип частичные активные шаблоны - - Allow implicit Extension attribute on declaring types, modules - Разрешить атрибут неявного расширения для объявляющих типов, модулей - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. Выдает предупреждения, если атрибут TailCall используется в нерекурсивных функциях. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 1a917da78aa..8022420b7ab 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -322,11 +322,6 @@ Boole döndüren ve dönüş türü yönlendiren kısmi etkin desenler - - Allow implicit Extension attribute on declaring types, modules - Türler, modüller bildirirken örtük Extension özniteliğine izin ver - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. 'TailCall' özniteliği özyinelemeli olmayan işlevlerde kullanılıyorsa uyarılar oluşturur. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index f159ad4ee1b..bed6d4b47e8 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -322,11 +322,6 @@ 布尔返回模式和返回类型定向部分活动模式 - - Allow implicit Extension attribute on declaring types, modules - 允许对声明类型、模块使用隐式扩展属性 - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. 如果在非递归函数上使用“TailCall”属性,则引发警告。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index abb0041c10d..22c0c34c173 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -322,11 +322,6 @@ 布爾值傳回和傳回類型導向的部分現用模式 - - Allow implicit Extension attribute on declaring types, modules - 允許宣告類型、模組上的隱含擴充屬性 - - Raises warnings if the 'TailCall' attribute is used on non-recursive functions. 如果 'TailCall' 屬性用於非遞迴函數,則引發警告。 diff --git a/tests/fsharp/Compiler/Language/OpenTypeDeclarationTests.fs b/tests/fsharp/Compiler/Language/OpenTypeDeclarationTests.fs index 24c2a09c8f5..621c4d10b87 100644 --- a/tests/fsharp/Compiler/Language/OpenTypeDeclarationTests.fs +++ b/tests/fsharp/Compiler/Language/OpenTypeDeclarationTests.fs @@ -1385,10 +1385,6 @@ let main _ = |> ignore [] - // NOTE: With langversion 8.0 and the CSharpExtensionAttributeNotRequired feature, - // extension methods with [] attribute on the method (but not the type) - // are treated as true C# extension methods and are NOT accessible via open type. - // This is the correct behavior - they should be used as extension methods, not static calls. let ``Opened types do allow unqualified access to C#-style extension methods if type has no [] attribute`` () = FSharp """ open System.Runtime.CompilerServices