Skip to content

Commit 8244fe4

Browse files
authored
Prevent infering type parameters on getset props (#13978)
1 parent c7bae31 commit 8244fe4

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,9 @@ module GeneralizationHelpers =
21852185
| Some memberFlags ->
21862186
match memberFlags.MemberKind with
21872187
// can't infer extra polymorphism for properties
2188-
| SynMemberKind.PropertyGet | SynMemberKind.PropertySet -> false
2188+
| SynMemberKind.PropertyGet
2189+
| SynMemberKind.PropertySet
2190+
| SynMemberKind.PropertyGetSet -> false
21892191
// can't infer extra polymorphism for class constructors
21902192
| SynMemberKind.ClassConstructor -> false
21912193
// can't infer extra polymorphism for constructors

tests/fsharp/typecheck/sigs/neg32.bsl

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,48 @@ neg32.fs(17,21,17,49): typecheck error FS0842: This attribute is not valid for u
33

44
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.
55

6-
neg32.fs(39,17,39,19): typecheck error FS0039: The type parameter 'T is not defined.
6+
neg32.fs(43,17,43,19): typecheck error FS0039: The type parameter 'T is not defined.
77

8-
neg32.fs(40,4,40,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
8+
neg32.fs(44,4,44,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
99

10-
neg32.fs(40,21,40,23): typecheck error FS0039: The type parameter 'U is not defined.
10+
neg32.fs(44,21,44,23): typecheck error FS0039: The type parameter 'U is not defined.
1111

12-
neg32.fs(41,21,41,23): typecheck error FS0039: The type parameter 'U is not defined.
12+
neg32.fs(45,21,45,23): typecheck error FS0039: The type parameter 'U is not defined.
1313

14-
neg32.fs(41,27,41,29): typecheck error FS0039: The type parameter 'U is not defined.
14+
neg32.fs(45,27,45,29): typecheck error FS0039: The type parameter 'U is not defined.
1515

16-
neg32.fs(42,18,42,20): typecheck error FS0039: The type parameter 'U is not defined.
16+
neg32.fs(46,18,46,20): typecheck error FS0039: The type parameter 'U is not defined.
1717

18-
neg32.fs(42,24,42,26): typecheck error FS0039: The type parameter 'U is not defined.
18+
neg32.fs(46,24,46,26): typecheck error FS0039: The type parameter 'U is not defined.
1919

20-
neg32.fs(46,17,46,19): typecheck error FS0039: The type parameter 'T is not defined.
20+
neg32.fs(50,17,50,19): typecheck error FS0039: The type parameter 'T is not defined.
2121

22-
neg32.fs(47,4,47,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
22+
neg32.fs(51,4,51,23): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
2323

24-
neg32.fs(47,21,47,23): typecheck error FS0039: The type parameter 'U is not defined.
24+
neg32.fs(51,21,51,23): typecheck error FS0039: The type parameter 'U is not defined.
2525

26-
neg32.fs(48,21,48,23): typecheck error FS0039: The type parameter 'U is not defined.
26+
neg32.fs(52,21,52,23): typecheck error FS0039: The type parameter 'U is not defined.
2727

28-
neg32.fs(48,27,48,29): typecheck error FS0039: The type parameter 'U is not defined.
28+
neg32.fs(52,27,52,29): typecheck error FS0039: The type parameter 'U is not defined.
2929

30-
neg32.fs(49,18,49,20): typecheck error FS0039: The type parameter 'U is not defined.
30+
neg32.fs(53,18,53,20): typecheck error FS0039: The type parameter 'U is not defined.
3131

32-
neg32.fs(49,24,49,26): typecheck error FS0039: The type parameter 'U is not defined.
32+
neg32.fs(53,24,53,26): typecheck error FS0039: The type parameter 'U is not defined.
3333

34-
neg32.fs(52,10,52,12): typecheck error FS0039: The type parameter 'T is not defined.
34+
neg32.fs(54,18,54,20): typecheck error FS0039: The type parameter 'T is not defined.
3535

36-
neg32.fs(52,10,52,12): typecheck error FS0039: The type parameter 'T is not defined.
36+
neg32.fs(55,18,55,20): typecheck error FS0039: The type parameter 'T is not defined.
3737

38-
neg32.fs(55,11,55,13): typecheck error FS0039: The type parameter 'T is not defined.
38+
neg32.fs(56,18,56,20): typecheck error FS0039: The type parameter 'T is not defined.
3939

40-
neg32.fs(55,11,55,13): typecheck error FS0039: The type parameter 'T is not defined.
40+
neg32.fs(59,10,59,12): typecheck error FS0039: The type parameter 'T is not defined.
4141

42-
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)
42+
neg32.fs(59,10,59,12): typecheck error FS0039: The type parameter 'T is not defined.
4343

44-
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<_,_>'.
44+
neg32.fs(62,11,62,13): typecheck error FS0039: The type parameter 'T is not defined.
45+
46+
neg32.fs(62,11,62,13): typecheck error FS0039: The type parameter 'T is not defined.
47+
48+
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)
49+
50+
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<_,_>'.

tests/fsharp/typecheck/sigs/neg32.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ type PositiveClass<'A>() =
3434
abstract M<'T> : 'T -> 'T
3535
abstract M2<'T> : 'T -> 'A
3636
abstract M : 'U -> 'U
37-
37+
abstract M3 : 'A with get, set
38+
abstract M4 : 'A with set
39+
abstract M5 : 'A with get
40+
41+
3842
type NegativeInterface =
3943
abstract v : 'T
4044
abstract M<'T> : 'U
@@ -47,6 +51,9 @@ type NegativeClass() =
4751
abstract M<'T> : 'U
4852
abstract M<'T> : 'U -> 'U
4953
abstract M : ('U -> 'U)
54+
abstract M2 : 'T with get, set
55+
abstract M3 : 'T with set
56+
abstract M4 : 'T with get
5057

5158
type NegativeRecord =
5259
{ v : 'T }

0 commit comments

Comments
 (0)