Skip to content

Instantly share code, notes, and snippets.

@taisukeoe
Last active February 9, 2019 20:29
Show Gist options
  • Save taisukeoe/f9d8ab182d6a10aa430eb7fda09d5a90 to your computer and use it in GitHub Desktop.
Save taisukeoe/f9d8ab182d6a10aa430eb7fda09d5a90 to your computer and use it in GitHub Desktop.
ax:A#X = a.x
Welcome to Scala 2.12.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_201).
Type in expressions for evaluation. Or try :help.
scala> trait A {val x:AnyRef = null;type X = x.type}
defined trait A
scala> val a = new A{}
a: A = $anon$1@36417a54
scala> val ax:a.type#X = a.x
ax: a.X = null
scala> val ax2:A#X = a.x
ax2: _1.x.type forSome { val _1: A } = null
//dotr -version
//Starting dotty REPL...
//Dotty compiler version 0.12.0-RC1 -- Copyright 2002-2019, LAMP/EPFL
Starting dotty REPL...
scala> trait A {val x:AnyRef = null;type X = x.type}
// defined trait A
scala> val a = new A{}
val a: A = anon$1@3050ac2f
scala> val ax:a.type#X = a.x
val ax: a.X = null
scala> val ax2:A#X = a.x
1 |val ax2:A#X = a.x
| ^^^
| Found: AnyRef(a.x)
| Required: A#X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment