Poor diagnostic when implementing abstract member
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
I have a ViewModelBase that needs to create sub view models. So I defined a `Create` method that returns the same generic type with different type parameters
``` F#
type [] internal ViewModelBase<'model, 'msg>
( initialModel: 'model,
dispatch: 'msg -> unit,
bindings: Binding<'model, 'msg> list,
config: ElmConfig,
propNameChain: string)
as this =
inherit DynamicObject()
abstract member Create
: initialModel: obj * dispatch: (obj -> unit) * bindings: Binding list * config: ElmConfig * propNameChain: string
-> ViewModelBase
```
``` F#
type internal ViewModel<'model, 'msg>(initialModel: 'model, dispatch: Dispatch<'msg>, bindings: Binding<'model, 'msg> list, config, propNameChain) =
inherit ViewModelBase<'model, 'msg>(initialModel, dispatch, bindings, config, propNameChain)
override _.Create (initialModel, dispatch, bindings, config, propNameChain) =
ViewModel(initialModel, dispatch, bindings, config, propNameChain)
```
So I get

Then I tried
``` F#
abstract member Create<'subModel, 'subMsg>
: initialModel: 'subModel * dispatch: ('subMsg -> unit) * bindings: Binding<'subModel, 'subMsg> list * config: ElmConfig * propNameChain: string
-> ViewModelBase<'subModel, 'subMsg>
```
``` F#
override _.Create<'subModel, 'subMsg>(initialModel: 'subModel, dispatch: Dispatch<'subMsg>, bindings: Binding<'subModel, 'subMsg> list, config, propNameChain) =
ViewModel<'subModel, 'subMsg>(initialModel, dispatch, bindings, config, propNameChain) :> _
```
but got

**Repro steps**
1. Clone https://github.com/xperiandri/Elmish.Uno/tree/incremental_load
2. Check out `incremental_load` branch
3. Go to `ViewModelModule.fs`
**Expected behavior**
The compiler uses declared type constraints.
**Actual behavior**
Compiler mixes type type constraints with method type constraints.
**Known workarounds**
No
**Related information**
F# 5.0.1
Contributor guide
Assessment
This issue has not been assessed yet.