Created
May 9, 2010 15:52
-
-
Save kmizu/395236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class X() { | |
// type T = String // この行を入れると何故かコンパイルを通る… | |
} | |
case class Y() | |
trait C[A] { | |
type T | |
} | |
trait Show[A] { def format(a: A): String } | |
object InstanceDeclarations { | |
implicit val instanceCX: C[X] = new C[X] { type T = String } | |
implicit val instanceCY: C[Y] = new C[Y] { type T = Int } | |
} | |
import InstanceDeclarations._ | |
object DependentMethodTypeBug { | |
def test[S](s: S)(implicit cs: C[S]): cs.T = error("not implemented") | |
def main(args: Array[String]) { | |
val t: String = test(X()) // X().Tの型はStringのはずなので,コンパイルを通るはずなのだけど… | |
//次のようなコンパイルエラーが出る.Xはtype member持ってないはずなんだけど | |
// 2.8.0.r21770-b20100501020120で確認(-Xexperimentalを付けてコンパイルすること) | |
// DependentMethodTypeBug.scala:22: error: type mismatch; | |
// found : X#T | |
// required: String | |
// val t: String = test(X()) // X().Tの型はStringのはずなので,コンパイルを通るはずなのだけど… | |
println("test") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment