diff --git a/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs b/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs index 6ba4f3cb5..01d939e87 100644 --- a/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs +++ b/src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs @@ -43,8 +43,9 @@ let private generateFix (text:string) range = lazy( let runner args = match args.AstNode, args.CheckInfo with - | AstNode.Expression(SynExpr.New(_, SynType.LongIdent(identifier), _, range)), Some checkInfo - | AstNode.Expression(SynExpr.New(_, SynType.App(SynType.LongIdent(identifier), _, _, _, _, _, _), _, range)), Some checkInfo -> + | AstNode.Expression (SynExpr.Upcast (SynExpr.New (_, SynType.LongIdent (identifier), _, range), _, _)), Some checkInfo + | AstNode.Expression (SynExpr.New(_, SynType.LongIdent(identifier), _, range)), Some checkInfo + | AstNode.Expression (SynExpr.New(_, SynType.App(SynType.LongIdent(identifier), _, _, _, _, _, _), _, range)), Some checkInfo -> { Range = range Message = Resources.GetString("RulesRedundantNewKeyword") SuggestedFix = Some (generateFix args.FileContent range) diff --git a/tests/FSharpLint.Core.Tests/Rules/Conventions/RedundantNewKeyword.fs b/tests/FSharpLint.Core.Tests/Rules/Conventions/RedundantNewKeyword.fs index f82d4e80d..6ab5b49bd 100644 --- a/tests/FSharpLint.Core.Tests/Rules/Conventions/RedundantNewKeyword.fs +++ b/tests/FSharpLint.Core.Tests/Rules/Conventions/RedundantNewKeyword.fs @@ -66,3 +66,24 @@ module Program new Int32() |> ignore""") Assert.IsTrue this.ErrorsExist + + [] + member this.``new keyword is required.``() = + this.Parse( + """ +open System + +type ISomeInterfaceWithDisposable = + interface + inherit IDisposable + end + +type SomeDisposableType() = + interface ISomeInterfaceWithDisposable with + member _.Dispose() = () + +module Program = + let foo = new SomeDisposableType() :> ISomeInterfaceWithDisposable""" + ) + + this.AssertNoWarnings()