You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** List of symbols to import from in a root context. Typically that
is java.lang, scala, and [[scala.Predef]], in that order. Exceptions:
if option -Yno-imports is given, nothing is imported
if the unit is java defined, only java.lang is imported
if option -Yno-predef is given, if the unit body has an import of Predef
among its leading imports, or if the tree is [[scala.Predef]], Predef is not imported.
*/
protected def rootImports(unit: CompilationUnit): List[Symbol] = {
assert(definitions.isDefinitionsInitialized, "definitions uninitialized")
if (settings.noimports) Nil
else if (unit.isJava) RootImports.javaList
else if (settings.nopredef || treeInfo.noPredefImportForUnit(unit.body)) {
debuglog("Omitted import of Predef._ for " + unit)
RootImports.javaAndScalaList
}
else RootImports.completeList
}
There is an exception in the comment: if the unit body has an import of Predef among its leading imports.
I think spec should mention this exception.
The text was updated successfully, but these errors were encountered:
Oleg Atamanenko (uthark) said:
Some specific observation:
If I add in the code import scala.Predef.String - I don't import Predef as a whole, just a scala.Predef.String, then scala.Predef is not implicitly added.
I found very confusing behaviour for implicit import of scala.Predef.
http://stackoverflow.com/questions/17690183/explain-why-import-scala-predef-string-fails-build
Spec, section 9.1 Compilation units states the following:
Implicitly imported into every compilation unit are, in that order : the package java.lang, the package scala, and the object scala.Predef (§12.5).
But if I open the implementation:
https://github.com/scala/scala/blob/master/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
method rootImports and scaladoc:
/** List of symbols to import from in a root context. Typically that
java.lang
,scala
, and [[scala.Predef]], in that order. Exceptions:-Yno-imports
is given, nothing is importedjava.lang
is imported-Yno-predef
is given, if the unit body has an import of PredefPredef
is not imported.*/
protected def rootImports(unit: CompilationUnit): List[Symbol] = {
assert(definitions.isDefinitionsInitialized, "definitions uninitialized")
}
There is an exception in the comment: if the unit body has an import of Predef among its leading imports.
I think spec should mention this exception.
The text was updated successfully, but these errors were encountered: