[ fix #954 ] Allow RF names for interface methods (#956)

This commit is contained in:
G. Allais 2021-01-19 20:50:47 +00:00 committed by GitHub
parent b0e0bf17d4
commit 47d345f67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 2 deletions

View File

@ -442,7 +442,11 @@ elabImplementation {vars} fc vis opts_in pass env nest is cons iname ps named im
-- Given the method type (result of topMethType) return the mapping from -- Given the method type (result of topMethType) return the mapping from
-- top level method name to current implementation's method name -- top level method name to current implementation's method name
methNameUpdate : (Name, Name, t) -> (Name, Name) methNameUpdate : (Name, Name, t) -> (Name, Name)
methNameUpdate (mn, fn, _) = (UN (nameRoot mn), fn) methNameUpdate (UN mn, fn, _) = (UN mn, fn)
methNameUpdate (RF mn, fn, _) = (RF mn, fn)
methNameUpdate (NS _ mn, fn, p) = methNameUpdate (mn, fn, p)
methNameUpdate (mn, fn, p) = (UN (nameRoot mn), fn) -- probably impossible
findMethName : List (Name, Name) -> FC -> Name -> Core Name findMethName : List (Name, Name) -> FC -> Name -> Core Name
findMethName ns fc n findMethName ns fc n

View File

@ -81,7 +81,7 @@ idrisTestsInterface = MkTestPool []
"interface009", "interface010", "interface011", "interface012", "interface009", "interface010", "interface011", "interface012",
"interface013", "interface014", "interface015", "interface016", "interface013", "interface014", "interface015", "interface016",
"interface017", "interface018", "interface019", "interface020", "interface017", "interface018", "interface019", "interface020",
"interface021"] "interface021", "interface022"]
idrisTestsLinear : TestPool idrisTestsLinear : TestPool
idrisTestsLinear = MkTestPool [] idrisTestsLinear = MkTestPool []

View File

@ -0,0 +1,27 @@
data D = MkD
data E = MkE
data Proxy i = MkProxy
interface I i where
(.idot) : i -> Int
I D where
(.idot) _ = 0
interface J i where
theInt : Proxy i -> Int
(.jdot) : i -> Int
(.jdot) _ = theInt (the (Proxy i) MkProxy)
val : i -> Int
val v = 10 + v .jdot
J D where
theInt _ = 0
J E where
theInt _ = 0
(.jdot) _ = 1
val _ = 2

View File

@ -0,0 +1,8 @@
1/1: Building DotMethod (DotMethod.idr)
Main> 0
Main> 0
Main> 1
Main> 10
Main> 2
Main>
Bye for now!

View File

@ -0,0 +1,5 @@
MkD .idot
MkD .jdot
MkE .jdot
val MkD
val MkE

3
tests/idris2/interface022/run Executable file
View File

@ -0,0 +1,3 @@
$1 --no-color --no-banner --console-width 0 DotMethod.idr < input
rm -rf build