-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further changes for BlockType Wildcards
- Loading branch information
Showing
9 changed files
with
97 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
module examples/pts/blockType | ||
|
||
def main() = { | ||
var num : _ = 1 | ||
num = 2 | ||
println(num) | ||
module examples/pts/blockType | ||
|
||
def runFunc{func : _} = { | ||
func("abc", 1) | ||
} | ||
|
||
def main() = { | ||
def test(x : String, y : Int) : String = { | ||
"a" | ||
} | ||
|
||
val res : Int = runFunc { test } | ||
println(res) | ||
} |
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,18 @@ | ||
module examples/pts/blockTypes | ||
|
||
def main() = { | ||
def test1(x : String, y : Int) : String = { | ||
"a" | ||
} | ||
|
||
def test2(x : String, y : String) : String = { | ||
"a turtle" | ||
} | ||
|
||
val res : Int = runFunc { test1 } { test2 } | ||
println(res) | ||
} | ||
|
||
def runFunc{func1 : _}{func2 : _} = { | ||
func2(func1("abc", 1), " turtle") | ||
} |
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,12 @@ | ||
module examples/pts/functionParameterTypes | ||
|
||
def constant(num : _) = { | ||
val a : Test = num | ||
return 5 | ||
} | ||
|
||
def main() = { | ||
val input : Int = 2 | ||
val res : Int = constant(input) | ||
println(res) | ||
} |
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,16 @@ | ||
module examples/pts/longType | ||
|
||
|
||
type List[A] { | ||
Nil(); | ||
Cons(head: A, tail: List[A]) | ||
} | ||
|
||
type TypeWithReallyLongName { | ||
X(y : Int) | ||
} | ||
|
||
def main() = { | ||
val listA : List[_] = Cons(X(1), Cons(X(2), Cons(X(3), Nil()))) | ||
println(listA) | ||
} |
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 @@ | ||
module examples/pts/nestedTypes | ||
|
||
type List[A] { | ||
Nil(); | ||
Cons(head: A, tail: List[A]) | ||
} | ||
|
||
type Map[A, B] { | ||
Map(keys : List[A], values : List[B]) | ||
} | ||
|
||
def main() = { | ||
val listA : List[_] = Cons(1, Cons(2, Cons(3, Nil()))) | ||
val listB : List[_] = Cons("a", Cons("b", Cons("c", Nil()))) | ||
|
||
val map1 : Map[_, _] = Map(listA, listB) | ||
val map2 : Map[String, Int] = map1 | ||
println("end") | ||
} |
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,6 +1,7 @@ | ||
module examples/pts/valueType | ||
|
||
def main() = { | ||
val num : Int = 1; | ||
println(num); | ||
val num1 : _ = 1 | ||
val num2 : String = num1 | ||
println(num1) | ||
} |