From 864d04a525d3ef848fc59fbb7aa5e64071401f50 Mon Sep 17 00:00:00 2001
From: Thomas Boby
Date: Sat, 24 Sep 2022 13:38:16 +0100
Subject: [PATCH] Prevent infering type parameters on getset props
---
src/Compiler/Checking/CheckExpressions.fs | 4 +-
tests/fsharp/typecheck/sigs/neg32.bsl | 46 +++++++++++++----------
tests/fsharp/typecheck/sigs/neg32.fs | 9 ++++-
3 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs
index 0ef6963c527..1b65421daba 100644
--- a/src/Compiler/Checking/CheckExpressions.fs
+++ b/src/Compiler/Checking/CheckExpressions.fs
@@ -2185,7 +2185,9 @@ module GeneralizationHelpers =
| Some memberFlags ->
match memberFlags.MemberKind with
// can't infer extra polymorphism for properties
- | SynMemberKind.PropertyGet | SynMemberKind.PropertySet -> false
+ | SynMemberKind.PropertyGet
+ | SynMemberKind.PropertySet
+ | SynMemberKind.PropertyGetSet -> false
// can't infer extra polymorphism for class constructors
| SynMemberKind.ClassConstructor -> false
// can't infer extra polymorphism for constructors
diff --git a/tests/fsharp/typecheck/sigs/neg32.bsl b/tests/fsharp/typecheck/sigs/neg32.bsl
index bb849961393..6afdd7ae5a7 100644
--- a/tests/fsharp/typecheck/sigs/neg32.bsl
+++ b/tests/fsharp/typecheck/sigs/neg32.bsl
@@ -3,42 +3,48 @@ neg32.fs(17,21,17,49): typecheck error FS0842: This attribute is not valid for u
neg32.fs(24,15,24,16): typecheck error FS0043: The member or object constructor 'TryParse' does not take 1 argument(s). An overload was found taking 2 arguments.
-neg32.fs(39,17,39,19): typecheck error FS0039: The type parameter 'T is not defined.
+neg32.fs(43,17,43,19): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(40,4,40,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
+neg32.fs(44,4,44,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
-neg32.fs(40,21,40,23): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(44,21,44,23): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(41,21,41,23): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(45,21,45,23): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(41,27,41,29): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(45,27,45,29): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(42,18,42,20): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(46,18,46,20): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(42,24,42,26): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(46,24,46,26): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(46,17,46,19): typecheck error FS0039: The type parameter 'T is not defined.
+neg32.fs(50,17,50,19): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(47,4,47,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
+neg32.fs(51,4,51,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
-neg32.fs(47,21,47,23): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(51,21,51,23): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(48,21,48,23): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(52,21,52,23): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(48,27,48,29): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(52,27,52,29): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(49,18,49,20): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(53,18,53,20): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(49,24,49,26): typecheck error FS0039: The type parameter 'U is not defined.
+neg32.fs(53,24,53,26): typecheck error FS0039: The type parameter 'U is not defined.
-neg32.fs(52,10,52,12): typecheck error FS0039: The type parameter 'T is not defined.
+neg32.fs(54,18,54,20): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(52,10,52,12): typecheck error FS0039: The type parameter 'T is not defined.
+neg32.fs(55,18,55,20): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(55,11,55,13): typecheck error FS0039: The type parameter 'T is not defined.
+neg32.fs(56,18,56,20): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(55,11,55,13): typecheck error FS0039: The type parameter 'T is not defined.
+neg32.fs(59,10,59,12): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(59,65,59,86): typecheck error FS0033: The non-generic type 'System.EventArgs' does not expect any type arguments, but here is given 1 type argument(s)
+neg32.fs(59,10,59,12): typecheck error FS0039: The type parameter 'T is not defined.
-neg32.fs(59,21,59,27): typecheck error FS1091: The event 'Event1' has a non-standard type. If this event is declared in another CLI language, you may need to access this event using the explicit add_Event1 and remove_Event1 methods for the event. If this event is declared in F#, make the type of the event an instantiation of either 'IDelegateEvent<_>' or 'IEvent<_,_>'.
+neg32.fs(62,11,62,13): typecheck error FS0039: The type parameter 'T is not defined.
+
+neg32.fs(62,11,62,13): typecheck error FS0039: The type parameter 'T is not defined.
+
+neg32.fs(66,65,66,86): typecheck error FS0033: The non-generic type 'System.EventArgs' does not expect any type arguments, but here is given 1 type argument(s)
+
+neg32.fs(66,21,66,27): typecheck error FS1091: The event 'Event1' has a non-standard type. If this event is declared in another CLI language, you may need to access this event using the explicit add_Event1 and remove_Event1 methods for the event. If this event is declared in F#, make the type of the event an instantiation of either 'IDelegateEvent<_>' or 'IEvent<_,_>'.
diff --git a/tests/fsharp/typecheck/sigs/neg32.fs b/tests/fsharp/typecheck/sigs/neg32.fs
index 4ff91d11dcf..a8893b86bbe 100644
--- a/tests/fsharp/typecheck/sigs/neg32.fs
+++ b/tests/fsharp/typecheck/sigs/neg32.fs
@@ -34,7 +34,11 @@ type PositiveClass<'A>() =
abstract M<'T> : 'T -> 'T
abstract M2<'T> : 'T -> 'A
abstract M : 'U -> 'U
-
+ abstract M3 : 'A with get, set
+ abstract M4 : 'A with set
+ abstract M5 : 'A with get
+
+
type NegativeInterface =
abstract v : 'T
abstract M<'T> : 'U
@@ -47,6 +51,9 @@ type NegativeClass() =
abstract M<'T> : 'U
abstract M<'T> : 'U -> 'U
abstract M : ('U -> 'U)
+ abstract M2 : 'T with get, set
+ abstract M3 : 'T with set
+ abstract M4 : 'T with get
type NegativeRecord =
{ v : 'T }