Skip to content
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

Each plugin must only be instantiated once. #7494

Closed
scabug opened this issue May 18, 2013 · 3 comments
Closed

Each plugin must only be instantiated once. #7494

scabug opened this issue May 18, 2013 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented May 18, 2013

The meaning of the following comment in Plugins.scala is that loadAllFrom in Plugin.scala must ensure uniqueness.

The continuations plugin relies on this behavior, for instance. Once instantiated, a plugin is free to muck with its global. (A Subcomponent has no lifecycle for init and destroy operations.)

If two continuations plugins are specified, the second, "stale" checker will not be "enabled." The enabled flag is propagated from the (proper) plugin to its subcomponents and to its checkers.

// Each plugin must only be instantiated once. A common pattern
// is to register annotation checkers during object construction, so
// creating multiple plugin instances will leave behind stale checkers.

Sample confusing output, which also occurs on 2.10 if $CJ is a nefarious file name like my-continuations.jar:

$ scalac -verbose -Ylog:all -P:continuations:enable -Xplugin:$CJ t1807.scala
***
[log <no phase>] instantiated cps plugin: scala.tools.selectivecps.SelectiveCPSPlugin@6fc33c70
[log <no phase>] instantiated cps plugin: scala.tools.selectivecps.SelectiveCPSPlugin@7ab51662
[loaded plugin continuations]
[skipping a repeated plugin: continuations]
***
t1807.scala:10: error: this code must be compiled with the Scala continuations plugin enabled
      val f: (() => Int @cps[Int]) = () => 1
                         ^
[loaded class file /home/apm/projects/scala-pick/build/pack/lib/scala-library.jar(scala/util/continuations/cpsPlus.class) in 1ms]
t1807.scala:10: error: this code must be compiled with the Scala continuations plugin enabled
      val f: (() => Int @cps[Int]) = () => 1
                                           ^
***
four errors found

That's one more error than if you don't specify -P::enabled at all, so go figure.

@scabug
Copy link
Author

scabug commented May 18, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7494?orig=1
Reporter: @som-snytt
Affected Versions: 2.11.0-M2

@scabug
Copy link
Author

scabug commented May 18, 2013

@som-snytt said:
scala/scala#2562

All is as it was before, and the timeline has been restored in which the duplication is silently glossed over.

It might be nice to issue a warning, in case someone is actually trying to monkey with the plugin in question.

The state of the class path is not specified, so it's not obvious whether it ought to prefer -Xpluginsdir or -Xplugin:myplugin.jar. Presumably the answer is either pluginsdir because it's either earlier on the class path or actually on a parent class loader, or myplugin.jar because I specifically asked for it.

@scabug
Copy link
Author

scabug commented May 20, 2013

@retronym said:
I think this is of sufficient importance to be the last change in 2.11.0-M3.

@scabug scabug closed this as completed May 20, 2013
@scabug scabug added this to the 2.11.0-M3 milestone Apr 7, 2017
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

No branches or pull requests

2 participants