Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
1617a15e
F
fsharp
项目概览
dotNET Platform
/
fsharp
11 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1617a15e
编写于
10月 17, 2022
作者:
D
Don Syme
提交者:
GitHub
10月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix 14097 (#14131)
* Fix 14097 * Fix 14097
上级
8ba53ff1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
7 deletion
+36
-7
src/Compiler/Checking/CheckExpressions.fs
src/Compiler/Checking/CheckExpressions.fs
+6
-1
tests/FSharp.Compiler.ComponentTests/Conformance/TypesAndTypeConstraints/IWSAMsAndSRTPs/testFiles/CheckNewSyntax.fs
...ypeConstraints/IWSAMsAndSRTPs/testFiles/CheckNewSyntax.fs
+30
-6
未找到文件。
src/Compiler/Checking/CheckExpressions.fs
浏览文件 @
1617a15e
...
...
@@ -8556,7 +8556,12 @@ and TcTraitItemThen (cenv: cenv) overallTy env objOpt traitInfo tpenv mItem dela
applicableExpr, exprTy
| _ ->
let vs, ves = argTys |> List.mapi (fun i ty -> mkCompGenLocal mItem ("arg" + string i) ty) |> List.unzip
let traitCall = Expr.Op (TOp.TraitCall traitInfo, [], objArgs@ves, mItem)
// Account for a unit mismtach in logical v. compiled arguments
let compiledArgExprs =
match argTys, traitInfo.GetCompiledArgumentTypes() with
| [_], [] -> []
| _ -> ves
let traitCall = Expr.Op (TOp.TraitCall traitInfo, [], objArgs@compiledArgExprs, mItem)
let v, body = MultiLambdaToTupledLambda g vs traitCall
let expr = mkLambda mItem v (body, retTy)
let exprTy = tyOfExpr g expr
...
...
tests/FSharp.Compiler.ComponentTests/Conformance/TypesAndTypeConstraints/IWSAMsAndSRTPs/testFiles/CheckNewSyntax.fs
浏览文件 @
1617a15e
...
...
@@ -4,19 +4,31 @@ module CheckNewSyntax =
type
MyType
()
=
static
member
val
StaticProperty
=
0
with
get
,
set
static
member
StaticMethod
x
=
x
+
5
static
member
StaticMethod0
()
=
5
static
member
StaticMethod1
x
=
x
+
5
static
member
StaticMethod2
(
x
,
y
)
=
x
+
y
+
5
member
val
Length
=
0
with
get
,
set
member
_.
Item
with
get
x
=
"Hello"
member
_.
InstanceMethod
x
=
x
+
5
member
_.
InstanceMethod0
()
=
5
member
_.
InstanceMethod1
x
=
x
+
5
member
_.
InstanceMethod2
(
x
,
y
)
=
x
+
y
+
5
// Check that "property" and "get_ method" constraints are considered logically equivalent
let
inline
f_StaticProperty
<
'
T
when
'
T
:
(
static
member
StaticProperty
:
int
)
>()
:
int
=
'
T
.
StaticProperty
let
inline
f_StaticMethod
<
'
T
when
'
T
:
(
static
member
StaticMethod
:
int
->
int
)
>()
:
int
=
'
T
.
StaticMethod
(
3
)
let
inline
f_StaticMethod0
<
'
T
when
'
T
:
(
static
member
StaticMethod0
:
unit
->
int
)
>()
:
int
=
'
T
.
StaticMethod0
()
let
inline
f_StaticMethod1
<
'
T
when
'
T
:
(
static
member
StaticMethod1
:
int
->
int
)
>()
:
int
=
'
T
.
StaticMethod1
(
3
)
let
inline
f_StaticMethod2
<
'
T
when
'
T
:
(
static
member
StaticMethod2
:
int
*
int
->
int
)
>()
:
int
=
'
T
.
StaticMethod2
(
3
,
3
)
let
inline
f_set_StaticProperty
<
'
T
when
'
T
:
(
static
member
StaticProperty
:
int
with
set
)
>()
=
'
T
.
set_StaticProperty
(
3
)
let
inline
f_InstanceMethod
<
'
T
when
'
T
:
(
member
InstanceMethod
:
int
->
int
)
>(
x
:
'
T
)
:
int
=
x
.
InstanceMethod
(
3
)
let
inline
f_InstanceMethod0
<
'
T
when
'
T
:
(
member
InstanceMethod0
:
unit
->
int
)
>(
x
:
'
T
)
:
int
=
x
.
InstanceMethod0
()
let
inline
f_InstanceMethod1
<
'
T
when
'
T
:
(
member
InstanceMethod1
:
int
->
int
)
>(
x
:
'
T
)
:
int
=
x
.
InstanceMethod1
(
3
)
let
inline
f_InstanceMethod2
<
'
T
when
'
T
:
(
member
InstanceMethod2
:
int
*
int
->
int
)
>(
x
:
'
T
)
:
int
=
x
.
InstanceMethod2
(
3
,
3
)
let
inline
f_Length
<
'
T
when
'
T
:
(
member
Length
:
int
)
>(
x
:
'
T
)
=
x
.
Length
...
...
@@ -33,7 +45,13 @@ module CheckNewSyntax =
//let inline f_set_Length2<'T when 'T : (member Length: int with set) >(x: 'T) = x.Length <- 3
//let inline f_Item2<'T when 'T : (member Item: int -> string with get) >(x: 'T) = x[3]
if
f_StaticMethod
<
MyType
>()
<>
8
then
if
f_StaticMethod0
<
MyType
>()
<>
5
then
failwith
"Unexpected result"
if
f_StaticMethod1
<
MyType
>()
<>
8
then
failwith
"Unexpected result"
if
f_StaticMethod2
<
MyType
>()
<>
11
then
failwith
"Unexpected result"
if
f_set_StaticProperty
<
MyType
>()
<>
()
then
...
...
@@ -47,7 +65,13 @@ module CheckNewSyntax =
if
f_Length
(
myInstance
)
<>
0
then
failwith
"Unexpected result"
if
f_InstanceMethod
(
myInstance
)
<>
8
then
if
f_InstanceMethod0
(
myInstance
)
<>
5
then
failwith
"Unexpected result"
if
f_InstanceMethod1
(
myInstance
)
<>
8
then
failwith
"Unexpected result"
if
f_InstanceMethod2
(
myInstance
)
<>
11
then
failwith
"Unexpected result"
if
f_set_Length
(
myInstance
)
<>
()
then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录