8000 Fix #2164: Support default args constructors in js.Any classes. by nicolasstucki · Pull Request #2186 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Fix #2164: Support default args constructors in js.Any classes. #2186

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

Merged

Conversation

nicolasstucki
Copy link
Contributor

Add explicit restriction: ScalaJSDefined and Scala classes that
have a js.Native module cannot use constructors with default arguments.

@nicolasstucki
Copy link
Contributor Author

Review by @sjrd.

* therefore companionModule is fetched at uncurryPhase.
*/
val companionModule = enteringPhase(currentRun.uncurryPhase) {
classSym.companionModule
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to access the companion module the exact same way in GenJSExports it might be a good idea to factor it out. But I'm not sure where would be the most appropriate place to place it.

@nicolasstucki nicolasstucki force-pushed the support-js-defined-default-arguments branch from b5f3843 to c70468f Compare January 19, 2016 16:35
@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2789/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3590/
Test PASSed.

reporter.error(pos,
"Implementation restriction: constructors of " +
"Scala classes cannot have default parameters " +
"if their module is JS native.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

companion module

@sjrd
Copy link
Member
sjrd commented Jan 19, 2016

That's all.

@nicolasstucki nicolasstucki force-pushed the support-js-defined-default-arguments branch from c70468f to efde166 Compare January 20, 2016 09:49
@@ -4516,10 +4524,15 @@ abstract class GenJSCode extends plugins.PluginComponent
def isRawJSType(tpe: Type): Boolean =
tpe.typeSymbol.annotations.find(_.tpe =:= RawJSTypeAnnot.tpe).isDefined


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double blank line.

@sjrd
Copy link
Member
sjrd commented Jan 20, 2016

LGTM, nice!

@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2794/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3596/
Test FAILed.

@sjrd
Copy link
Member
sjrd commented Jan 20, 2016

Scalastyle errors ...

@nicolasstucki nicolasstucki force-pushed the support-js-defined-default-arguments branch from efde166 to 1c0e8a9 Compare January 21, 2016 08:16
Add explicit restriction: ScalaJSDefined and Scala classes that
have a js.Native module cannot use constructors with default arguments.
@nicolasstucki nicolasstucki force-pushed the support-js-defined-default-arguments branch from 1c0e8a9 to a8de5aa Compare January 21, 2016 08:17
@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2800/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3603/
Test PASSed.

@scala-jenkins
Copy link

Refer to this link for build results (access rights to CI server needed):

https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/2799/
https://scala-webapps.epfl.ch/jenkins/job/scalajs-matrix-build/3602/
Test PASSed.

@sjrd
Copy link
Member
sjrd commented Jan 21, 2016

LGTM

sjrd added a commit that referenced this pull request Jan 21, 2016
…t-arguments

Fix #2164: Support default args constructors in js.Any classes.
@sjrd sjrd merged commit 6d784a3 into scala-js:master Jan 21, 2016
@nicolasstucki nicolasstucki deleted the support-js-defined-default-arguments branch February 3, 2016 08:41
sjrd added a commit to dotty-staging/dotty that referenced this pull request Sep 18, 2020
This commit implements the entire specification of non-native JS
classes, including nested ones, except the behavior of *anonymous*
JS classes. Anonymous JS classes are not supposed to have their own
class/prototype, but currently they still do.

The most important PRs to scala-js/scala-js that define what is
implemented here were:

1. scala-js/scala-js#1809
   Essentials of Scala.js-defined classes (former name of
   non-native JS classes)
2. scala-js/scala-js#1982
   Support for secondary constructors
3. scala-js/scala-js#2186
   Support for default parameters in constructors
4. scala-js/scala-js#2659
   Support for `js.Symbol`s in `@JSName` annotations
5. scala-js/scala-js#3161
   Nested JS classes

However, this commit was written more based on the state of things
at Scala.js v1.2.0 rather than as a port of the abovementioned PRs.

The support is spread over 4 components:

* The `ExplicitJSClasses` phase, which reifies all nested JS
  classes, and has extensive documentation in the code.
* The `JSExportsGen` component of the back-end, which creates
  dispatchers for run-time overloading, default parameters and
  variadic arguments (equivalent to `GenJSExports` in Scala 2).
* The `JSConstructorGen` component, which massages the constructors
  of JS classes and their dispatcher into a unique JS constructor.
* Bits and pieces in `JSCodeGen`, notably to generate the
  `js.ClassDef`s for non-native JS classes, orchestrate the two
  other back-end components, and to adapt calls to the members of
  non-native JS classes.

`JSConstructorGen` in particular is copied quasi-verbatim from
pieces of `GenJSCode` in Scala 2, since it works on `js.IRNode`s,
without knowledge of scalac/dotc data structures.
sjrd added a commit to dotty-staging/dotty that referenced this pull request Sep 18, 2020
This commit implements the entire specification of non-native JS
classes, including nested ones, except the behavior of *anonymous*
JS classes. Anonymous JS classes are not supposed to have their own
class/prototype, but currently they still do.

The most important PRs to scala-js/scala-js that define what is
implemented here were:

1. scala-js/scala-js#1809
   Essentials of Scala.js-defined classes (former name of
   non-native JS classes)
2. scala-js/scala-js#1982
   Support for secondary constructors
3. scala-js/scala-js#2186
   Support for default parameters in constructors
4. scala-js/scala-js#2659
   Support for `js.Symbol`s in `@JSName` annotations
5. scala-js/scala-js#3161
   Nested JS classes

However, this commit was written more based on the state of things
at Scala.js v1.2.0 rather than as a port of the abovementioned PRs.

The support is spread over 4 components:

* The `ExplicitJSClasses` phase, which reifies all nested JS
  classes, and has extensive documentation in the code.
* The `JSExportsGen` component of the back-end, which creates
  dispatchers for run-time overloading, default parameters and
  variadic arguments (equivalent to `GenJSExports` in Scala 2).
* The `JSConstructorGen` component, which massages the constructors
  of JS classes and their dispatcher into a unique JS constructor.
* Bits and pieces in `JSCodeGen`, notably to generate the
  `js.ClassDef`s for non-native JS classes, orchestrate the two
  other back-end components, and to adapt calls to the members of
  non-native JS classes.

`JSConstructorGen` in particular is copied quasi-verbatim from
pieces of `GenJSCode` in Scala 2, since it works on `js.IRNode`s,
without knowledge of scalac/dotc data structures.
sjrd added a commit to dotty-staging/dotty that referenced this pull request Sep 24, 2020
This commit implements the entire specification of non-native JS
classes, including nested ones, except the behavior of *anonymous*
JS classes. Anonymous JS classes are not supposed to have their own
class/prototype, but currently they still do.

The most important PRs to scala-js/scala-js that define what is
implemented here were:

1. scala-js/scala-js#1809
   Essentials of Scala.js-defined classes (former name of
   non-native JS classes)
2. scala-js/scala-js#1982
   Support for secondary constructors
3. scala-js/scala-js#2186
   Support for default parameters in constructors
4. scala-js/scala-js#2659
   Support for `js.Symbol`s in `@JSName` annotations
5. scala-js/scala-js#3161
   Nested JS classes

However, this commit was written more based on the state of things
at Scala.js v1.2.0 rather than as a port of the abovementioned PRs.

The support is spread over 4 components:

* The `ExplicitJSClasses` phase, which reifies all nested JS
  classes, and has extensive documentation in the code.
* The `JSExportsGen` component of the back-end, which creates
  dispatchers for run-time overloading, default parameters and
  variadic arguments (equivalent to `GenJSExports` in Scala 2).
* The `JSConstructorGen` component, which massages the constructors
  of JS classes and their dispatcher into a unique JS constructor.
* Bits and pieces in `JSCodeGen`, notably to generate the
  `js.ClassDef`s for non-native JS classes, orchestrate the two
  other back-end components, and to adapt calls to the members of
  non-native JS classes.

`JSConstructorGen` in particular is copied quasi-verbatim from
pieces of `GenJSCode` in Scala 2, since it works on `js.IRNode`s,
without knowledge of scalac/dotc data structures.
sjrd added a commit to dotty-staging/dotty that referenced this pull request Oct 2, 2020
This commit implements the entire specification of non-native JS
classes, including nested ones, except the behavior of *anonymous*
JS classes. Anonymous JS classes are not supposed to have their own
class/prototype, but currently they still do.

The most important PRs to scala-js/scala-js that define what is
implemented here were:

1. scala-js/scala-js#1809
   Essentials of Scala.js-defined classes (former name of
   non-native JS classes)
2. scala-js/scala-js#1982
   Support for secondary constructors
3. scala-js/scala-js#2186
   Support for default parameters in constructors
4. scala-js/scala-js#2659
   Support for `js.Symbol`s in `@JSName` annotations
5. scala-js/scala-js#3161
   Nested JS classes

However, this commit was written more based on the state of things
at Scala.js v1.2.0 rather than as a port of the abovementioned PRs.

The support is spread over 4 components:

* The `ExplicitJSClasses` phase, which reifies all nested JS
  classes, and has extensive documentation in the code.
* The `JSExportsGen` component of the back-end, which creates
  dispatchers for run-time overloading, default parameters and
  variadic arguments (equivalent to `GenJSExports` in Scala 2).
* The `JSConstructorGen` component, which massages the constructors
  of JS classes and their dispatcher into a unique JS constructor.
* Bits and pieces in `JSCodeGen`, notably to generate the
  `js.ClassDef`s for non-native JS classes, orchestrate the two
  other back-end components, and to adapt calls to the members of
  non-native JS classes.

`JSConstructorGen` in particular is copied quasi-verbatim from
pieces of `GenJSCode` in Scala 2, since it works on `js.IRNode`s,
without knowledge of scalac/dotc data structures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0