You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala>val (x,y) =iftruethen""else (42,17)
scala.MatchError: (of classjava.lang.String)
... 30 elided
java.lang.NoClassDefFoundError:Could not initialize classrepl$.rs$line$3$
at repl$.rs$line$3.y(rs$line$3)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at dotty.tools.repl.Rendering.$anonfun$3(Rendering.scala:116)
at scala.Option.map(Option.scala:242)
at dotty.tools.repl.Rendering.valueOf(Rendering.scala:116)
at dotty.tools.repl.Rendering.renderVal(Rendering.scala:153)
at dotty.tools.repl.ReplDriver.$anonfun$13(ReplDriver.scala:325)
at scala.collection.immutable.List.flatMap(List.scala:293)
at scala.collection.immutable.List.flatMap(List.scala:79)
at dotty.tools.repl.ReplDriver.extractAndFormatMembers$1(ReplDriver.scala:325)
at dotty.tools.repl.ReplDriver.renderDefinitions$$anonfun$2(ReplDriver.scala:348)
at scala.Option.map(Option.scala:242)
at dotty.tools.repl.ReplDriver.renderDefinitions(ReplDriver.scala:351)
at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:269)
at scala.util.Either.fold(Either.scala:189)
at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:286)
at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:218)
Output
java.lang.NoClassDefFoundError:Could not initialize classrepl$.rs$line$3$
Same under -source future.
➜ dotty git:(test/current) ./bin/scala -source future
Welcome to Scala3.1.3-RC1-bin-SNAPSHOT-git-fd97aee (17.0.2, JavaOpenJDK64-BitServerVM).
Type in expressions for evaluation. Ortry:help.
scala>val (x,y) =iftruethen""else (42,17)
1 warning found
--Warning:-------------------------------------------------------------------------------------------------------------------------------------1|val (x,y) =iftruethen""else (42,17)
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^| pattern'stype (Int, Int) is more specialized than the right hand side expression'stype ("":String) | (Int, Int)
||If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression.
scala.MatchError: (of classjava.lang.String)
... 33 elided
java.lang.NoClassDefFoundError:Could not initialize classrs$line$1$
at rs$line$1.y(rs$line$1)
The right hand side of value definitions in the REPL are computed in the static
initializer for the wrapper object created for that input line (e.g. rs$line$1).
If any of these definitions throws an exception, the wrapper class will fail to
initialize, and further attempts to use the class will throw NoClassDefFoundError.
In this commit, we avoid all reflective access on a wrapper class once we notice
that it failed to initialize, and mark that wrapper object as invalid in the REPL
state. We discard all input from the failed wrapper (which may have been multi-line
containing many statements and definitions); any types, terms, aliases, or imports
defined there will not override any existing with the same name, and will not be
accessible in subsequent runs.
Fixesscala#4416Fixesscala#14473
Compiler version
3.1.0, 3.1.1
Minimized code
Output
Same under
-source future
.Expectation
More like
The text was updated successfully, but these errors were encountered: