-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #14488: Scala.js: Add compiler support for scala.Enumeration. #15770
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,60 @@ | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:6:4 ------------------------------------------------------------- | ||
6 | Value // error | ||
| ^^^^^ | ||
| Could not transform call to scala.Enumeration.Value. | ||
| The resulting program is unlikely to function properly as this operation requires reflection. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:10:9 ------------------------------------------------------------ | ||
10 | Value(4) // error | ||
| ^^^^^^^^ | ||
| Could not transform call to scala.Enumeration.Value. | ||
| The resulting program is unlikely to function properly as this operation requires reflection. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:15:15 ----------------------------------------------------------- | ||
15 | val a = Value(null) // error | ||
| ^^^^^^^^^^^ | ||
| Passing null as name to scala.Enumeration.Value requires reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:16:15 ----------------------------------------------------------- | ||
16 | val b = Value(10, null) // error | ||
| ^^^^^^^^^^^^^^^ | ||
| Passing null as name to scala.Enumeration.Value requires reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:20:10 ----------------------------------------------------------- | ||
20 | val a = new Val // error | ||
| ^^^^^^^ | ||
| Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:21:10 ----------------------------------------------------------- | ||
21 | val b = new Val(10) // error | ||
| ^^^^^^^^^^^ | ||
| Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:25:10 ----------------------------------------------------------- | ||
25 | val a = new Val(null) // error | ||
| ^^^^^^^^^^^^^ | ||
| Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:26:10 ----------------------------------------------------------- | ||
26 | val b = new Val(10, null) // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:30:31 ----------------------------------------------------------- | ||
30 | protected class Val1 extends Val // error | ||
| ^^^ | ||
| Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:31:31 ----------------------------------------------------------- | ||
31 | protected class Val2 extends Val(1) // error | ||
| ^^^^^^ | ||
| Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:35:31 ----------------------------------------------------------- | ||
35 | protected class Val1 extends Val(null) // error | ||
| ^^^^^^^^^ | ||
| Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | ||
| The resulting program is unlikely to function properly. | ||
-- Error: tests/neg-scalajs/enumeration-warnings.scala:36:31 ----------------------------------------------------------- | ||
36 | protected class Val2 extends Val(1, null) // error | ||
| ^^^^^^^^^^^^ | ||
| Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | ||
| The resulting program is unlikely to function properly. |
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,37 @@ | ||
// scalac: -Xfatal-warnings | ||
|
||
class UnableToTransformValue extends Enumeration { | ||
val a = { | ||
println("oh, oh!") | ||
Value // error | ||
} | ||
val b = { | ||
println("oh, oh!") | ||
Value(4) // error | ||
} | ||
} | ||
|
||
class ValueWithNullName extends Enumeration { | ||
val a = Value(null) // error | ||
val b = Value(10, null) // error | ||
} | ||
|
||
class NewValWithNoName extends Enumeration { | ||
val a = new Val // error | ||
val b = new Val(10) // error | ||
} | ||
|
||
class NewValWithNullName extends Enumeration { | ||
val a = new Val(null) // error | ||
val b = new Val(10, null) // error | ||
} | ||
|
||
class ExtendsValWithNoName extends Enumeration { | ||
protected class Val1 extends Val // error | ||
protected class Val2 extends Val(1) // error | ||
} | ||
|
||
class ExtendsValWithNullName extends Enumeration { | ||
protected class Val1 extends Val(null) // error | ||
protected class Val2 extends Val(1, null) // error | ||
} |
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,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
object Q extends Enumeration { | ||
val A = Value("A") | ||
val B = Value("B") | ||
|
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,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
object Test extends App { | ||
|
||
object Color extends Enumeration { | ||
|
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,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
object X extends Enumeration { | ||
val Y = Value | ||
} | ||
|
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,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
object t extends Enumeration { val a, b = Value } | ||
|
||
object Test extends App { | ||
|
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,4 +1,4 @@ | ||
// scalajs: --skip --pending | ||
// scalajs: --skip | ||
|
||
object Days extends Enumeration { | ||
type Day = DayValue | ||
|
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,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
object Test extends Enumeration { | ||
val foo = Value | ||
def bar = withName("foo") | ||
|
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,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
object L extends Enumeration { | ||
val One, Two, Three = Value | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test uses
extends Val
without explicit name, which is not supported (and was never supported in Scala 2 either).