-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
12 deletions.
There are no files selected for viewing
36 changes: 35 additions & 1 deletion
36
...wollok.tests/src/org/uqbar/project/wollok/tests/typesystem/xpect/closures-advanced.wlk.xt
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 |
---|---|---|
@@ -1,8 +1,42 @@ | ||
/* XPECT_SETUP org.uqbar.project.wollok.tests.typesystem.xpect.TypeSystemXpectTestCase END_SETUP */ | ||
|
||
object advancedClosures { | ||
// XPECT methodType at next --> (Number) => Number | ||
// XPECT methodType at next --> (Number) => Number | ||
method next(n) { | ||
return { a => a + 1 }.apply(n) | ||
} | ||
} | ||
|
||
object incompatibility { | ||
//const numbers = [1,2,3] | ||
|
||
method closure_vs_basic_type() { | ||
// XPECT warnings --> "Type system: expected <<{(Number) => Boolean}>> but found <<String>>" at ""ERROR"" | ||
return [1,2,3].filter("ERROR") | ||
} | ||
|
||
method basic_vs_closure_type() { | ||
// XPECT warnings --> "Type system: expected <<Number>> but found <<{() => String}>>" at "{"ERROR"}" | ||
return [1,2,3].contains({"ERROR"}) | ||
} | ||
|
||
method closure_type_with_different_params() { | ||
// XPECT warnings --> "Type system: expected <<{(Number) => Boolean}>> but found <<{() => Boolean}>>" at "{true}" | ||
return [1,2,3].filter({true}) | ||
} | ||
|
||
method incompatible_param_closure_type() { | ||
// XPECT warnings --> "Number does not understand startsWith("ERROR")" at "n.startsWith("ERROR")" | ||
return [1,2,3].filter({n => n.startsWith("ERROR")}) | ||
} | ||
|
||
method incompatible_return_closure_type() { | ||
// XPECT warnings --> "Type system: expected <<Boolean>> but found <<String>>" at "{n => "ERROR"}" | ||
return [1,2,3].any({n => "ERROR"}) | ||
} | ||
|
||
method infinite_closure_type(c) { | ||
// XPECT warnings --> "Type system: Infinite recursive type" at "c" | ||
return [c].filter(c) | ||
} | ||
} |
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
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
14 changes: 14 additions & 0 deletions
14
...m/src/org/uqbar/project/wollok/typesystem/exceptions/InfiniteRecursiveTypeException.xtend
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,14 @@ | ||
package org.uqbar.project.wollok.typesystem.exceptions | ||
|
||
import org.uqbar.project.wollok.typesystem.Messages | ||
import org.uqbar.project.wollok.typesystem.TypeSystemException | ||
import org.uqbar.project.wollok.typesystem.constraints.variables.TypeVariable | ||
|
||
class InfiniteRecursiveTypeException extends TypeSystemException { | ||
|
||
new(TypeVariable variable) { | ||
super(variable) | ||
} | ||
|
||
override getMessage() { Messages.TypeSystemException_INFINITE_RECURSIVE_TYPE } | ||
} |
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
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