scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.89k stars 1.06k forks source link

Various internal types available in user code #8673

Open bishabosha opened 4 years ago

bishabosha commented 4 years ago

Minimized code

lazy val x: scala.|[Int, String] = ???
lazy val y: scala.&[Int, String] = ???
lazy val z: implicits = ???
lazy val a: compiletime = ???
def foo(seq: `<repeated>`[Int]) = ???
def bar(x: `<byname>`[Int]) = ???
def baz = `<special-ops>`.`throw`(new AssertionError("?"))

Output

Warning: mocking up superclass for module class compiletime
Warning: mocking up superclass for module class implicits

Expectation

nsc does not recognise <repeated> or <byname> as types, even though it does the same thing with mock class types

odersky commented 4 years ago

I think its best to declare that names enclosed in <...> are compiler-internals, and should not be used. Same as for names with $'s in them. In both cases, we will not check that there's no direct usage. We will just state that the effect is unpredictable. So expert users that somehow need to get at these can still do it.

compiletime, | and & are legitimate objects or types. So these should be exposed as they are now. I don't know where you got implicits from?

bishabosha commented 4 years ago

The issue with compiletime, implicits is that apparently any package can be used as a type, e.g.

scala> def x: scala.jdk = ???
Warning: mocking up superclass for module class jdk
def x: jdk

this errors in scala 2 by saying error: type jdk is not a member of package scala

my other issue with | and & used with applied type syntax was that these have no footprint in the standard library, and have to be special cased in consumers of TASTy but I guess thats the same with Nothing, Null and Singleton etc.