-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RA22-015: Fix call decl/type resolution
This fixes several bugs in the call decl/type resolution mechanism * Generally make `called_decl` only return a called decl when there is one for the specific callexpr. Before, for nested call expressions like ̀ a () () ()` it would return the sub call-expression called decl. * Make `expr_context_free_type` compute the type even when there is no called declaration
- Loading branch information
1 parent
39925cd
commit da65c32
Showing
6 changed files
with
275 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
testsuite/tests/contrib/lkt_semantic/advanced_calls/test.lkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class MyCallable { | ||
fun __call__(a: Int): Bool | ||
} | ||
|
||
class RecursiveCallable { | ||
fun __call__(a: Int): RecursiveCallable | ||
} | ||
|
||
class A { | ||
@property | ||
fun pouet(): (Int) -> Bool | ||
|
||
fun callable_array(): Array[MyCallable] | ||
|
||
fun test(): Bool = self.pouet(12) | ||
fun test2(): Bool = MyCallable()(12) | ||
fun test3(): Bool = self.callable_array()(12)(12) | ||
fun test4(): RecursiveCallable = RecursiveCallable()(12)(12)(12)(12)(12)(12)(12)(12)(12)(12)(12)(12)(12)(12) | ||
} |
191 changes: 191 additions & 0 deletions
191
testsuite/tests/contrib/lkt_semantic/advanced_calls/test.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
Resolving test.lkt | ||
================== | ||
Id <RefId "Int" test.lkt:2:21-2:24> | ||
references <StructDecl prelude: "Int"> | ||
|
||
Id <RefId "Bool" test.lkt:2:27-2:31> | ||
references <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "Int" test.lkt:6:21-6:24> | ||
references <StructDecl prelude: "Int"> | ||
|
||
Id <RefId "RecursiveCallable" test.lkt:6:27-6:44> | ||
references <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Id <RefId "Int" test.lkt:11:19-11:22> | ||
references <StructDecl prelude: "Int"> | ||
|
||
Id <RefId "Bool" test.lkt:11:27-11:31> | ||
references <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "Array" test.lkt:13:27-13:32> | ||
references <GenericDecl prelude: "Array"> | ||
|
||
Id <RefId "MyCallable" test.lkt:13:33-13:43> | ||
references <ClassDecl "MyCallable" test.lkt:1:1-3:2> | ||
|
||
Id <RefId "Bool" test.lkt:15:17-15:21> | ||
references <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "self" test.lkt:15:24-15:28> | ||
references <SelfDecl "self" test.lkt:9:1-19:2> | ||
|
||
Expr <RefId "self" test.lkt:15:24-15:28> | ||
has type <ClassDecl "A" test.lkt:9:1-19:2> | ||
|
||
Id <RefId "pouet" test.lkt:15:29-15:34> | ||
references <FunDecl "pouet" test.lkt:11:5-11:31> | ||
|
||
Expr <RefId "pouet" test.lkt:15:29-15:34> | ||
has type <FunctionType prelude: "(Int) -> Bool"> | ||
|
||
Expr <DotExpr test.lkt:15:24-15:34> | ||
has type <FunctionType prelude: "(Int) -> Bool"> | ||
|
||
Expr <NumLit test.lkt:15:35-15:37> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:15:24-15:38> | ||
has type <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "Bool" test.lkt:16:18-16:22> | ||
references <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "MyCallable" test.lkt:16:25-16:35> | ||
references <ClassDecl "MyCallable" test.lkt:1:1-3:2> | ||
|
||
Expr <CallExpr test.lkt:16:25-16:37> | ||
has type <ClassDecl "MyCallable" test.lkt:1:1-3:2> | ||
|
||
Expr <NumLit test.lkt:16:38-16:40> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:16:25-16:41> | ||
has type <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "Bool" test.lkt:17:18-17:22> | ||
references <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "self" test.lkt:17:25-17:29> | ||
references <SelfDecl "self" test.lkt:9:1-19:2> | ||
|
||
Expr <RefId "self" test.lkt:17:25-17:29> | ||
has type <ClassDecl "A" test.lkt:9:1-19:2> | ||
|
||
Id <RefId "callable_array" test.lkt:17:30-17:44> | ||
references <FunDecl "callable_array" test.lkt:13:5-13:44> | ||
|
||
Expr <RefId "callable_array" test.lkt:17:30-17:44> | ||
has type <FunctionType prelude: "() -> Array[MyCallable]"> | ||
|
||
Expr <DotExpr test.lkt:17:25-17:44> | ||
has type <FunctionType prelude: "() -> Array[MyCallable]"> | ||
|
||
Expr <CallExpr test.lkt:17:25-17:46> | ||
has type <InstantiatedGenericType prelude: "Array[MyCallable]"> | ||
|
||
Expr <NumLit test.lkt:17:47-17:49> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:17:25-17:50> | ||
has type <ClassDecl "MyCallable" test.lkt:1:1-3:2> | ||
|
||
Expr <NumLit test.lkt:17:51-17:53> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:17:25-17:54> | ||
has type <EnumTypeDecl prelude: "Bool"> | ||
|
||
Id <RefId "RecursiveCallable" test.lkt:18:18-18:35> | ||
references <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Id <RefId "RecursiveCallable" test.lkt:18:38-18:55> | ||
references <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:57> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:58-18:60> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:61> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:62-18:64> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:65> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:66-18:68> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:69> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:70-18:72> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:73> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:74-18:76> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:77> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:78-18:80> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:81> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:82-18:84> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:85> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:86-18:88> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:89> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:90-18:92> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:93> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:94-18:96> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:97> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:98-18:100> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:101> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:102-18:104> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:105> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:106-18:108> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:109> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
||
Expr <NumLit test.lkt:18:110-18:112> | ||
has type <StructDecl prelude: "Int"> | ||
|
||
Expr <CallExpr test.lkt:18:38-18:113> | ||
has type <ClassDecl "RecursiveCallable" test.lkt:5:1-7:2> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
driver: lkt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters