summaryrefslogtreecommitdiff
path: root/test/files/neg/t10066.scala
blob: ef52f333dd6f07c9e020617c76b4d439057d6132 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)
}