Skip to content

Intrinsic extensions for static methods in interfaces fail to compile #15990

@gusty

Description

@gusty

Intrinsic extensions for static methods in interfaces fail to compile

Repro steps

[<Interface>]
type MyInterface<'T> =
    interface end
type MyInterface with
    static member ByPass (x: MyInterface<'t>) = x

Expected behavior

Compile

Actual behavior

Error: stdin(6,6): error FS0956: Members that extend interface, delegate or enum types must be placed in a module separate to the definition of the type. This module must either have the AutoOpen attribute or be opened explicitly by client code to bring the extension members into scope.

Known workarounds

Removing lines 2 and 3, but obviously in real life code this means duplicating all the module let bindings code that might sit between those 2 lines and are needed to implement ByPass and other static members defined in the interface.

Related information

Provide any related information (optional):

Microsoft (R) F# Interactive version 12.8.0.0 for F# 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions