diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2017-02-16 11:05:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-16 11:05:48 -0800 |
commit | b990e510510e77e516525d225a81cc3c22c94aec (patch) | |
tree | c96f1c9d3b8b255d880baf1761d220b7c47ec870 /test/files/pos | |
parent | 05d5338ff4ee3ffe5ef1c0e33faa1a29480be2b0 (diff) | |
parent | 944db65d63e12ae4e0135999cdc8b9f2695f4102 (diff) | |
download | scala-b990e510510e77e516525d225a81cc3c22c94aec.tar.gz scala-b990e510510e77e516525d225a81cc3c22c94aec.tar.bz2 scala-b990e510510e77e516525d225a81cc3c22c94aec.zip |
Merge pull request #5542 from retronym/ticket/10066
SI-10066 Fix crash in erroneous code with implicits, dynamic
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/t10066.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/files/pos/t10066.scala b/test/files/pos/t10066.scala new file mode 100644 index 0000000000..bef85cb08c --- /dev/null +++ b/test/files/pos/t10066.scala @@ -0,0 +1,38 @@ +package dynamicrash + +import scala.language.dynamics + +class Config + +trait Extractor[A] { + def extract(config: Config, name: String): A +} + +object Extractor { + // this has "implicit", unlike the corresponding neg test + 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) +} |