diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index 7d4162f804e..0f3c2f36b48 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -56,6 +56,7 @@ * Fix parallel compilation of scripts ([PR #19649](https://github.com/dotnet/fsharp/pull/19649)) * Fix parser recovery, name resolution, and code completion for unfinished enum patterns ([PR #19708](https://github.com/dotnet/fsharp/pull/19708)) * Parser: fix unexpected diagnostics in debug builds, improve error messages ([PR #19730](https://github.com/dotnet/fsharp/pull/19730)) +* Fix false FS1113 error on inline instance members when a class-scope self identifier (`as self`) is present. ([Issue #17899](https://github.com/dotnet/fsharp/issues/17899), [PR #19761](https://github.com/dotnet/fsharp/pull/19761)) * Fix signature conformance: overloaded member with unit parameter `M(())` now matches sig `member M: unit -> unit`. ([Issue #19596](https://github.com/dotnet/fsharp/issues/19596), [PR #19615](https://github.com/dotnet/fsharp/pull/19615)) ### Added diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index 3cbb574598c..f0a94c66516 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -496,7 +496,7 @@ let rec IsPartialExprVal x = | SizeValue (_, a) -> IsPartialExprVal a let CheckInlineValueIsComplete (v: Val) res = - if v.ShouldInline && IsPartialExprVal res then + if v.ShouldInline && not v.IsMember && IsPartialExprVal res then errorR(Error(FSComp.SR.optValueMarkedInlineButIncomplete(v.DisplayName), v.Range)) //System.Diagnostics.Debug.Assert(false, sprintf "Break for incomplete inline value %s" v.DisplayName) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/MemberDeclarations.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/MemberDeclarations.fs index d69fb460957..03f225ee4d1 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/MemberDeclarations.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/ObjectOrientedTypeDefinitions/ClassTypes/MemberDeclarations/MemberDeclarations.fs @@ -8,6 +8,25 @@ open FSharp.Test.Compiler module MemberDeclarations = + [] + let ``Inline member with class-scope self identifier should compile`` () = + FSharp """ +module Test + +type TestClass1() as SomeSelfIdentifier = + member inline AnotherSelfIdentifier.test() = 5 + +type TestClass2() as self = + member inline self.test() = 5 + +type TestClass3() as self = + member inline _.test() = 5 +""" + |> asLibrary + |> ignoreWarnings + |> compile + |> shouldSucceed + // Error tests []