You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No errors for non-virtual members overrides (dotnet#14263)
* No errors for non virtual members overrides
* Check for isFSharpObjModelTy as we are interested on csharp virtual methods
* More testing
* Add a feature lang preview
* More testing
* Fix PR comment
Copy file name to clipboardExpand all lines: src/Compiler/Checking/CheckExpressions.fs
+19-6Lines changed: 19 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -10950,7 +10950,7 @@ and ComputeIsComplete enclosingDeclaredTypars declaredTypars ty =
10950
10950
/// Determine if a uniquely-identified-abstract-slot exists for an override member (or interface member implementation) based on the information available
10951
10951
/// at the syntactic definition of the member (i.e. prior to type inference). If so, we know the expected signature of the override, and the full slotsig
10952
10952
/// it implements. Apply the inferred slotsig.
10953
-
and ApplyAbstractSlotInference (cenv: cenv) (envinner: TcEnv) (argsAndRetTy, m, synTyparDecls, declaredTypars, memberId, tcrefObjTy, renaming, _objTy, intfSlotTyOpt, valSynData, memberFlags: SynMemberFlags, attribs) =
10953
+
and ApplyAbstractSlotInference (cenv: cenv) (envinner: TcEnv) (baseValOpt: Val option) (argsAndRetTy, m, synTyparDecls, declaredTypars, memberId, tcrefObjTy, renaming, intfSlotTyOpt, valSynData, memberFlags: SynMemberFlags, attribs) =
10954
10954
10955
10955
let g = cenv.g
10956
10956
let ad = envinner.eAccessRights
@@ -10997,7 +10997,21 @@ and ApplyAbstractSlotInference (cenv: cenv) (envinner: TcEnv) (argsAndRetTy, m,
10997
10997
| _ -> [] // check that method to override is sealed is located at CheckOverridesAreAllUsedOnce (typrelns.fs)
10998
10998
// We hit this case when it is ambiguous which abstract method is being implemented.
10999
10999
11000
-
11000
+
if g.langVersion.SupportsFeature(LanguageFeature.ErrorForNonVirtualMembersOverrides) then
11001
+
// Checks if the declaring type inherits from a base class and is not FSharpObjModelTy
11002
+
// Raises an error if we try to override an non virtual member with the same name in both
11003
+
match baseValOpt with
11004
+
| Some ttype when not(isFSharpObjModelTy g ttype.Type) ->
11005
+
match stripTyEqns g ttype.Type with
11006
+
| TType_app(tyconRef, _, _) ->
11007
+
let ilMethods = tyconRef.ILTyconRawMetadata.Methods.AsList()
11008
+
let nameOpt = ilMethods |> List.tryFind(fun id -> id.Name = memberId.idText)
3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
1566
1567
3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
0 commit comments