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

Compiler crashes with Dynamic and implicits #10066

Closed
scabug opened this issue Nov 17, 2016 · 2 comments
Closed

Compiler crashes with Dynamic and implicits #10066

scabug opened this issue Nov 17, 2016 · 2 comments

Comments

@scabug
Copy link

scabug commented Nov 17, 2016

reported on https://groups.google.com/forum/#!topic/scala-internals/9VQXHholnsY

package dynamicrash

import scala.language.dynamics

class Config

trait Extractor[A] {
  def extract(config: Config, name: String): A
}

object Extractor {
  // note missing "implicit"
  val stringExtractor = new Extractor[String] {
    override def extract(config: Config, name: String): String = ???
  }
}

class Workspace extends Dynamic {
  val config: Config = new Config

  def selectDynamic[A](name: String)(implicit extractor: Extractor[A]): A =
    extractor.extract(config, name)
}

object Main {
  val storage = new Workspace

  // this line works fine
  // val a = storage.foo

  // this line crashes the compiler ("head of empty list")
  // in ContextErrors$InferencerContextErrors$InferErrorGen$.NotWithinBoundsErrorMessage
  // println(storage.foo[String])

  // this line crashes the compiler in different way ("unknown type")
  // in the backend, warning: an unexpected type representation reached the compiler backend while compiling Test.scala: <error>
  // println(storage.foo)
}
@scabug
Copy link
Author

scabug commented Nov 17, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10066?orig=1
Reporter: @lrytz
Affected Versions: 2.11.8, 2.12.0

@scabug
Copy link
Author

scabug commented Nov 18, 2016

@retronym said:
scala/scala#5542

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

3 participants