Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
* Interpolated string holes (e.g. `$"{x}"`) are now formatted with invariant culture (via the `string` operator) instead of the current thread culture. ([PR #19971](https://github.com/dotnet/fsharp/pull/19971))
* Lines starting with `#:` are now ignored ([Language suggestion 1440](https://github.com/fsharp/fslang-suggestions/issues/1440), [RFC FS-1337](https://github.com/fsharp/fslang-design/pull/830), [PR #20212](https://github.com/dotnet/fsharp/pull/20212))
* Calculate Entity.PublicPath instead of storing ([PR #20285](https://github.com/dotnet/fsharp/pull/20285))
* Remove the always-on `NullableOptionalInterop` language feature flag and collapse its guarded code to the enabled path; `--disableLanguageFeature:NullableOptionalInterop` is no longer a recognized feature name. ([Issue #20154](https://github.com/dotnet/fsharp/issues/20154), [PR #20378](https://github.com/dotnet/fsharp/pull/20378))

### Breaking Changes
* Add `ExtendedLayoutAttribute` support for future .NET runtime interop. `ILTypeDefLayout` has a new `Extended` case. ([Issue #19190](https://github.com/dotnet/fsharp/issues/19190), [PR #19194](https://github.com/dotnet/fsharp/pull/19194))
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5883,7 +5883,7 @@ and TcAdjustExprForTypeDirectedConversions (cenv: cenv) (overallTy: OverallTy) a
let g = cenv.g

match overallTy with
| MustConvertTo (isMethodArg, reqdTy) when g.langVersion.SupportsFeature LanguageFeature.AdditionalTypeDirectedConversions || (g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop && isMethodArg) ->
| MustConvertTo (isMethodArg, reqdTy) when g.langVersion.SupportsFeature LanguageFeature.AdditionalTypeDirectedConversions || isMethodArg ->
let tcVal = LightweightTcValForUsingInBuildMethodCall g env.TraitContext
AdjustExprForTypeDirectedConversions tcVal g cenv.amap cenv.infoReader env.AccessRights reqdTy actualTy m expr
| _ ->
Expand Down
31 changes: 9 additions & 22 deletions src/Compiler/Checking/MethodCalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ let rec AdjustRequiredTypeForTypeDirectedConversions (infoReader: InfoReader) ad
elif g.langVersion.SupportsFeature LanguageFeature.AdditionalTypeDirectedConversions && typeEquiv g g.float_ty reqdTy && typeEquiv g g.int32_ty actualTy then
g.int32_ty, TypeDirectedConversionUsed.Yes(warn TypeDirectedConversion.BuiltIn, false, false), None

elif g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop && isMethodArg && isNullableTy g reqdTy && not (isNullableTy g actualTy) then
elif isMethodArg && isNullableTy g reqdTy && not (isNullableTy g actualTy) then
let underlyingTy = destNullableTy g reqdTy
// shortcut
if typeEquiv g underlyingTy actualTy then
Expand Down Expand Up @@ -365,17 +365,13 @@ let AdjustCalledArgTypeForOptionals (infoReader: InfoReader) ad enforceNullableO
match calledArg.OptArgInfo with
// CSharpMethod(?x = arg), optional C#-style argument, may have nullable type
| CallerSide _ ->
if g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop then

let calledArgTy =
if isNullableTy g calledArgTy then
destNullableTy g calledArgTy
else
calledArgTy
let calledArgTy =
if isNullableTy g calledArgTy then
destNullableTy g calledArgTy
else
calledArgTy

mkOptionalTy g calledArgTy, TypeDirectedConversionUsed.No, None
else
calledArgTy, TypeDirectedConversionUsed.No, None
mkOptionalTy g calledArgTy, TypeDirectedConversionUsed.No, None

// FSharpMethod(?x = arg), optional F#-style argument
| CalleeSide ->
Expand All @@ -387,15 +383,11 @@ let AdjustCalledArgTypeForOptionals (infoReader: InfoReader) ad enforceNullableO
AdjustCalledArgTypeForTypeDirectedConversionsAndAutoQuote infoReader ad callerArgTy calledArgTy calledArg m
else
match calledArg.OptArgInfo with
// CSharpMethod(x = arg), non-optional C#-style argument, may have type Nullable<ty>.
| NotOptional when not (g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop) ->
AdjustCalledArgTypeForTypeDirectedConversionsAndAutoQuote infoReader ad callerArgTy calledArgTy calledArg m

// The arg should have type ty. However for backwards compat, we also allow arg to have type Nullable<ty>
| NotOptional
// CSharpMethod(x = arg), optional C#-style argument, may have type Nullable<ty>.
| CallerSide _ ->
if isNullableTy g calledArgTy && g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop then
if isNullableTy g calledArgTy then
// If inference has worked out it's a nullable then use this
if isNullableTy g callerArgTy then
calledArgTy, TypeDirectedConversionUsed.No, None
Expand Down Expand Up @@ -1470,8 +1462,7 @@ let rec AdjustExprForTypeDirectedConversions tcVal (g: TcGlobals) amap infoReade

mkCallToDoubleOperator g m actualTy expr

elif g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop &&
isNullableTy g reqdTy && not (isNullableTy g actualTy) then
elif isNullableTy g reqdTy && not (isNullableTy g actualTy) then

let underlyingTy = destNullableTy g reqdTy
let adjustedExpr = AdjustExprForTypeDirectedConversions tcVal g amap infoReader ad underlyingTy actualTy m expr
Expand Down Expand Up @@ -1627,10 +1618,6 @@ let AdjustCallerArgForOptional tcVal tcFieldInit eCallerMemberName (infoReader:
let reflArgInfo = calledArg.ReflArgInfo
let calledArgTy = calledArg.CalledArgumentType
match calledArg.OptArgInfo with
| NotOptional when not (g.langVersion.SupportsFeature LanguageFeature.NullableOptionalInterop) ->
if isOptCallerArg then errorR(Error(FSComp.SR.tcFormalArgumentIsNotOptional(), m))
assignedArg

// For non-nullable, non-optional arguments no conversion is needed.
// We return precisely the assignedArg. This also covers the case where there
// can be a lingering permitted type mismatch between caller argument and called argument,
Expand Down
11 changes: 3 additions & 8 deletions src/Compiler/Checking/OverloadResolutionRules.fs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,8 @@ let private compareArg (ctx: OverloadResolutionContext) (calledArg1: CalledArg)
// T is always better than inref<T>
| _ when isInByrefTy g ty2 && typeEquiv g ty1 (destByrefTy g ty2) -> true

// T is always better than Nullable<T> from F# 5.0 onwards
| _ when
g.langVersion.SupportsFeature(LanguageFeature.NullableOptionalInterop)
&& isNullableTy g ty2
&& typeEquiv g ty1 (destNullableTy g ty2)
->
true
// T is always better than Nullable<T>
| _ when isNullableTy g ty2 && typeEquiv g ty1 (destNullableTy g ty2) -> true

| _ -> false)

Expand Down Expand Up @@ -490,7 +485,7 @@ let private moreConcreteRule: TiebreakRule =
let private nullableOptionalInteropRule: TiebreakRule =
{
Id = TiebreakRuleId.NullableOptionalInterop
RequiredFeature = Some LanguageFeature.NullableOptionalInterop
RequiredFeature = None
Compare =
fun ctx (struct (candidate, _, _)) (struct (other, _, _)) ->
let args1 = candidate.AllCalledArgs |> List.concat
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,6 @@ featurePackageManagement,"package management"
featureFromEndSlicing,"from-end slicing"
featureNullnessChecking,"nullness checking"
featureResumableStateMachines,"resumable state machines"
featureNullableOptionalInterop,"nullable optional interop"
featureDefaultInterfaceMemberConsumption,"default interface member consumption"
featureStringInterpolation,"string interpolation"
featureWitnessPassing,"witness passing for trait constraints in F# quotations"
Expand Down
3 changes: 0 additions & 3 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type LanguageFeature =
| PackageManagement
| FromEndSlicing
| ResumableStateMachines
| NullableOptionalInterop
| DefaultInterfaceMemberConsumption
| WitnessPassing
| AdditionalTypeDirectedConversions
Expand Down Expand Up @@ -139,7 +138,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array)
[
// F# 5.0
LanguageFeature.DotlessFloat32Literal, languageVersion50
LanguageFeature.NullableOptionalInterop, languageVersion50
LanguageFeature.DefaultInterfaceMemberConsumption, languageVersion50
LanguageFeature.PackageManagement, languageVersion50
LanguageFeature.WitnessPassing, languageVersion50
Expand Down Expand Up @@ -341,7 +339,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array)
| LanguageFeature.FromEndSlicing -> FSComp.SR.featureFromEndSlicing ()
| LanguageFeature.NullnessChecking -> FSComp.SR.featureNullnessChecking ()
| LanguageFeature.ResumableStateMachines -> FSComp.SR.featureResumableStateMachines ()
| LanguageFeature.NullableOptionalInterop -> FSComp.SR.featureNullableOptionalInterop ()
| LanguageFeature.DefaultInterfaceMemberConsumption -> FSComp.SR.featureDefaultInterfaceMemberConsumption ()
| LanguageFeature.WitnessPassing -> FSComp.SR.featureWitnessPassing ()
| LanguageFeature.AdditionalTypeDirectedConversions -> FSComp.SR.featureAdditionalImplicitConversions ()
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type LanguageFeature =
| PackageManagement
| FromEndSlicing
| ResumableStateMachines
| NullableOptionalInterop
| DefaultInterfaceMemberConsumption
| WitnessPassing
| AdditionalTypeDirectedConversions
Expand Down
5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading