Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -11080,16 +11081,19 @@ 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))
elif memberFlags.MemberKind = SynMemberKind.Constructor then
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
if not isMemberStatic then
error(Error(FSComp.SR.tcConcreteMembersIllegalInInterface(), m))
else
checkLanguageFeatureError g.langVersion LanguageFeature.StaticMembersInInterfaces m

//-------------------------------------------------------------------------
// TcLetrecBindings - AnalyzeAndMakeAndPublishRecursiveValue s
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/Compiler/Checking/CheckExpressions.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Checking/CheckIncrementalClasses.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/Compiler/Checking/infos.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,"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."
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type LanguageFeature =
| ErrorReportingOnStaticClasses
| TryWithInSeqExpression
| WarningWhenCopyAndUpdateRecordChangesAllFields
| StaticMembersInInterfaces

/// LanguageVersion management
type LanguageVersion(versionText) =
Expand Down Expand Up @@ -142,6 +143,7 @@ type LanguageVersion(versionText) =
LanguageFeature.ErrorReportingOnStaticClasses, previewVersion
LanguageFeature.TryWithInSeqExpression, previewVersion
LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields, previewVersion
LanguageFeature.StaticMembersInInterfaces, previewVersion

]

Expand Down Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type LanguageFeature =
| ErrorReportingOnStaticClasses
| TryWithInSeqExpression
| WarningWhenCopyAndUpdateRecordChangesAllFields
| StaticMembersInInterfaces

/// LanguageVersion management
type LanguageVersion =
Expand Down
12 changes: 7 additions & 5 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@
<target state="translated">vzor s jedním podtržítkem</target>
<note />
</trans-unit>
<trans-unit id="featureStaticMembersInInterfaces">
<source>Static members in interfaces</source>
<target state="new">Static members in interfaces</target>
<note />
</trans-unit>
<trans-unit id="featureStringInterpolation">
<source>string interpolation</source>
<target state="translated">interpolace řetězce</target>
Expand All @@ -382,19 +387,16 @@
<target state="translated">reprezentace struktury aktivních vzorů</target>
<note />
</trans-unit>

<trans-unit id="featureTryWithInSeqExpressions">
<source>Support for try-with in sequence expressions</source>
<target state="new">Support for try-with in sequence expressions</target>
<note />
</trans-unit>

<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>

<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Vyvolá upozornění, když se použije „let inline ... =“ společně s atributem [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;]. Funkce není vkládána.</target>
Expand Down Expand Up @@ -4626,8 +4628,8 @@
<note />
</trans-unit>
<trans-unit id="tcConcreteMembersIllegalInInterface">
<source>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.</source>
<target state="translated">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.</target>
<source>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.</source>
<target state="needs-review-translation">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.</target>
<note />
</trans-unit>
<trans-unit id="tcConstructorsDisallowedInExceptionAugmentation">
Expand Down
12 changes: 7 additions & 5 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@
<target state="translated">Muster mit einzelnem Unterstrich</target>
<note />
</trans-unit>
<trans-unit id="featureStaticMembersInInterfaces">
<source>Static members in interfaces</source>
<target state="new">Static members in interfaces</target>
<note />
</trans-unit>
<trans-unit id="featureStringInterpolation">
<source>string interpolation</source>
<target state="translated">Zeichenfolgeninterpolation</target>
Expand All @@ -382,19 +387,16 @@
<target state="translated">Strukturdarstellung für aktive Muster</target>
<note />
</trans-unit>

<trans-unit id="featureTryWithInSeqExpressions">
<source>Support for try-with in sequence expressions</source>
<target state="new">Support for try-with in sequence expressions</target>
<note />
</trans-unit>

<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>

<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Löst Warnungen aus, wenn „let inline ... =“ zusammen mit dem Attribut [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] verwendet wird. Die Funktion wird nicht inline gesetzt.</target>
Expand Down Expand Up @@ -4626,8 +4628,8 @@
<note />
</trans-unit>
<trans-unit id="tcConcreteMembersIllegalInInterface">
<source>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.</source>
<target state="translated">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.</target>
<source>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.</source>
<target state="needs-review-translation">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.</target>
<note />
</trans-unit>
<trans-unit id="tcConstructorsDisallowedInExceptionAugmentation">
Expand Down
12 changes: 7 additions & 5 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@
<target state="translated">patrón de subrayado simple</target>
<note />
</trans-unit>
<trans-unit id="featureStaticMembersInInterfaces">
<source>Static members in interfaces</source>
<target state="new">Static members in interfaces</target>
<note />
</trans-unit>
<trans-unit id="featureStringInterpolation">
<source>string interpolation</source>
<target state="translated">interpolación de cadena</target>
Expand All @@ -382,19 +387,16 @@
<target state="translated">representación de struct para modelos activos</target>
<note />
</trans-unit>

<trans-unit id="featureTryWithInSeqExpressions">
<source>Support for try-with in sequence expressions</source>
<target state="new">Support for try-with in sequence expressions</target>
<note />
</trans-unit>

<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>

<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Genera advertencias cuando se usa "let inline ... =" junto con el atributo [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;]. La función no se está insertando.</target>
Expand Down Expand Up @@ -4626,8 +4628,8 @@
<note />
</trans-unit>
<trans-unit id="tcConcreteMembersIllegalInInterface">
<source>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.</source>
<target state="translated">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.</target>
<source>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.</source>
<target state="needs-review-translation">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.</target>
<note />
</trans-unit>
<trans-unit id="tcConstructorsDisallowedInExceptionAugmentation">
Expand Down
Loading