-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement :jar (deprecate :require) #22343
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
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f8cd3ba
Skeleton :require
aherlihy d528014
find class names, need to add URL to loader
aherlihy f4968e7
Attempt to update class loader, not successful
aherlihy b8034c2
Add updateClassPath + reset rootctx
aherlihy 800356b
updated state with classpath
aherlihy f79588b
fix test order
aherlihy 0fad939
working but state lost
aherlihy 7b0ba9f
Clean up impl
aherlihy 1ac09e6
further cleanup, reuse dir (bug w double import)
aherlihy 2babf5c
Add simple tests
aherlihy 4d1e2b0
Handle out of sync imports after require + tests
aherlihy 78bf30b
slightly cleaner tests
aherlihy 9a60679
Fix :require adding classes/pkgs
dwijnand 4649d5e
Rename :require to :jar and deprecate :require
aherlihy 46aef87
Update compiler/src/dotty/tools/repl/ReplDriver.scala
aherlihy 7b142b8
re-add tests
aherlihy 4bb08f7
Update compiler/src/dotty/tools/repl/ReplDriver.scala
aherlihy 42c4e89
Add wrapper around :jar to avoid crashing repl on invalid jar
aherlihy 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
/** | ||
* JAR used for testing repl :jar | ||
* Generated using: mkdir out; scalac -d out MyLibrary.scala; jar cf mylibrary.jar -C out . | ||
*/ | ||
package mylibrary | ||
|
||
object Utils: | ||
def greet(name: String): String = s"Hello, $name!" |
This file contains hidden or 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,9 @@ | ||
/** | ||
* JAR used for testing repl :jar | ||
* Generated using: mkdir out2; scalac -d out MyLibrary2.scala; jar cf mylibrary2.jar -C out2 . | ||
*/ | ||
package mylibrary2 | ||
|
||
object Utils2: | ||
def greet(name: String): String = s"Greetings, $name!" | ||
|
Binary file not shown.
Binary file not shown.
This file contains hidden or 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,13 @@ | ||
scala> val z = 1 | ||
val z: Int = 1 | ||
|
||
scala>:jar sbt-test/source-dependencies/canon/actual/a.jar | ||
Added 'sbt-test/source-dependencies/canon/actual/a.jar' to classpath. | ||
|
||
scala> import A.x | ||
|
||
scala> x | ||
val res0: Int = 3 | ||
|
||
scala> z | ||
val res1: Int = 1 |
This file contains hidden or 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,11 @@ | ||
scala>:jar path/does/not/exist | ||
Cannot add "path/does/not/exist" to classpath. | ||
|
||
scala>:jar sbt-test/source-dependencies/canon/actual/a.jar | ||
Added 'sbt-test/source-dependencies/canon/actual/a.jar' to classpath. | ||
|
||
scala>:jar sbt-test/source-dependencies/canon/actual/a.jar | ||
The path 'sbt-test/source-dependencies/canon/actual/a.jar' cannot be loaded, it contains a classfile that already exists on the classpath: sbt-test/source-dependencies/canon/actual/a.jar(A.class) | ||
|
||
scala>:require sbt-test/source-dependencies/canon/actual/a.jar | ||
:require is no longer supported, but has been replaced with :jar. Please use :jar |
This file contains hidden or 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,32 @@ | ||
scala> val z = 1 | ||
val z: Int = 1 | ||
|
||
scala>:jar compiler/test-resources/jars/mylibrary.jar | ||
Added 'compiler/test-resources/jars/mylibrary.jar' to classpath. | ||
|
||
scala> import mylibrary.Utils | ||
|
||
scala> Utils.greet("Alice") | ||
val res0: String = Hello, Alice! | ||
|
||
scala>:jar compiler/test-resources/jars/mylibrary2.jar | ||
Added 'compiler/test-resources/jars/mylibrary2.jar' to classpath. | ||
|
||
scala> import mylibrary2.Utils2 | ||
|
||
scala> Utils2.greet("Alice") | ||
val res1: String = Greetings, Alice! | ||
|
||
scala> Utils.greet("Alice") | ||
val res2: String = Hello, Alice! | ||
|
||
scala> import mylibrary.Utils.greet | ||
|
||
scala> greet("Tom") | ||
val res3: String = Hello, Tom! | ||
|
||
scala> Utils.greet("Alice") | ||
val res4: String = Hello, Alice! | ||
|
||
scala> z | ||
val res5: Int = 1 |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.