Skip to content

Commit d9fed81

Browse files
authored
Disallow explicit type parameters on getset properties (#14212)
1 parent 9d82592 commit d9fed81

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,8 @@ module GeneralizationHelpers =
21692169
match memberFlags.MemberKind with
21702170
// can't infer extra polymorphism for properties
21712171
| SynMemberKind.PropertyGet
2172-
| SynMemberKind.PropertySet ->
2172+
| SynMemberKind.PropertySet
2173+
| SynMemberKind.PropertyGetSet ->
21732174
if not (isNil declaredTypars) then
21742175
errorR(Error(FSComp.SR.tcPropertyRequiresExplicitTypeParameters(), m))
21752176
| SynMemberKind.Constructor ->

tests/fsharp/typecheck/sigs/neg32.bsl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ neg32.fs(55,18,55,20): typecheck error FS0039: The type parameter 'T is not defi
3737

3838
neg32.fs(56,18,56,20): typecheck error FS0039: The type parameter 'T is not defined.
3939

40-
neg32.fs(59,10,59,12): typecheck error FS0039: The type parameter 'T is not defined.
40+
neg32.fs(57,4,57,38): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
4141

42-
neg32.fs(59,10,59,12): typecheck error FS0039: The type parameter 'T is not defined.
42+
neg32.fs(58,4,58,33): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
4343

44-
neg32.fs(62,11,62,13): typecheck error FS0039: The type parameter 'T is not defined.
44+
neg32.fs(59,4,59,33): typecheck error FS0671: A property cannot have explicit type parameters. Consider using a method instead.
4545

46-
neg32.fs(62,11,62,13): typecheck error FS0039: The type parameter 'T is not defined.
46+
neg32.fs(62,10,62,12): typecheck error FS0039: The type parameter 'T is not defined.
4747

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

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<_,_>'.
50+
neg32.fs(65,11,65,13): typecheck error FS0039: The type parameter 'T is not defined.
51+
52+
neg32.fs(65,11,65,13): typecheck error FS0039: The type parameter 'T is not defined.
53+
54+
neg32.fs(69,65,69,86): typecheck error FS0033: The non-generic type 'System.EventArgs' does not expect any type arguments, but here is given 1 type argument(s)
55+
56+
neg32.fs(69,21,69,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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ type NegativeClass() =
5454
abstract M2 : 'T with get, set
5555
abstract M3 : 'T with set
5656
abstract M4 : 'T with get
57+
abstract M5<'T> : 'T with get, set
58+
abstract M6<'T> : 'T with set
59+
abstract M7<'T> : 'T with get
5760

5861
type NegativeRecord =
5962
{ v : 'T }

0 commit comments

Comments
 (0)