Skip to content

No compile-time error for partial implementation of interface with static abstract members #17138

@brianrourkeboll

Description

@brianrourkeboll

There is no compile-time error if a type only partially implements an interface with static abstract members (IWSAM). If you try to use the partial implementation, a System.TypeLoadException is raised at runtime.

Repro steps

#nowarn "3535"

type IFace =
    static abstract P1 : int
    static abstract P2 : int

type T =
    interface IFace with
        static member P1 = 1

let inline p1<'T & #IFace> = 'T.P1

p1<T>

Runtime error:

Unhandled exception. System.TypeLoadException: Virtual static method 'get_P2' is not implemented on type 'T' from assembly 'ConsoleApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at <StartupCode$ConsoleApp1>.$Program.main@()

Expected behavior

There should be a compile-time error indicating that all abstract methods on the interface must be implemented.

Actual behavior

There is no compile-time error; there is an error at runtime instead.

Known workarounds

N/A

Related information

.NET 8/9 preview.

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
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions