-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: fix printing interface variable in smartcast
- Loading branch information
Showing
4 changed files
with
33 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface Any {} | ||
|
||
fn do(v Any) string { | ||
match v { | ||
int { | ||
println('> integer answer: ${2 * v}') | ||
return '${2 * v}' | ||
} | ||
string { | ||
println('> string answer: ${v}, len: ${v.len}') | ||
return '${v}' | ||
} | ||
else { | ||
return '' | ||
} | ||
} | ||
} | ||
|
||
fn test_printing_interface_variable_in_smartcast() { | ||
s1 := do(123) | ||
assert s1 == '246' | ||
|
||
s2 := do('abc') | ||
assert s2 == 'abc' | ||
} |