From d732280bbd01d958deb4763c8a4a36fc53b9c521 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 3 Feb 2023 18:01:51 +0100 Subject: [PATCH 1/3] Allow static members in interfaces --- src/Compiler/Checking/CheckExpressions.fs | 22 +++--- src/Compiler/Checking/CheckExpressions.fsi | 8 ++- .../Checking/CheckIncrementalClasses.fs | 4 +- src/Compiler/Checking/infos.fs | 4 +- src/Compiler/FSComp.txt | 2 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/xlf/FSComp.txt.cs.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.de.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.es.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.fr.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.it.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.ja.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.ko.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.pl.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.ru.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.tr.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 13 +++- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 13 +++- .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../Language/InterfaceTests.fs | 70 +++++++++++++++++++ 22 files changed, 230 insertions(+), 54 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 332cea09879..f5f480aacdf 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -4358,12 +4358,13 @@ and TcTypeOrMeasure kindOpt (cenv: cenv) newOk checkConstraints occ (iwsam: Warn and CheckIWSAM (cenv: cenv) (env: TcEnv) checkConstraints iwsam m tcref = let g = cenv.g - let ad = env.eAccessRights let ty = generalizedTyconRef g tcref + if iwsam = WarnOnIWSAM.Yes && isInterfaceTy g ty && checkConstraints = CheckCxs then - let tcref = tcrefOfAppTy g ty - let meths = AllMethInfosOfTypeInScope ResultCollectionSettings.AllResults cenv.infoReader env.NameEnv None ad IgnoreOverrides m ty + let meths = AllMethInfosOfTypeInScope ResultCollectionSettings.AllResults cenv.infoReader env.NameEnv None env.eAccessRights IgnoreOverrides m ty + if meths |> List.exists (fun meth -> not meth.IsInstance && meth.IsDispatchSlot && not meth.IsExtensionMember) then + let tcref = tcrefOfAppTy g ty warning(Error(FSComp.SR.tcUsingInterfaceWithStaticAbstractMethodAsType(tcref.DisplayNameWithStaticParametersAndUnderscoreTypars), m)) and TcLongIdentType kindOpt (cenv: cenv) newOk checkConstraints occ iwsam env tpenv synLongId = @@ -11080,7 +11081,7 @@ and ApplyAbstractSlotInference (cenv: cenv) (envinner: TcEnv) (_: Val option) (a [], declaredTypars -and CheckForNonAbstractInterface declKind tcref (memberFlags: SynMemberFlags) m = +and CheckForNonAbstractInterface (g: TcGlobals) declKind tcref (memberFlags: SynMemberFlags) isMemberStatic m = if isInterfaceTyconRef tcref then if memberFlags.MemberKind = SynMemberKind.ClassConstructor then error(Error(FSComp.SR.tcStaticInitializersIllegalInInterface(), m)) @@ -11088,8 +11089,11 @@ and CheckForNonAbstractInterface declKind tcref (memberFlags: SynMemberFlags) m error(Error(FSComp.SR.tcObjectConstructorsIllegalInInterface(), m)) elif memberFlags.IsOverrideOrExplicitImpl then error(Error(FSComp.SR.tcMemberOverridesIllegalInInterface(), m)) - elif not (declKind=ExtrinsicExtensionBinding || memberFlags.IsDispatchSlot ) then - error(Error(FSComp.SR.tcConcreteMembersIllegalInInterface(), m)) + elif not (declKind = ExtrinsicExtensionBinding || memberFlags.IsDispatchSlot) then + match isMemberStatic, g.langVersion.SupportsFeature LanguageFeature.StaticMembersInInterfaces with + | true, true -> () + | false, true -> error(Error(FSComp.SR.tcConcreteInstanceMembersIllegalInInterface(), m)) + | _ -> error(Error(FSComp.SR.tcConcreteMembersIllegalInInterface(), m)) //------------------------------------------------------------------------- // TcLetrecBindings - AnalyzeAndMakeAndPublishRecursiveValue s @@ -11135,7 +11139,7 @@ and AnalyzeRecursiveStaticMemberOrValDecl memberFlags.IsOverrideOrExplicitImpl -> CheckMemberFlags intfSlotTyOpt newslotsOK overridesOK memberFlags id.idRange - CheckForNonAbstractInterface declKind tcref memberFlags id.idRange + CheckForNonAbstractInterface g declKind tcref memberFlags true id.idRange let isExtrinsic = (declKind = ExtrinsicExtensionBinding) let tcrefObjTy, enclosingDeclaredTypars, renaming, _, _ = FreshenObjectArgType cenv mBinding TyparRigidity.WillBeRigid tcref isExtrinsic declaredTyconTypars @@ -11157,7 +11161,7 @@ and AnalyzeRecursiveStaticMemberOrValDecl assert (Option.isNone intfSlotTyOpt) CheckMemberFlags None newslotsOK overridesOK memberFlags id.idRange - CheckForNonAbstractInterface declKind tcref memberFlags id.idRange + CheckForNonAbstractInterface g declKind tcref memberFlags true id.idRange if memberFlags.MemberKind = SynMemberKind.Constructor && tcref.Deref.IsFSharpException then error(Error(FSComp.SR.tcConstructorsDisallowedInExceptionAugmentation(), id.idRange)) @@ -11262,7 +11266,7 @@ and AnalyzeRecursiveInstanceMemberDecl let argsAndRetTy = NewInferenceType g UnifyTypes cenv envinner mBinding ty (mkFunTy g thisTy argsAndRetTy) - CheckForNonAbstractInterface declKind tcref memberFlags memberId.idRange + CheckForNonAbstractInterface g declKind tcref memberFlags false memberId.idRange // Determine if a uniquely-identified-override exists based on the information // at the member signature. If so, we know the type of this member, and the full slotsig diff --git a/src/Compiler/Checking/CheckExpressions.fsi b/src/Compiler/Checking/CheckExpressions.fsi index 5c2b0b6451f..0e079eeec33 100644 --- a/src/Compiler/Checking/CheckExpressions.fsi +++ b/src/Compiler/Checking/CheckExpressions.fsi @@ -389,7 +389,13 @@ val AnalyzeAndMakeAndPublishRecursiveValue: /// Check that a member can be included in an interface val CheckForNonAbstractInterface: - declKind: DeclKind -> tcref: TyconRef -> memberFlags: SynMemberFlags -> m: range -> unit + g: TcGlobals -> + declKind: DeclKind -> + tcref: TyconRef -> + memberFlags: SynMemberFlags -> + isMemberStatic: bool -> + m: range -> + unit /// Check the flags on a member definition for consistency val CheckMemberFlags: diff --git a/src/Compiler/Checking/CheckIncrementalClasses.fs b/src/Compiler/Checking/CheckIncrementalClasses.fs index fe7e1a2393c..7ace6fe83b3 100644 --- a/src/Compiler/Checking/CheckIncrementalClasses.fs +++ b/src/Compiler/Checking/CheckIncrementalClasses.fs @@ -128,7 +128,7 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr let valSynData = SynValInfo([synArgInfos], SynInfo.unnamedRetVal) let id = ident ("new", m) - CheckForNonAbstractInterface ModuleOrMemberBinding tcref memberFlags id.idRange + CheckForNonAbstractInterface g ModuleOrMemberBinding tcref memberFlags false id.idRange let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, attribs, [], memberFlags, valSynData, id, false) let prelimValReprInfo = TranslateSynValInfo m (TcAttributes cenv env) valSynData let prelimTyschemeG = GeneralizedType(copyOfTyconTypars, ctorTy) @@ -152,7 +152,7 @@ let TcImplicitCtorLhs_Phase2A(cenv: cenv, env, tpenv, tcref: TyconRef, vis, attr let cctorTy = mkFunTy g g.unit_ty g.unit_ty let valSynData = SynValInfo([[]], SynInfo.unnamedRetVal) let id = ident ("cctor", m) - CheckForNonAbstractInterface ModuleOrMemberBinding tcref ClassCtorMemberFlags id.idRange + CheckForNonAbstractInterface g ModuleOrMemberBinding tcref ClassCtorMemberFlags false id.idRange let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, [], [], ClassCtorMemberFlags, valSynData, id, false) let prelimValReprInfo = TranslateSynValInfo m (TcAttributes cenv env) valSynData let prelimTyschemeG = GeneralizedType(copyOfTyconTypars, cctorTy) diff --git a/src/Compiler/Checking/infos.fs b/src/Compiler/Checking/infos.fs index 68e844fa919..a012d9260e3 100644 --- a/src/Compiler/Checking/infos.fs +++ b/src/Compiler/Checking/infos.fs @@ -866,9 +866,7 @@ type MethInfo = member x.IsDispatchSlot = match x with | ILMeth(_g, ilmeth, _) -> ilmeth.IsVirtual - | FSMeth(g, _, vref, _) as x -> - isInterfaceTy g x.ApparentEnclosingType || - vref.MemberInfo.Value.MemberFlags.IsDispatchSlot + | FSMeth(_, _, vref, _) -> vref.MemberInfo.Value.MemberFlags.IsDispatchSlot | DefaultStructCtor _ -> false #if !NO_TYPEPROVIDERS | ProvidedMeth _ -> x.IsVirtual // Note: follow same implementation as ILMeth diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 063a6b973c8..f1a988982ee 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1563,6 +1563,7 @@ featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals featureErrorReportingOnStaticClasses,"Error reporting on static classes" featureTryWithInSeqExpressions,"Support for try-with in sequence expressions" featureWarningWhenCopyAndUpdateRecordChangesAllFields,"Raises warnings when an copy-and-update record expression changes all fields of a record." +featureStaticMembersInInterfaces,"Allow static members in interfaces" 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." @@ -1677,3 +1678,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Explicit field declarations are not allowed." 3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'." 3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead." +3561,tcConcreteInstanceMembersIllegalInInterface,"Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 46748d6f889..095e12ac95a 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -63,6 +63,7 @@ type LanguageFeature = | ErrorReportingOnStaticClasses | TryWithInSeqExpression | WarningWhenCopyAndUpdateRecordChangesAllFields + | StaticMembersInInterfaces /// LanguageVersion management type LanguageVersion(versionText) = @@ -142,6 +143,7 @@ type LanguageVersion(versionText) = LanguageFeature.ErrorReportingOnStaticClasses, previewVersion LanguageFeature.TryWithInSeqExpression, previewVersion LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields, previewVersion + LanguageFeature.StaticMembersInInterfaces, previewVersion ] @@ -258,6 +260,7 @@ type LanguageVersion(versionText) = | LanguageFeature.ErrorReportingOnStaticClasses -> FSComp.SR.featureErrorReportingOnStaticClasses () | LanguageFeature.TryWithInSeqExpression -> FSComp.SR.featureTryWithInSeqExpressions () | LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields -> FSComp.SR.featureWarningWhenCopyAndUpdateRecordChangesAllFields () + | LanguageFeature.StaticMembersInInterfaces -> FSComp.SR.featureStaticMembersInInterfaces () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 8ab8b72704b..badfce8c012 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -53,6 +53,7 @@ type LanguageFeature = | ErrorReportingOnStaticClasses | TryWithInSeqExpression | WarningWhenCopyAndUpdateRecordChangesAllFields + | StaticMembersInInterfaces /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index b6ad7c62f3a..d252af29df7 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -372,6 +372,11 @@ vzor s jedním podtržítkem + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation interpolace řetězce @@ -382,19 +387,16 @@ reprezentace struktury aktivních vzorů - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Vyvolá upozornění, když se použije „let inline ... =“ společně s atributem [<MethodImpl(MethodImplOptions.NoInlining)>]. Funkce není vkládána. @@ -885,6 +887,11 @@ Atributy nejde použít pro rozšíření typů. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 52f3d52cf26..309a2993dc1 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -372,6 +372,11 @@ Muster mit einzelnem Unterstrich + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation Zeichenfolgeninterpolation @@ -382,19 +387,16 @@ Strukturdarstellung für aktive Muster - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Löst Warnungen aus, wenn „let inline ... =“ zusammen mit dem Attribut [<MethodImpl(MethodImplOptions.NoInlining)>] verwendet wird. Die Funktion wird nicht inline gesetzt. @@ -885,6 +887,11 @@ Attribute können nicht auf Typerweiterungen angewendet werden. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 298deb31137..37078ed0d52 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -372,6 +372,11 @@ patrón de subrayado simple + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation interpolación de cadena @@ -382,19 +387,16 @@ representación de struct para modelos activos - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Genera advertencias cuando se usa "let inline ... =" junto con el atributo [<MethodImpl(MethodImplOptions.NoInlining)>]. La función no se está insertando. @@ -885,6 +887,11 @@ Los atributos no se pueden aplicar a las extensiones de tipo. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index d41d7f05761..ca40a4aaff1 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -372,6 +372,11 @@ modèle de trait de soulignement unique + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation interpolation de chaîne @@ -382,19 +387,16 @@ représentation de structure pour les modèles actifs - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Génère des avertissements lorsque « let inline ... = » est utilisé avec l’attribut [<MethodImpl(MethodImplOptions.NoInlining)>]. La fonction n’est pas inlined. @@ -885,6 +887,11 @@ Impossible d'appliquer des attributs aux extensions de type. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 083f98e4dfa..5c9b4b642d6 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -372,6 +372,11 @@ criterio per carattere di sottolineatura singolo + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation interpolazione di stringhe @@ -382,19 +387,16 @@ rappresentazione struct per criteri attivi - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Genera avvisi quando 'let inline ... =' viene usato insieme all'attributo [<MethodImpl(MethodImplOptions.NoInlining)>]. La funzione non viene resa inline. @@ -885,6 +887,11 @@ Gli attributi non possono essere applicati a estensioni di tipo. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 85735c3b4e2..0a8e0779623 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -372,6 +372,11 @@ 単一のアンダースコア パターン + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation 文字列の補間 @@ -382,19 +387,16 @@ アクティブなパターンの構造体表現 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 'let inline ... =' が [<MethodImpl(MethodImplOptions.NoInlining)>] 属性と一緒に使用されるときに警告を生成します。関数はインライン化されていません。 @@ -885,6 +887,11 @@ 属性を型拡張に適用することはできません。 + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 2b32dd65949..21197651842 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -372,6 +372,11 @@ 단일 밑줄 패턴 + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation 문자열 보간 @@ -382,19 +387,16 @@ 활성 패턴에 대한 구조체 표현 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 'let inline ... ='을(를) [<MethodImpl(MethodImplOptions.NoInlining)>] 특성과 함께 사용하는 경우 경고를 발생합니다. 함수가 인라인되지 않습니다. @@ -885,6 +887,11 @@ 형식 확장에 특성을 적용할 수 없습니다. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index ee6b6afe9ac..16b0a779541 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -372,6 +372,11 @@ wzorzec z pojedynczym podkreśleniem + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation interpolacja ciągu @@ -382,19 +387,16 @@ reprezentacja struktury aktywnych wzorców - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Zgłasza ostrzeżenia, gdy element „let inline ... =” jest używany razem z atrybutem [<MethodImpl(MethodImplOptions.NoInlining)>]. Funkcja nie jest wstawiana. @@ -885,6 +887,11 @@ Atrybutów nie można stosować do rozszerzeń typu. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 8ad44f41ea6..fe8026c2f91 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -372,6 +372,11 @@ padrão de sublinhado simples + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation interpolação da cadeia de caracteres @@ -382,19 +387,16 @@ representação estrutural para padrões ativos - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Gera avisos quando 'let inline ... =' é usado junto com o atributo [<MethodImpl(MethodImplOptions.NoInlining)>]. A função não está sendo embutida. @@ -885,6 +887,11 @@ Os atributos não podem ser aplicados às extensões de tipo. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 0cbd637dd4d..1227bef3e61 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -372,6 +372,11 @@ шаблон с одним подчеркиванием + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation интерполяция строк @@ -382,19 +387,16 @@ представление структуры для активных шаблонов - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. Выдает предупреждения, когда используется параметр "let inline ... =" вместе с атрибутом [<MethodImpl(MethodImplOptions.NoInlining)>]. Функция не встраивается. @@ -885,6 +887,11 @@ Атрибуты не могут быть применены к расширениям типа. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index c9713648da3..12d59805a84 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -372,6 +372,11 @@ tek alt çizgi deseni + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation dizede düz metin arasına kod ekleme @@ -382,19 +387,16 @@ etkin desenler için yapı gösterimi - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. [<MethodImpl(MethodImplOptions.NoInlining)>] özniteliği ile birlikte 'let inline ... =' kullanıldığında uyarı verir. İşlev satır içine alınmıyor. @@ -885,6 +887,11 @@ Öznitelikler tür uzantılarına uygulanamaz. + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 4072aaad792..f20c4f890f6 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -372,6 +372,11 @@ 单下划线模式 + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation 字符串内插 @@ -382,19 +387,16 @@ 活动模式的结构表示形式 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 当 "let inline ... =" 与 [<MethodImpl(MethodImplOptions.NoInlining)>] 属性一起使用时引发警告。函数未内联。 @@ -885,6 +887,11 @@ 属性不可应用于类型扩展。 + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index bd871bbba49..f87679bfe8d 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -372,6 +372,11 @@ 單一底線模式 + + Allow static members in interfaces + Allow static members in interfaces + + string interpolation 字串內插補點 @@ -382,19 +387,16 @@ 現用模式的結構表示法 - Support for try-with in sequence expressions Support for try-with in sequence expressions - Raises warnings when an copy-and-update record expression changes all fields of a record. Raises warnings when an copy-and-update record expression changes all fields of a record. - Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined. 當 'let inline ... =' 與 [<MethodImpl(MethodImplOptions.NoInlining)>] 屬性一起使用時引發警告。函數未內嵌。 @@ -885,6 +887,11 @@ 屬性無法套用到類型延伸模組。 + + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + + This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 9f8f23b83c3..394d419e94e 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -180,6 +180,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs new file mode 100644 index 00000000000..27911436506 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs @@ -0,0 +1,70 @@ +module FSharp.Compiler.ComponentTests.Language.InterfaceTests + +open Xunit +open FSharp.Test.Compiler + +[] +let ``Concrete instance method is not allowed in interfaces in lang preview``() = + FSharp $""" +[] +type I = + member _.X () = 1 + """ + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3561, Line 4, Col 14, Line 4, Col 15, "Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class.") + ] + +[] +let ``Concrete instance property is not allowed in interfaces in lang preview``() = + FSharp $""" +[] +type I = + member _.Prop = "x" + """ + |> withLangVersionPreview + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3561, Line 4, Col 14, Line 4, Col 18, "Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class.") + ] + +[] +let ``Concrete static members are allowed in interfaces in lang preview``() = + FSharp $""" +[] +type I<'T> = + static member Echo (x: 'T) = x + static member Prop = Unchecked.defaultof<'T> + +if I.Echo 42 <> 42 || I.Prop <> 0 || not (isNull I.Prop) then + failwith "failed" + """ + |> withLangVersionPreview + |> asExe + |> compileAndRun + |> shouldSucceed + +[] +let ``Interface with concrete static members can be implemented in lang preview``() = + FSharp $""" +[] +type I = + static member Echo (x: string) = x + abstract member Blah: int + +type Imp () = + interface I with + member _.Blah = 3 + +let o = {{ new I with member _.Blah = 4 }} + +if I.Echo "yup" <> "yup" || (Imp() :> I).Blah <> 3 || o.Blah <> 4 then + failwith "failed" + """ + |> withLangVersionPreview + |> asExe + |> compileAndRun + |> shouldSucceed \ No newline at end of file From a03d9af7ed6e563a19e5b40a7051cad450fbb543 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 6 Feb 2023 15:15:06 +0100 Subject: [PATCH 2/3] Add negative test for lang 7.0 --- .../Language/InterfaceTests.fs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs index 27911436506..5bd39a23962 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs @@ -47,6 +47,21 @@ if I.Echo 42 <> 42 || I.Prop <> 0 || not (isNull I.Prop) then |> compileAndRun |> shouldSucceed +[] +let ``Concrete static members are not allowed in interfaces in lang version70``() = + FSharp $""" +[] +type I<'T> = + static member Echo (x: 'T) = x + static member Prop = Unchecked.defaultof<'T> + """ + |> withLangVersion70 + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 868, Line 4, Col 19, Line 4, Col 23, "Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class.") + ] + [] let ``Interface with concrete static members can be implemented in lang preview``() = FSharp $""" From 1883e55f468dd74f0204e068a6ea355c13afd1a4 Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 8 Feb 2023 17:21:56 +0100 Subject: [PATCH 3/3] Improve error messages --- src/Compiler/Checking/CheckExpressions.fs | 8 ++++---- src/Compiler/FSComp.txt | 5 ++--- src/Compiler/xlf/FSComp.txt.cs.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.de.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.es.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.fr.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.it.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.ja.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.ko.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.pl.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.ru.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.tr.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 13 ++++--------- src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 13 ++++--------- .../Language/InterfaceTests.fs | 6 +++--- 16 files changed, 61 insertions(+), 127 deletions(-) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index f5f480aacdf..24c444664fd 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -11090,10 +11090,10 @@ and CheckForNonAbstractInterface (g: TcGlobals) declKind tcref (memberFlags: Syn elif memberFlags.IsOverrideOrExplicitImpl then error(Error(FSComp.SR.tcMemberOverridesIllegalInInterface(), m)) elif not (declKind = ExtrinsicExtensionBinding || memberFlags.IsDispatchSlot) then - match isMemberStatic, g.langVersion.SupportsFeature LanguageFeature.StaticMembersInInterfaces with - | true, true -> () - | false, true -> error(Error(FSComp.SR.tcConcreteInstanceMembersIllegalInInterface(), m)) - | _ -> error(Error(FSComp.SR.tcConcreteMembersIllegalInInterface(), m)) + if not isMemberStatic then + error(Error(FSComp.SR.tcConcreteMembersIllegalInInterface(), m)) + else + checkLanguageFeatureError g.langVersion LanguageFeature.StaticMembersInInterfaces m //------------------------------------------------------------------------- // TcLetrecBindings - AnalyzeAndMakeAndPublishRecursiveValue s diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index f1a988982ee..b13769ab5ce 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -717,7 +717,7 @@ tcUnnamedArgumentsDoNotFormPrefix,"The unnamed arguments do not form a prefix of 865,tcStaticInitializersIllegalInInterface,"Interfaces cannot contain definitions of static initializers" 866,tcObjectConstructorsIllegalInInterface,"Interfaces cannot contain definitions of object constructors" 867,tcMemberOverridesIllegalInInterface,"Interfaces cannot contain definitions of member overrides" -868,tcConcreteMembersIllegalInInterface,"Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class." +868,tcConcreteMembersIllegalInInterface,"Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class." 869,tcConstructorsDisallowedInExceptionAugmentation,"Constructors cannot be specified in exception augmentations" 870,tcStructsCannotHaveConstructorWithNoArguments,"Structs cannot have an object constructor with no arguments. This is a restriction imposed on all CLI languages as structs automatically support a default constructor." 871,tcConstructorsIllegalForThisType,"Constructors cannot be defined for this type" @@ -1563,7 +1563,7 @@ featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals featureErrorReportingOnStaticClasses,"Error reporting on static classes" featureTryWithInSeqExpressions,"Support for try-with in sequence expressions" featureWarningWhenCopyAndUpdateRecordChangesAllFields,"Raises warnings when an copy-and-update record expression changes all fields of a record." -featureStaticMembersInInterfaces,"Allow static members in interfaces" +featureStaticMembersInInterfaces,"Static members in interfaces" 3353,fsiInvalidDirective,"Invalid directive '#%s %s'" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." @@ -1678,4 +1678,3 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form 3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [] and [] attributes, it means it is static. Explicit field declarations are not allowed." 3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'." 3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead." -3561,tcConcreteInstanceMembersIllegalInInterface,"Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class." diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index d252af29df7..c81fe4e8f56 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Atributy nejde použít pro rozšíření typů. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Rozhraní nemůžou obsahovat definice konkrétních členů. Možná bude potřeba definovat u typu konstruktor, který bude vyjadřovat, že jde o třídu. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Rozhraní nemůžou obsahovat definice konkrétních členů. Možná bude potřeba definovat u typu konstruktor, který bude vyjadřovat, že jde o třídu. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index 309a2993dc1..fffff96ecc3 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Attribute können nicht auf Typerweiterungen angewendet werden. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Schnittstellen dürfen keine Definitionen konkreter Member enthalten. Sie müssen ggf. einen Konstruktor für den Typ definieren, um anzugeben, dass es sich bei dem Typ um eine Klasse handelt. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Schnittstellen dürfen keine Definitionen konkreter Member enthalten. Sie müssen ggf. einen Konstruktor für den Typ definieren, um anzugeben, dass es sich bei dem Typ um eine Klasse handelt. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index 37078ed0d52..7a7c32069e7 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Los atributos no se pueden aplicar a las extensiones de tipo. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Las interfaces no pueden contener definiciones de miembros concretos. Puede ser necesario definir un constructor en el tipo para indicar que el tipo es una clase. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Las interfaces no pueden contener definiciones de miembros concretos. Puede ser necesario definir un constructor en el tipo para indicar que el tipo es una clase. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index ca40a4aaff1..bfe8bff317b 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Impossible d'appliquer des attributs aux extensions de type. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Les interfaces ne peuvent pas contenir de définitions de membres concrets. Vous pouvez définir un constructeur sur votre type pour indiquer que le type est une classe. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Les interfaces ne peuvent pas contenir de définitions de membres concrets. Vous pouvez définir un constructeur sur votre type pour indiquer que le type est une classe. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 5c9b4b642d6..e6419dfc465 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Gli attributi non possono essere applicati a estensioni di tipo. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Le interfacce non possono contenere definizioni di membri concreti. Potrebbe essere necessario definire un costruttore nel tipo utilizzato per indicare che il tipo è una classe. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Le interfacce non possono contenere definizioni di membri concreti. Potrebbe essere necessario definire un costruttore nel tipo utilizzato per indicare che il tipo è una classe. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 0a8e0779623..b565ccf6694 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ 属性を型拡張に適用することはできません。 - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - インターフェイスに具象メンバーの定義を含めることはできません。必要に応じて、型にコンストラクターを定義して、型がクラスであることを示してください。 + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + インターフェイスに具象メンバーの定義を含めることはできません。必要に応じて、型にコンストラクターを定義して、型がクラスであることを示してください。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 21197651842..c75c9cf1435 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ 형식 확장에 특성을 적용할 수 없습니다. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - 인터페이스에는 구체적인 멤버의 정의를 포함할 수 없습니다. 사용자 형식에 대한 생성자를 정의하여 해당 형식이 클래스임을 나타내야 할 수 있습니다. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + 인터페이스에는 구체적인 멤버의 정의를 포함할 수 없습니다. 사용자 형식에 대한 생성자를 정의하여 해당 형식이 클래스임을 나타내야 할 수 있습니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 16b0a779541..6cf95f5eaa4 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Atrybutów nie można stosować do rozszerzeń typu. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Interfejsy nie mogą zawierać definicji konkretnych elementów członkowskich. Może być konieczne zdefiniowanie konstruktora w typie, aby określić, że typ to klasa. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfejsy nie mogą zawierać definicji konkretnych elementów członkowskich. Może być konieczne zdefiniowanie konstruktora w typie, aby określić, że typ to klasa. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index fe8026c2f91..56eb6903278 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Os atributos não podem ser aplicados às extensões de tipo. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces não podem conter definições de membros concretos. Talvez seja necessário definir um construtor no seu tipo para indicar que o tipo é uma classe. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Interfaces não podem conter definições de membros concretos. Talvez seja necessário definir um construtor no seu tipo para indicar que o tipo é uma classe. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 1227bef3e61..81a41024002 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Атрибуты не могут быть применены к расширениям типа. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Интерфейсы не могут содержать определений конкретных элементов. Чтобы указать, что тип является классом, возможно, потребуется определить конструктор для типа. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Интерфейсы не могут содержать определений конкретных элементов. Чтобы указать, что тип является классом, возможно, потребуется определить конструктор для типа. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 12d59805a84..8b6882ff1b4 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ Öznitelikler tür uzantılarına uygulanamaz. - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - Arabirimler somut üyelerin tanımlarını içeremez. Türün sınıf olduğunu belirtmek için türünüzde bir oluşturucu tanımlamanız gerekebilir. + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + Arabirimler somut üyelerin tanımlarını içeremez. Türün sınıf olduğunu belirtmek için türünüzde bir oluşturucu tanımlamanız gerekebilir. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index f20c4f890f6..f39f82d2045 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ 属性不可应用于类型扩展。 - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - 接口不能包含具体成员的定义。您可能需要定义类型的构造函数来指示该类型是类。 + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + 接口不能包含具体成员的定义。您可能需要定义类型的构造函数来指示该类型是类。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f87679bfe8d..1529a87f1cb 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -373,8 +373,8 @@ - Allow static members in interfaces - Allow static members in interfaces + Static members in interfaces + Static members in interfaces @@ -887,11 +887,6 @@ 屬性無法套用到類型延伸模組。 - - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. - - This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead. @@ -4633,8 +4628,8 @@ - Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class. - 介面不能包含具象成員的定義。您必須在類型上定義建構函式,以指示類型是類別。 + Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class. + 介面不能包含具象成員的定義。您必須在類型上定義建構函式,以指示類型是類別。 diff --git a/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs index 5bd39a23962..97a0798e1da 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/InterfaceTests.fs @@ -14,7 +14,7 @@ type I = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3561, Line 4, Col 14, Line 4, Col 15, "Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class.") + (Error 868, Line 4, Col 14, Line 4, Col 15, "Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class.") ] [] @@ -28,7 +28,7 @@ type I = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 3561, Line 4, Col 14, Line 4, Col 18, "Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class.") + (Error 868, Line 4, Col 14, Line 4, Col 18, "Interfaces cannot contain definitions of concrete instance members. You may need to define a constructor on your type to indicate that the type is a class.") ] [] @@ -59,7 +59,7 @@ type I<'T> = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 868, Line 4, Col 19, Line 4, Col 23, "Interfaces cannot contain definitions of concrete members. You may need to define a constructor on your type to indicate that the type is a class.") + (Error 3350, Line 4, Col 19, Line 4, Col 23, "Feature 'Static members in interfaces' is not available in F# 7.0. Please use language version 'PREVIEW' or greater.") ] []