Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0eb04a4

Browse files
forkiKevinRansom
authored andcommitted
Static vs. nonstatic method conflicts are properly reported (dotnet#2256)
* Static vs. nonstatic method conflicts are properly reported -fixesdotnet#2255* Fix tests
1 parentf50a2dd commit0eb04a4

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

‎src/fsharp/FSComp.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,3 +1332,4 @@ tcTupleStructMismatch,"One tuple type is a struct tuple, the other is a referenc
13321332
3211,DefaultParameterValueNotAppropriateForArgument,"The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'."
13331333
tcGlobalsSystemTypeNotFound,"The system type '%s' was required but no referenced system DLL contained this type"
13341334
3213,typrelMemberHasMultiplePossibleDispatchSlots,"The member '%s' matches multiple overloads of the same method.\nPlease restrict it to one of the following:%s."
1335+
3214,methodIsNotStatic,"Method or object constructor '%s' is not static"

‎src/fsharp/NameResolution.fs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,11 +3127,17 @@ type AfterOverloadResolution =
31273127
///
31283128
/// Called for 'TypeName.Bar' - for VS IntelliSense, we can filter out instance members from method groups
31293129
letResolveLongIdentAsExprAndComputeRange(sink:TcResultsSink)(ncenv:NameResolver)wholem ad nenv typeNameResInfo lid=
3130-
letitem,rest= ResolveExprLongIdent sink ncenv wholem ad nenv typeNameResInfo lid
3130+
letitem1,rest= ResolveExprLongIdent sink ncenv wholem ad nenv typeNameResInfo lid
31313131
letitemRange= ComputeItemRange wholem lid rest
31323132

31333133
// Record the precise resolution of the field for intellisense
3134-
letitem= FilterMethodGroups ncenv itemRange itemtrue
3134+
letitem= FilterMethodGroups ncenv itemRange item1true
3135+
3136+
match item1,itemwith
3137+
| Item.MethodGroup(name, minfos1,_), Item.MethodGroup(_,[],_)whennot(isNil minfos1)->
3138+
error(Error(FSComp.SR.methodIsNotStatic(name),wholem))
3139+
|_->()
3140+
31353141
// Fake idents e.g. 'Microsoft.FSharp.Core.None' have identical ranges for each part
31363142
letisFakeIdents=
31373143
match lidwith

‎tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/MethodsAndProperties/E_useInstMethodThroughStatic.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #Regression #Conformance #DeclarationElements #MemberDefinitions #MethodsAndProperties
2-
//<Expects status="error"x x-first x-last">FS0509" span="(10,14)">Method or object constructor 'DoStuff' notfound$</Expects>
2+
//<Expects status="error"x x-first x-last">FS3214" span="(10,14)">Method or object constructor 'DoStuff'isnotstatic$</Expects>
33

44
typeFoo()=
55
letm_val=0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #Warnings
2+
//<Expects status="Error" span="(7,9)" id="FS3214">Method or object constructor 'X' is not static</Expects>
3+
4+
typeClass1()=
5+
memberthis.X()="F#"
6+
7+
letx= Class1.X()
8+
9+
exit0

‎tests/fsharpqa/Source/Warnings/env.lst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
SOURCE=FS0988AtEndOfFile.fs # FS0988AtEndOfFile.fs
1515
SOURCE=WrongArity.fs # WrongArity.fs
1616
SOURCE=OverrideErrors.fs # OverrideErrors.fs
17+
SOURCE=MethodIsNotStatic.fs # MethodIsNotStatic.fs
1718
SOURCE=AccessOfTypeAbbreviation.fs # AccessOfTypeAbbreviation.fs
1819
SOURCE=AccessOfTypeAbbreviation2.fs # AccessOfTypeAbbreviation2.fs
1920
SOURCE=AccessOfTypeAbbreviation3.fs # AccessOfTypeAbbreviation3.fs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp