-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9183 from som-snytt/issue/restore-unit
Exclude unit value as literal type
- Loading branch information
Showing
3 changed files
with
53 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
sip23-no-unit-type.scala:6: error: Illegal literal type (), use Unit instead | ||
case _: () => "err" | ||
^ | ||
sip23-no-unit-type.scala:7: error: Illegal literal type (), use Unit instead | ||
case _: ().type => "err" | ||
^ | ||
sip23-no-unit-type.scala:7: error: '=>' expected but '.' found. | ||
case _: ().type => "err" | ||
^ | ||
sip23-no-unit-type.scala:10: error: Illegal literal type (), use Unit instead | ||
val younit: () = () | ||
^ | ||
sip23-no-unit-type.scala:11: error: Illegal literal type (), use Unit instead | ||
val unit: ().type = () | ||
^ | ||
sip23-no-unit-type.scala:11: error: '=' expected but '.' found. | ||
val unit: ().type = () | ||
^ | ||
sip23-no-unit-type.scala:12: error: illegal start of simple expression | ||
} | ||
^ | ||
7 errors |
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 @@ | ||
|
||
object Test { | ||
def f: () => Int = () => 42 | ||
def s = null.asInstanceOf[Any] match { | ||
case () => "ok" | ||
case _: () => "err" | ||
case _: ().type => "err" | ||
case _: Unit => "quite good" | ||
} | ||
val younit: () = () | ||
val unit: ().type = () | ||
} |