提交 dded030d 编写于 作者: V Vasily Kirichenko 提交者: Will Smith

Typecheck method args even though it's not resolved (#4105)

* typecheck method args even though it's not resolved

* fix tests

* add a test
上级 d19fb00f
......@@ -9454,16 +9454,7 @@ and TcMethodApplication
let uniquelyResolved =
let csenv = MakeConstraintSolverEnv ContextInfo.NoContext cenv.css mMethExpr denv
let res = UnifyUniqueOverloading csenv callerArgCounts methodName ad preArgumentTypeCheckingCalledMethGroup returnTy
match res with
| ErrorResult _ ->
match afterResolution with
| AfterResolution.DoNothing -> ()
| AfterResolution.RecordResolution(_, _, _, onFailure) -> onFailure()
| _ -> ()
res |> CommitOperationResult
UnifyUniqueOverloading csenv callerArgCounts methodName ad preArgumentTypeCheckingCalledMethGroup returnTy
uniquelyResolved, preArgumentTypeCheckingCalledMethGroup
......@@ -9496,7 +9487,7 @@ and TcMethodApplication
else
[domainTy]
[argTys], returnTy
let lambdaVarsAndExprs = curriedArgTys |> List.mapiSquared (fun i j ty -> mkCompGenLocal mMethExpr ("arg"+string i+string j) ty)
let unnamedCurriedCallerArgs = lambdaVarsAndExprs |> List.mapSquared (fun (_, e) -> CallerArg(tyOfExpr cenv.g e, e.Range, false, e))
let namedCurriedCallerArgs = lambdaVarsAndExprs |> List.map (fun _ -> [])
......@@ -9530,6 +9521,16 @@ and TcMethodApplication
let preArgumentTypeCheckingCalledMethGroup =
preArgumentTypeCheckingCalledMethGroup |> List.map (fun cmeth -> (cmeth.Method, cmeth.CalledTyArgs, cmeth.AssociatedPropertyInfo, cmeth.UsesParamArrayConversion))
let uniquelyResolved =
match uniquelyResolved with
| ErrorResult _ ->
match afterResolution with
| AfterResolution.DoNothing -> ()
| AfterResolution.RecordResolution(_, _, _, onFailure) -> onFailure()
| _ -> ()
uniquelyResolved |> CommitOperationResult
// STEP 3. Resolve overloading
/// Select the called method that's the result of overload resolution
let finalCalledMeth =
......
......@@ -211,6 +211,26 @@ is not compatible with type
'int []'
.
neg20.fs(183,29,183,34): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'obj'
neg20.fs(183,29,183,34): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'obj'
neg20.fs(183,35,183,40): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'obj'
neg20.fs(183,35,183,40): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'obj'
neg20.fs(183,14,183,41): typecheck error FS0001: This expression was expected to have type
'unit'
but here has type
......@@ -248,6 +268,26 @@ is not compatible with type
'string []'
.
neg20.fs(189,29,189,34): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
'obj'
neg20.fs(189,29,189,34): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
'obj'
neg20.fs(189,35,189,40): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
'obj'
neg20.fs(189,35,189,40): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
'obj'
neg20.fs(189,14,189,41): typecheck error FS0001: This expression was expected to have type
'unit'
but here has type
......
......@@ -18,6 +18,6 @@ neg67.fsx(42,35,42,36): parse error FS0010: Unexpected symbol '}' in definition.
neg67.fsx(41,9,41,14): typecheck error FS0001: This expression was expected to have type
'unit'
but here has type
'Async<'a>'
'Async<unit>'
neg67.fsx(30,1,41,37): typecheck error FS0003: This value is not a function and cannot be applied.
......@@ -1029,7 +1029,35 @@ for i in 0..a."]
for (code, marker) in useCases do
let code = prologue @ [code]
AssertCtrlSpaceCompleteContains code marker [] ["field1"; "field2"]
[<Test>]
[<Category("Records")>]
member public this.``Records.InferByFieldsInPriorMethodArguments``() =
let prologue =
[
"type T() ="
" new (left: float32, top: float32) = T()"
" new (left: float32, top: float32, width: float32, height: float32) = T()"
""
"type Rect ="
" { Left: float32"
" Top: float32"
" Width: float32"
" Height: float32 }"
]
let useCases =
[
"let toT(original) = T(original.Left, (* MARKER*)original.)", "(* MARKER*)original.", ["Left"; "Top"; "Width"; "Height"]
"let toT(original) = T(original.Left, original.Height, (* MARKER*)original.)", "(* MARKER*)original.", ["Left"; "Top"; "Width"; "Height"]
"let toT(original) = T(original.Left, original.Height, original.Width, (* MARKER*)original.)", "(* MARKER*)original.", ["Left"; "Top"; "Width"; "Height"]
"let toT(original) = T(original.Left, original.Height, (* MARKER*)original., original.Width)", "(* MARKER*)original.", ["Left"; "Top"; "Width"; "Height"]
]
for (code, marker, should) in useCases do
let code = prologue @ [code]
AssertCtrlSpaceCompleteContains code marker should []
[<Test>]
member this.``Completion.DetectInterfaces``() =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册