Skip to content

valueOf wildcard type crashes #7866

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

Closed
Atry opened this issue Dec 30, 2019 · 1 comment
Closed

valueOf wildcard type crashes #7866

Atry opened this issue Dec 30, 2019 · 1 comment

Comments

@Atry
Copy link
Contributor

Atry commented Dec 30, 2019

minimized code

object Test extends App {
  valueOf[_]
}
Stack trace
java.nio.file.NoSuchFileException: /drone/src/library/src/dotty/DottyPredef.scala
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
	at java.nio.file.Files.newByteChannel(Files.java:361)
	at java.nio.file.Files.newByteChannel(Files.java:407)
	at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
	at java.nio.file.Files.newInputStream(Files.java:152)
	at dotty.tools.io.File.inputStream(File.scala:51)
	at dotty.tools.io.PlainFile.input(PlainFile.scala:44)
	at dotty.tools.io.AbstractFile.toByteArray(AbstractFile.scala:170)
	at dotty.tools.dotc.util.SourceFile.SourceFile$superArg$1$$anonfun$1(SourceFile.scala:51)
	at dotty.tools.dotc.util.SourceFile.content(SourceFile.scala:47)
	at dotty.tools.dotc.util.SourceFile.lineIndices(SourceFile.scala:110)
	at dotty.tools.dotc.util.SourceFile.offsetToLine(SourceFile.scala:129)
	at dotty.tools.dotc.util.SourcePosition.line(SourcePosition.scala:25)
	at xsbt.DelegatingReporter$2.line(DelegatingReporter.java:91)
	at com.olegych.scastie.sbtscastie.CompilerReporter$$anon$1.toApi$1(CompilerReporter.scala:43)
	at com.olegych.scastie.sbtscastie.CompilerReporter$$anon$1.$anonfun$printSummary$2(CompilerReporter.scala:46)
	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at scala.collection.TraversableLike.map(TraversableLike.scala:238)
	at scala.collection.TraversableLike.map$(TraversableLike.scala:231)
	at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:198)
	at com.olegych.scastie.sbtscastie.CompilerReporter$$anon$1.printSummary(CompilerReporter.scala:46)
	at xsbt.DelegatingReporter.printSummary(DelegatingReporter.java:58)
	at dotty.tools.dotc.Run.printSummary(Run.scala:258)
	at dotty.tools.dotc.Driver.finish$1(Driver.scala:39)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:49)
	at dotty.tools.dotc.Driver.process(Driver.scala:189)
	at dotty.tools.dotc.Main.process(Main.scala)
	at xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
	at xsbt.CompilerInterface.run(CompilerInterface.java:41)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77)
	at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215)
	at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77)
	at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343)
	at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120)
	at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100)
	at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180)
	at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98)
	at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102)
	at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155)
	at sbt.internal.inc.Incremental$.compile(Incremental.scala:92)
	at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75)
	at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348)
	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301)
	at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168)
	at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248)
	at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74)
	at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1761)
	at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1734)
	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
	at sbt.std.Transform$$anon$4.work(Transform.scala:67)
	at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
	at sbt.Execute.work(Execute.scala:290)
	at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
@MaximeKjaer
Copy link
Contributor

I think we can close this as a duplicate of #7442.

The expected behavior here is that a compilation error should be produced, since no singleton value can be produced by valueOf for a wildcard type. This is indeed what happens if I compile your minimized code example with dotc:

-- [E035] Syntax Error: tests/playground/i7866.scala:2:10 ----------------------
2 |  valueOf[_]
  |          ^
  |          Unbound wildcard type

longer explanation available when compiling with `-explain`
-- Error: tests/playground/i7866.scala:2:9 -------------------------------------
2 |  valueOf[_]
  |  ^^^^^^^^^^
  |  cannot reduce summonFrom with
  |   patterns :  case ev @ _:ValueOf[Any]
  | This location contains code that was inlined from DottyPredef.scala:36
2 errors found

However, compiling with sbt gives a NoSuchFileException instead, which is a bug that is being tracked in #7442.

@Atry Atry closed this as completed Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants