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
4 changes: 4 additions & 0 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ ExceptionDefsNotCompatibleFieldOrderDiffers,"The exception definitions are not c
364,typrelNamedArgumentHasBeenAssignedMoreThenOnce,"A named argument has been assigned more than one value"
365,typrelNoImplementationGiven,"No implementation was given for '%s'"
366,typrelNoImplementationGivenWithSuggestion,"No implementation was given for '%s'. Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
365,typrelNoImplementationGivenSeveral,"No implementation was given for those members: %s"
366,typrelNoImplementationGivenSeveralWithSuggestion,"No implementation was given for those members: %sNote that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
365,typrelNoImplementationGivenSeveralTruncated,"No implementation was given for those members (some results omitted): %s"
366,typrelNoImplementationGivenSeveralTruncatedWithSuggestion,"No implementation was given for those members (some results omitted): %sNote that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'."
367,typrelMemberDoesNotHaveCorrectNumberOfArguments,"The member '%s' does not have the correct number of arguments. The required signature is '%s'."
368,typrelMemberDoesNotHaveCorrectNumberOfTypeParameters,"The member '%s' does not have the correct number of method type parameters. The required signature is '%s'."
369,typrelMemberDoesNotHaveCorrectKindsOfGenericParameters,"The member '%s' does not have the correct kinds of generic parameters. The required signature is '%s'."
Expand Down
77 changes: 59 additions & 18 deletions src/fsharp/MethodOverrides.fs
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,30 @@ module DispatchSlotChecking =

let isReqdTyInterface = isInterfaceTy g reqdTy
let showMissingMethodsAndRaiseErrors = (isReqdTyInterface || not isOverallTyAbstract)
let res = ref true
let fail exn = (res := false ; if showMissingMethodsAndRaiseErrors then errorR exn)

let mutable res = true
let fail exn =
res <- false
if showMissingMethodsAndRaiseErrors then
errorR exn

// Index the availPriorOverrides and overrides by name
let availPriorOverridesKeyed = availPriorOverrides |> NameMultiMap.initBy (fun ov -> ov.LogicalName)
let overridesKeyed = overrides |> NameMultiMap.initBy (fun ov -> ov.LogicalName)

dispatchSlots |> List.iter (fun (RequiredSlot(dispatchSlot, isOptional)) ->

match NameMultiMap.find dispatchSlot.LogicalName overridesKeyed
|> List.filter (OverrideImplementsDispatchSlot g amap m dispatchSlot) with
// we accumulate those to compose a more complete error message, see noimpl() bellow.
let missingOverloadImplementation = ResizeArray()

for (RequiredSlot(dispatchSlot, isOptional)) in dispatchSlots do
let maybeResolvedSlot =
NameMultiMap.find dispatchSlot.LogicalName overridesKeyed
|> List.filter (OverrideImplementsDispatchSlot g amap m dispatchSlot)

match maybeResolvedSlot with
| [ovd] ->
if not ovd.IsCompilerGenerated then
let item = Item.MethodGroup(ovd.LogicalName, [dispatchSlot], None)
CallNameResolutionSink sink (ovd.Range, nenv, item, item, dispatchSlot.FormalMethodTyparInst, ItemOccurence.Implemented, denv, AccessorDomain.AccessibleFromSomewhere)
sink |> ignore
()
let item = Item.MethodGroup(ovd.LogicalName, [dispatchSlot],None)
CallNameResolutionSink sink (ovd.Range, nenv, item,item, dispatchSlot.FormalMethodTyparInst, ItemOccurence.Implemented, denv,AccessorDomain.AccessibleFromSomewhere)
| [] ->
if not isOptional &&
// Check that no available prior override implements this dispatch slot
Expand All @@ -281,10 +288,7 @@ module DispatchSlotChecking =
let compiledSig = CompiledSigOfMeth g amap m dispatchSlot

let noimpl() =
if isReqdTyInterface then
fail(Error(FSComp.SR.typrelNoImplementationGivenWithSuggestion(NicePrint.stringOfMethInfo amap m denv dispatchSlot), m))
else
fail(Error(FSComp.SR.typrelNoImplementationGiven(NicePrint.stringOfMethInfo amap m denv dispatchSlot), m))
missingOverloadImplementation.Add((isReqdTyInterface, lazy NicePrint.stringOfMethInfo amap m denv dispatchSlot))

match overrides |> List.filter (IsPartialMatch g dispatchSlot compiledSig) with
| [] ->
Expand All @@ -307,7 +311,7 @@ module DispatchSlotChecking =
if moreThanOnePossibleDispatchSlot then
noimpl()

elif argTys.Length <> vargtys.Length then
elif argTys.Length <> vargtys.Length then
fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectNumberOfArguments(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
elif mtps.Length <> fvmtps.Length then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If mtps is a list, use listSameLength here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmh it is a Typars, which in fact is a list, I'll change it as well.

It would be nice if type aliases in a tooltip were shown at the bottom.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is already an issue/suggestion. It would be easy to implement, the hard part is to decide how to represent it on the tooltip.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3110 revolves around similar topic, in this case it would display:

image

Typars = Typar list

fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectNumberOfTypeParameters(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
Expand All @@ -324,11 +328,48 @@ module DispatchSlotChecking =
else
// Error will be reported below in CheckOverridesAreAllUsedOnce
()

| _ ->
fail(Error(FSComp.SR.typrelOverrideWasAmbiguous(FormatMethInfoSig g amap m denv dispatchSlot), m))
| _ -> fail(Error(FSComp.SR.typrelMoreThenOneOverride(FormatMethInfoSig g amap m denv dispatchSlot), m)))
!res
| _ -> fail(Error(FSComp.SR.typrelMoreThenOneOverride(FormatMethInfoSig g amap m denv dispatchSlot), m))

if missingOverloadImplementation.Count > 0 then
// compose message listing missing override implementation
let maxDisplayedOverrides = 10
let shouldTruncate = missingOverloadImplementation.Count > maxDisplayedOverrides
let messageWithInterfaceSuggestion =
// check any of the missing overrides has isReqdTyInterface flag set
// in which case we use the message "with suggestion"
missingOverloadImplementation
|> Seq.map fst
|> Seq.filter id
|> Seq.isEmpty
|> not

if missingOverloadImplementation.Count = 1 then
// only one missing override, we have specific message for that
let signature = (snd missingOverloadImplementation.[0]).Value
if messageWithInterfaceSuggestion then
fail(Error(FSComp.SR.typrelNoImplementationGivenWithSuggestion(signature), m))
else
fail(Error(FSComp.SR.typrelNoImplementationGiven(signature), m))
else
let signatures =
(missingOverloadImplementation
|> Seq.truncate maxDisplayedOverrides
|> Seq.map snd
|> Seq.map (fun signature -> System.Environment.NewLine + "\t'" + signature.Value + "'")
|> String.concat "") + System.Environment.NewLine

// we have specific message if the list is truncated
let messageFunction =
match shouldTruncate, messageWithInterfaceSuggestion with
| false, true -> FSComp.SR.typrelNoImplementationGivenSeveralWithSuggestion
| false, false -> FSComp.SR.typrelNoImplementationGivenSeveral
| true , true -> FSComp.SR.typrelNoImplementationGivenSeveralTruncatedWithSuggestion
| true , false -> FSComp.SR.typrelNoImplementationGivenSeveralTruncated
fail(Error(messageFunction(signatures), m))

res

/// Check all implementations implement some dispatch slot.
let CheckOverridesAreAllUsedOnce(denv, g, amap, isObjExpr, reqdTy,
Expand Down
20 changes: 20 additions & 0 deletions src/fsharp/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7132,6 +7132,26 @@
<target state="translated">Funkce nebo metoda má neplatný návratový typ {0}. To nepovolují pravidla Common IL.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveral">
<source>No implementation was given for those members: {0}</source>
<target state="new">No implementation was given for those members: {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralWithSuggestion">
<source>No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncated">
<source>No implementation was given for those members (some results omitted): {0}</source>
<target state="new">No implementation was given for those members (some results omitted): {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncatedWithSuggestion">
<source>No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
20 changes: 20 additions & 0 deletions src/fsharp/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7132,6 +7132,26 @@
<target state="translated">Die Funktion oder Methode weist einen ungültigen Rückgabetyp "{0}" auf. Dies ist gemäß den Regeln von Common IL unzulässig.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveral">
<source>No implementation was given for those members: {0}</source>
<target state="new">No implementation was given for those members: {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralWithSuggestion">
<source>No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncated">
<source>No implementation was given for those members (some results omitted): {0}</source>
<target state="new">No implementation was given for those members (some results omitted): {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncatedWithSuggestion">
<source>No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
20 changes: 20 additions & 0 deletions src/fsharp/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7132,6 +7132,26 @@
<target state="translated">La función o método tiene un tipo de valor devuelto no válido "{0}". Esto no está permitido por las reglas de Common IL.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveral">
<source>No implementation was given for those members: {0}</source>
<target state="new">No implementation was given for those members: {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralWithSuggestion">
<source>No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncated">
<source>No implementation was given for those members (some results omitted): {0}</source>
<target state="new">No implementation was given for those members (some results omitted): {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncatedWithSuggestion">
<source>No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
20 changes: 20 additions & 0 deletions src/fsharp/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7132,6 +7132,26 @@
<target state="translated">La méthode ou la fonction a un type de retour non valide (« {0} »), ce qui n’est pas autorisé par les règles de Common IL.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveral">
<source>No implementation was given for those members: {0}</source>
<target state="new">No implementation was given for those members: {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralWithSuggestion">
<source>No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncated">
<source>No implementation was given for those members (some results omitted): {0}</source>
<target state="new">No implementation was given for those members (some results omitted): {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncatedWithSuggestion">
<source>No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
20 changes: 20 additions & 0 deletions src/fsharp/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7132,6 +7132,26 @@
<target state="translated">La funzione o il metodo contiene un tipo restituito non valido '{0}'. Questo comportamento non è consentito dalle regole di Common IL.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveral">
<source>No implementation was given for those members: {0}</source>
<target state="new">No implementation was given for those members: {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralWithSuggestion">
<source>No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members: {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncated">
<source>No implementation was given for those members (some results omitted): {0}</source>
<target state="new">No implementation was given for those members (some results omitted): {0}</target>
<note />
</trans-unit>
<trans-unit id="typrelNoImplementationGivenSeveralTruncatedWithSuggestion">
<source>No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</source>
<target state="new">No implementation was given for those members (some results omitted): {0}Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Loading