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

Commitf6a057c

Browse files
authored
Fixed overloading for inref/outref/byref from passing (dotnet#5467)
* Fixed overloading for inref/outref/byref from passing* Normalizing test names
1 parent2a0e1b3 commitf6a057c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

‎src/fsharp/infos.fs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,10 @@ type EventInfo =
24702470
//-------------------------------------------------------------------------
24712471
// Helpers associated with getting and comparing method signatures
24722472

2473+
/// Strips inref and outref to be a byref.
2474+
letstripByrefTy g ty=
2475+
if isByrefTy g tythen mkByrefTy g(destByrefTy g ty)
2476+
else ty
24732477

24742478
/// Represents the information about the compiled form of a method signature. Used when analyzing implementation
24752479
/// relations between members and abstract slots.
@@ -2493,7 +2497,8 @@ let CompiledSigOfMeth g amap m (minfo:MethInfo) =
24932497

24942498
CompiledSig(vargtys,vrty,formalMethTypars,fmtpinst)
24952499

2496-
/// Used to hide/filter members from super classes based on signature
2500+
/// Used to hide/filter members from super classes based on signature
2501+
/// Inref and outref parameter types will be treated as a byref type for equivalency.
24972502
letMethInfosEquivByNameAndPartialSig erasureFlag ignoreFinal g amap m(minfo:MethInfo)(minfo2:MethInfo)=
24982503
(minfo.LogicalName= minfo2.LogicalName)&&
24992504
(minfo.GenericArity= minfo2.GenericArity)&&
@@ -2504,7 +2509,8 @@ let MethInfosEquivByNameAndPartialSig erasureFlag ignoreFinal g amap m (minfo:Me
25042509
letfminst2= generalizeTypars formalMethTypars2
25052510
letargtys= minfo.GetParamTypes(amap, m, fminst)
25062511
letargtys2= minfo2.GetParamTypes(amap, m, fminst2)
2507-
(argtys,argtys2)||> List.lengthsEqAndForall2(List.lengthsEqAndForall2(typeAEquivAux erasureFlag g(TypeEquivEnv.FromEquivTypars formalMethTypars formalMethTypars2)))
2512+
(argtys,argtys2)||> List.lengthsEqAndForall2(List.lengthsEqAndForall2(fun ty1 ty2->
2513+
typeAEquivAux erasureFlag g(TypeEquivEnv.FromEquivTypars formalMethTypars formalMethTypars2)(stripByrefTy g ty1)(stripByrefTy g ty2)))
25082514

25092515
/// Used to hide/filter members from super classes based on signature
25102516
letPropInfosEquivByNameAndPartialSig erasureFlag g amap m(pinfo:PropInfo)(pinfo2:PropInfo)=

‎tests/fsharp/core/byrefs/test2.bsl‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ test2.fsx(93,17,93,29): typecheck error FS0425: The type of a first-class functi
2828
test2.fsx(112,53,112,54): typecheck error FS3209: The address of the variable 'x'or a related expression cannot be used at this point. This isto ensure the address of the local value doesnot escape its scope.
2929

3030
test2.fsx(124,41,124,42): typecheck error FS3209: The address of the variable 'x'or a related expression cannot be used at this point. This isto ensure the address of the local value doesnot escape its scope.
31+
32+
test2.fsx(133,23,133,33): typecheck error FS0438: Duplicate method. The method 'TestMethod' has the same nameand signature as another methodin type 'NegativeTests.TestNegativeOverloading'.
33+
34+
test2.fsx(131,23,131,33): typecheck error FS0438: Duplicate method. The method 'TestMethod' has the same nameand signature as another methodin type 'NegativeTests.TestNegativeOverloading'.
35+
36+
test2.fsx(129,23,129,33): typecheck error FS0438: Duplicate method. The method 'TestMethod' has the same nameand signature as another methodin type 'NegativeTests.TestNegativeOverloading'.

‎tests/fsharp/core/byrefs/test2.fsx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ module NegativeTests =
123123
let mutablex=1
124124
letf= TestDelegate(fun()->&x)// is not allowed
125125
()
126+
127+
typeTestNegativeOverloading()=
128+
129+
static memberTestMethod(dt:byref<int>)=()
130+
131+
static memberTestMethod(dt:inref<int>)=()
132+
133+
static memberTestMethod(dt:outref<int>)=()
126134
#endif
127135

128136
moduleTests=
@@ -138,6 +146,14 @@ module Tests =
138146
()
139147
()
140148

149+
typeTestPositiveOverloading()=
150+
151+
static memberTestMethod(dt:byref<int>)=()
152+
153+
static memberTestMethod(dt:inref<float32>)=()
154+
155+
static memberTestMethod(dt:outref<float>)=()
156+
141157
letaa=
142158
if!failuresthen(stdout.WriteLine"Test Failed"; exit1)
143159
else(stdout.WriteLine"Test Passed";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp