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

Commitdded030

Browse files
vasily-kirichenkoTIHan
authored andcommitted
Typecheck method args even though it's not resolved (#4105)
* typecheck method args even though it's not resolved* fix tests* add a test
1 parentd19fb00 commitdded030

File tree

4 files changed

+81
-12
lines changed

4 files changed

+81
-12
lines changed

‎src/fsharp/TypeChecker.fs‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9454,16 +9454,7 @@ and TcMethodApplication
94549454

94559455
let uniquelyResolved =
94569456
let csenv = MakeConstraintSolverEnv ContextInfo.NoContext cenv.css mMethExpr denv
9457-
let res = UnifyUniqueOverloading csenv callerArgCounts methodName ad preArgumentTypeCheckingCalledMethGroup returnTy
9458-
9459-
match res with
9460-
| ErrorResult _ ->
9461-
match afterResolution with
9462-
| AfterResolution.DoNothing -> ()
9463-
| AfterResolution.RecordResolution(_, _, _, onFailure) -> onFailure()
9464-
| _ -> ()
9465-
9466-
res |> CommitOperationResult
9457+
UnifyUniqueOverloading csenv callerArgCounts methodName ad preArgumentTypeCheckingCalledMethGroup returnTy
94679458

94689459
uniquelyResolved, preArgumentTypeCheckingCalledMethGroup
94699460

@@ -9496,7 +9487,7 @@ and TcMethodApplication
94969487
else
94979488
[domainTy]
94989489
[argTys], returnTy
9499-
9490+
95009491
let lambdaVarsAndExprs = curriedArgTys |> List.mapiSquared (fun i j ty -> mkCompGenLocal mMethExpr ("arg"+string i+string j) ty)
95019492
let unnamedCurriedCallerArgs = lambdaVarsAndExprs |> List.mapSquared (fun (_, e) -> CallerArg(tyOfExpr cenv.g e, e.Range, false, e))
95029493
let namedCurriedCallerArgs = lambdaVarsAndExprs |> List.map (fun _ -> [])
@@ -9530,6 +9521,16 @@ and TcMethodApplication
95309521
let preArgumentTypeCheckingCalledMethGroup =
95319522
preArgumentTypeCheckingCalledMethGroup |> List.map (fun cmeth -> (cmeth.Method, cmeth.CalledTyArgs, cmeth.AssociatedPropertyInfo, cmeth.UsesParamArrayConversion))
95329523

9524+
let uniquelyResolved =
9525+
match uniquelyResolved with
9526+
| ErrorResult _ ->
9527+
match afterResolution with
9528+
| AfterResolution.DoNothing -> ()
9529+
| AfterResolution.RecordResolution(_, _, _, onFailure) -> onFailure()
9530+
| _ -> ()
9531+
9532+
uniquelyResolved |> CommitOperationResult
9533+
95339534
// STEP 3. Resolve overloading
95349535
/// Select the called method that's the result of overload resolution
95359536
let finalCalledMeth =

‎tests/fsharp/typecheck/sigs/neg20.bsl‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,26 @@ is not compatible with type
211211
'int []'
212212
.
213213

214+
neg20.fs(183,29,183,34): typecheck error FS0001: This expression was expectedto have type
215+
'int'
216+
but here has type
217+
'obj'
218+
219+
neg20.fs(183,29,183,34): typecheck error FS0001: This expression was expectedto have type
220+
'int'
221+
but here has type
222+
'obj'
223+
224+
neg20.fs(183,35,183,40): typecheck error FS0001: This expression was expectedto have type
225+
'int'
226+
but here has type
227+
'obj'
228+
229+
neg20.fs(183,35,183,40): typecheck error FS0001: This expression was expectedto have type
230+
'int'
231+
but here has type
232+
'obj'
233+
214234
neg20.fs(183,14,183,41): typecheck error FS0001: This expression was expectedto have type
215235
'unit'
216236
but here has type
@@ -248,6 +268,26 @@ is not compatible with type
248268
'string []'
249269
.
250270

271+
neg20.fs(189,29,189,34): typecheck error FS0001: This expression was expectedto have type
272+
'string'
273+
but here has type
274+
'obj'
275+
276+
neg20.fs(189,29,189,34): typecheck error FS0001: This expression was expectedto have type
277+
'string'
278+
but here has type
279+
'obj'
280+
281+
neg20.fs(189,35,189,40): typecheck error FS0001: This expression was expectedto have type
282+
'string'
283+
but here has type
284+
'obj'
285+
286+
neg20.fs(189,35,189,40): typecheck error FS0001: This expression was expectedto have type
287+
'string'
288+
but here has type
289+
'obj'
290+
251291
neg20.fs(189,14,189,41): typecheck error FS0001: This expression was expectedto have type
252292
'unit'
253293
but here has type

‎tests/fsharp/typecheck/sigs/neg67.vsbsl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ neg67.fsx(42,35,42,36): parse error FS0010: Unexpected symbol '}' in definition.
1818
neg67.fsx(41,9,41,14): typecheck error FS0001: This expression was expected to have type
1919
'unit'
2020
but here has type
21-
'Async<'a>'
21+
'Async<unit>'
2222

2323
neg67.fsx(30,1,41,37): typecheck error FS0003: This value is not a function and cannot be applied.

‎vsintegration/tests/unittests/Tests.LanguageService.Completion.fs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,35 @@ for i in 0..a."]
10291029
for(code, marker)in useCasesdo
10301030
letcode= prologue@[code]
10311031
AssertCtrlSpaceCompleteContains code marker[]["field1";"field2"]
1032+
1033+
[<Test>]
1034+
[<Category("Records")>]
1035+
memberpublicthis.``Records.InferByFieldsInPriorMethodArguments``()=
1036+
1037+
letprologue=
1038+
[
1039+
"type T() ="
1040+
" new (left: float32, top: float32) = T()"
1041+
" new (left: float32, top: float32, width: float32, height: float32) = T()"
1042+
""
1043+
"type Rect ="
1044+
" { Left: float32"
1045+
" Top: float32"
1046+
" Width: float32"
1047+
" Height: float32 }"
1048+
]
10321049

1050+
letuseCases=
1051+
[
1052+
"let toT(original) = T(original.Left, (* MARKER*)original.)","(* MARKER*)original.",["Left";"Top";"Width";"Height"]
1053+
"let toT(original) = T(original.Left, original.Height, (* MARKER*)original.)","(* MARKER*)original.",["Left";"Top";"Width";"Height"]
1054+
"let toT(original) = T(original.Left, original.Height, original.Width, (* MARKER*)original.)","(* MARKER*)original.",["Left";"Top";"Width";"Height"]
1055+
"let toT(original) = T(original.Left, original.Height, (* MARKER*)original., original.Width)","(* MARKER*)original.",["Left";"Top";"Width";"Height"]
1056+
]
1057+
1058+
for(code, marker, should)in useCasesdo
1059+
letcode= prologue@[code]
1060+
AssertCtrlSpaceCompleteContains code marker should[]
10331061

10341062
[<Test>]
10351063
memberthis.``Completion.DetectInterfaces``()=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp