summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/macros/runtime/AbortMacroException.scala (renamed from src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Aliases.scala (renamed from src/compiler/scala/reflect/makro/runtime/Aliases.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/CapturedVariables.scala (renamed from src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Context.scala (renamed from src/compiler/scala/reflect/makro/runtime/Context.scala)4
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Enclosures.scala (renamed from src/compiler/scala/reflect/makro/runtime/Enclosures.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Evals.scala (renamed from src/compiler/scala/reflect/makro/runtime/Evals.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/ExprUtils.scala (renamed from src/compiler/scala/reflect/makro/runtime/ExprUtils.scala)4
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Exprs.scala (renamed from src/compiler/scala/reflect/makro/runtime/Exprs.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/FrontEnds.scala (renamed from src/compiler/scala/reflect/makro/runtime/FrontEnds.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Infrastructure.scala (renamed from src/compiler/scala/reflect/makro/runtime/Infrastructure.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Names.scala (renamed from src/compiler/scala/reflect/makro/runtime/Names.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Parsers.scala (renamed from src/compiler/scala/reflect/makro/runtime/Parsers.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Reifiers.scala (renamed from src/compiler/scala/reflect/makro/runtime/Reifiers.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Settings.scala (renamed from src/compiler/scala/reflect/makro/runtime/Settings.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Traces.scala (renamed from src/compiler/scala/reflect/makro/runtime/Traces.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/TypeTags.scala (renamed from src/compiler/scala/reflect/makro/runtime/TypeTags.scala)2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Typers.scala (renamed from src/compiler/scala/reflect/makro/runtime/Typers.scala)33
-rw-r--r--src/compiler/scala/reflect/macros/util/Traces.scala (renamed from src/compiler/scala/reflect/makro/util/Traces.scala)2
-rw-r--r--src/compiler/scala/reflect/reify/Errors.scala4
-rw-r--r--src/compiler/scala/reflect/reify/Reifier.scala6
-rw-r--r--src/compiler/scala/reflect/reify/Taggers.scala4
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenSymbols.scala2
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTypes.scala8
-rw-r--r--src/compiler/scala/reflect/reify/package.scala7
-rw-r--r--src/compiler/scala/reflect/reify/utils/Extractors.scala30
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala9
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala4
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala19
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Imports.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala8
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala5
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Power.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala3
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala84
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala5
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala13
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Tags.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/compiler/scala/tools/reflect/FastTrack.scala2
-rw-r--r--src/compiler/scala/tools/reflect/MacroImplementations.scala8
-rw-r--r--src/compiler/scala/tools/reflect/StdTags.scala6
-rw-r--r--src/compiler/scala/tools/reflect/ToolBox.scala54
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala122
-rw-r--r--src/compiler/scala/tools/util/PathResolver.scala2
50 files changed, 241 insertions, 269 deletions
diff --git a/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala b/src/compiler/scala/reflect/macros/runtime/AbortMacroException.scala
index a68910859d..f45dde8a85 100644
--- a/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala
+++ b/src/compiler/scala/reflect/macros/runtime/AbortMacroException.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
import scala.reflect.internal.util.Position
diff --git a/src/compiler/scala/reflect/makro/runtime/Aliases.scala b/src/compiler/scala/reflect/macros/runtime/Aliases.scala
index 760f7fc54d..8b742755cd 100644
--- a/src/compiler/scala/reflect/makro/runtime/Aliases.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Aliases.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Aliases {
diff --git a/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala b/src/compiler/scala/reflect/macros/runtime/CapturedVariables.scala
index 021b93ceee..78fb7100b0 100644
--- a/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala
+++ b/src/compiler/scala/reflect/macros/runtime/CapturedVariables.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait CapturedVariables {
diff --git a/src/compiler/scala/reflect/makro/runtime/Context.scala b/src/compiler/scala/reflect/macros/runtime/Context.scala
index 68964b7abb..8bbfef44a3 100644
--- a/src/compiler/scala/reflect/makro/runtime/Context.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Context.scala
@@ -1,9 +1,9 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
import scala.tools.nsc.Global
-abstract class Context extends scala.reflect.makro.Context
+abstract class Context extends scala.reflect.macros.Context
with Aliases
with CapturedVariables
with Infrastructure
diff --git a/src/compiler/scala/reflect/makro/runtime/Enclosures.scala b/src/compiler/scala/reflect/macros/runtime/Enclosures.scala
index 360a4b8e8a..ebde4447d7 100644
--- a/src/compiler/scala/reflect/makro/runtime/Enclosures.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Enclosures.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Enclosures {
diff --git a/src/compiler/scala/reflect/makro/runtime/Evals.scala b/src/compiler/scala/reflect/macros/runtime/Evals.scala
index 0574359a19..348e29cdd7 100644
--- a/src/compiler/scala/reflect/makro/runtime/Evals.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Evals.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
import scala.reflect.runtime.{universe => ru}
diff --git a/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala b/src/compiler/scala/reflect/macros/runtime/ExprUtils.scala
index e301dfc2a4..672699f00e 100644
--- a/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala
+++ b/src/compiler/scala/reflect/macros/runtime/ExprUtils.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait ExprUtils {
@@ -29,7 +29,7 @@ trait ExprUtils {
def literal(x: Double) = Expr[Double](Literal(Constant(x)))(TypeTag.Double)
- def literal(x: String) = Expr[String](Literal(Constant(x)))(TypeTag[String](definitions.StringClass.asTypeConstructor))
+ def literal(x: String) = Expr[String](Literal(Constant(x)))(TypeTag[String](definitions.StringClass.toTypeConstructor))
def literal(x: Char) = Expr[Char](Literal(Constant(x)))(TypeTag.Char)
}
diff --git a/src/compiler/scala/reflect/makro/runtime/Exprs.scala b/src/compiler/scala/reflect/macros/runtime/Exprs.scala
index b680b56bab..4217a6a404 100644
--- a/src/compiler/scala/reflect/makro/runtime/Exprs.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Exprs.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Exprs {
diff --git a/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala b/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala
index 6644c579ac..69fa416f8f 100644
--- a/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala
+++ b/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait FrontEnds extends scala.tools.reflect.FrontEnds {
diff --git a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
index 76c4b21731..19fb03364e 100644
--- a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
import scala.tools.nsc.util.ScalaClassLoader
diff --git a/src/compiler/scala/reflect/makro/runtime/Names.scala b/src/compiler/scala/reflect/macros/runtime/Names.scala
index 3f43b15d90..ee9f3a56d3 100644
--- a/src/compiler/scala/reflect/makro/runtime/Names.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Names.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Names {
diff --git a/src/compiler/scala/reflect/makro/runtime/Parsers.scala b/src/compiler/scala/reflect/macros/runtime/Parsers.scala
index ac8d09f592..6d89b71f39 100644
--- a/src/compiler/scala/reflect/makro/runtime/Parsers.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Parsers.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
import language.existentials
diff --git a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala b/src/compiler/scala/reflect/macros/runtime/Reifiers.scala
index 10b5ae5f42..056549578a 100644
--- a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Reifiers.scala
@@ -3,7 +3,7 @@
* @author Gilles Dubochet
*/
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Reifiers {
diff --git a/src/compiler/scala/reflect/makro/runtime/Settings.scala b/src/compiler/scala/reflect/macros/runtime/Settings.scala
index 8288180b8d..b7dba665fa 100644
--- a/src/compiler/scala/reflect/makro/runtime/Settings.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Settings.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Settings {
diff --git a/src/compiler/scala/reflect/makro/runtime/Traces.scala b/src/compiler/scala/reflect/macros/runtime/Traces.scala
index 225ee1f62b..0238e9f84e 100644
--- a/src/compiler/scala/reflect/makro/runtime/Traces.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Traces.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Traces extends util.Traces {
diff --git a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala b/src/compiler/scala/reflect/macros/runtime/TypeTags.scala
index 4f9b287674..2bc2fe6384 100644
--- a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala
+++ b/src/compiler/scala/reflect/macros/runtime/TypeTags.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait TypeTags {
diff --git a/src/compiler/scala/reflect/makro/runtime/Typers.scala b/src/compiler/scala/reflect/macros/runtime/Typers.scala
index 18c1714d15..9fa8567ada 100644
--- a/src/compiler/scala/reflect/makro/runtime/Typers.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Typers.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package runtime
trait Typers {
@@ -10,8 +10,9 @@ trait Typers {
def typeCheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
macroLogVerbose("typechecking %s with expected type %s, implicit views = %s, macros = %s".format(tree, pt, !withImplicitViewsDisabled, !withMacrosDisabled))
- val wrapper1 = if (!withImplicitViewsDisabled) (callsiteTyper.context.withImplicitsEnabled[Tree] _) else (callsiteTyper.context.withImplicitsDisabled[Tree] _)
- val wrapper2 = if (!withMacrosDisabled) (callsiteTyper.context.withMacrosEnabled[Tree] _) else (callsiteTyper.context.withMacrosDisabled[Tree] _)
+ val context = callsiteTyper.context
+ val wrapper1 = if (!withImplicitViewsDisabled) (context.withImplicitsEnabled[Tree] _) else (context.withImplicitsDisabled[Tree] _)
+ val wrapper2 = if (!withMacrosDisabled) (context.withMacrosEnabled[Tree] _) else (context.withMacrosDisabled[Tree] _)
def wrapper (tree: => Tree) = wrapper1(wrapper2(tree))
// if you get a "silent mode is not available past typer" here
// don't rush to change the typecheck not to use the silent method when the silent parameter is false
@@ -31,29 +32,21 @@ trait Typers {
def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
macroLogVerbose("inferring implicit value of type %s, macros = %s".format(pt, !withMacrosDisabled))
- import universe.analyzer.SearchResult
- val context = callsiteTyper.context
- val wrapper1 = if (!withMacrosDisabled) (context.withMacrosEnabled[SearchResult] _) else (context.withMacrosDisabled[SearchResult] _)
- def wrapper (inference: => SearchResult) = wrapper1(inference)
- wrapper(universe.analyzer.inferImplicit(universe.EmptyTree, pt, true, false, context, !silent, pos)) match {
- case failure if failure.tree.isEmpty =>
- macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
- universe.EmptyTree
- case success =>
- success.tree
- }
+ inferImplicit(universe.EmptyTree, pt, isView = false, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
+ }
+
+ def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
+ macroLogVerbose("inferring implicit view from %s to %s for %s, macros = %s".format(from, to, tree, !withMacrosDisabled))
+ val viewTpe = universe.appliedType(universe.definitions.FunctionClass(1).toTypeConstructor, List(from, to))
+ inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
}
- def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true, pos: Position = enclosingPosition): Tree = {
- macroLogVerbose("inferring implicit view from %s to %s for %s, macros = %s, reportAmbiguous = %s".format(from, to, tree, !withMacrosDisabled, reportAmbiguous))
+ private def inferImplicit(tree: Tree, pt: Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: Position): Tree = {
import universe.analyzer.SearchResult
val context = callsiteTyper.context
val wrapper1 = if (!withMacrosDisabled) (context.withMacrosEnabled[SearchResult] _) else (context.withMacrosDisabled[SearchResult] _)
def wrapper (inference: => SearchResult) = wrapper1(inference)
- val fun1 = universe.definitions.FunctionClass(1)
- val viewTpe = universe.TypeRef(fun1.typeConstructor.prefix, fun1, List(from, to))
- wrapper(universe.analyzer.inferImplicit(tree, viewTpe, reportAmbiguous, true, context, !silent, pos)) match {
+ wrapper(universe.analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos)) match {
case failure if failure.tree.isEmpty =>
macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
diff --git a/src/compiler/scala/reflect/makro/util/Traces.scala b/src/compiler/scala/reflect/macros/util/Traces.scala
index 2363cc4bac..6c2f115994 100644
--- a/src/compiler/scala/reflect/makro/util/Traces.scala
+++ b/src/compiler/scala/reflect/macros/util/Traces.scala
@@ -1,4 +1,4 @@
-package scala.reflect.makro
+package scala.reflect.macros
package util
trait Traces {
diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala
index 1b72b3075b..5e15c5ad3a 100644
--- a/src/compiler/scala/reflect/reify/Errors.scala
+++ b/src/compiler/scala/reflect/reify/Errors.scala
@@ -1,7 +1,7 @@
package scala.reflect.reify
-import scala.reflect.makro.ReificationError
-import scala.reflect.makro.UnexpectedReificationError
+import scala.reflect.macros.ReificationError
+import scala.reflect.macros.UnexpectedReificationError
trait Errors {
self: Reifier =>
diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala
index 8fba7274be..53e01309cb 100644
--- a/src/compiler/scala/reflect/reify/Reifier.scala
+++ b/src/compiler/scala/reflect/reify/Reifier.scala
@@ -1,8 +1,8 @@
package scala.reflect.reify
import scala.tools.nsc.Global
-import scala.reflect.makro.ReificationError
-import scala.reflect.makro.UnexpectedReificationError
+import scala.reflect.macros.ReificationError
+import scala.reflect.macros.UnexpectedReificationError
import scala.reflect.reify.utils.Utils
/** Given a tree or a type, generate a tree that when executed at runtime produces the original tree or type.
@@ -115,7 +115,7 @@ abstract class Reifier extends States
// todo. maybe try `resetLocalAttrs` once the dust settles
var importantSymbols = Set[Symbol](
NothingClass, AnyClass, SingletonClass, PredefModule, ScalaRunTimeModule, TypeCreatorClass, TreeCreatorClass, MirrorOfClass,
- BaseUniverseClass, ApiUniverseClass, JavaUniverseClass, ReflectRuntimePackage, ReflectRuntimeCurrentMirror)
+ BaseUniverseClass, JavaUniverseClass, ReflectRuntimePackage, ReflectRuntimeCurrentMirror)
importantSymbols ++= importantSymbols map (_.companionSymbol)
importantSymbols ++= importantSymbols map (_.moduleClass)
importantSymbols ++= importantSymbols map (_.linkedClassOfClass)
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala
index 4e30d0acf8..a8523fe686 100644
--- a/src/compiler/scala/reflect/reify/Taggers.scala
+++ b/src/compiler/scala/reflect/reify/Taggers.scala
@@ -1,7 +1,7 @@
package scala.reflect.reify
-import scala.reflect.makro.{ReificationError, UnexpectedReificationError}
-import scala.reflect.makro.runtime.Context
+import scala.reflect.macros.{ReificationError, UnexpectedReificationError}
+import scala.reflect.macros.runtime.Context
abstract class Taggers {
val c: Context
diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
index 38c8fedac5..59651bcdf9 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
@@ -36,7 +36,7 @@ trait GenSymbols {
else if (sym.isEmptyPackageClass)
mirrorMirrorSelect(nme.EmptyPackageClass)
else if (sym.isModuleClass)
- Select(Select(reify(sym.sourceModule), nme.asModuleSymbol), nme.moduleClass)
+ Select(Select(reify(sym.sourceModule), nme.asModule), nme.moduleClass)
else if (sym.isPackage)
mirrorMirrorCall(nme.staticPackage, reify(sym.fullName))
else if (sym.isLocatable) {
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
index c49e5b3342..c762a28f99 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
@@ -30,7 +30,7 @@ trait GenTypes {
val tsym = tpe.typeSymbolDirect
if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic)
- Select(Select(reify(tsym), nme.asTypeSymbol), nme.asTypeConstructor)
+ Select(Select(reify(tsym), nme.asType), nme.toTypeConstructor)
else tpe match {
case tpe @ NoType =>
reifyMirrorObject(tpe)
@@ -42,7 +42,7 @@ trait GenTypes {
mirrorBuildCall(nme.thisPrefix, mirrorMirrorSelect(nme.EmptyPackageClass))
case tpe @ ThisType(clazz) if clazz.isModuleClass && clazz.isStatic =>
val module = reify(clazz.sourceModule)
- val moduleClass = Select(Select(module, nme.asModuleSymbol), nme.moduleClass)
+ val moduleClass = Select(Select(module, nme.asModule), nme.moduleClass)
mirrorFactoryCall(nme.ThisType, moduleClass)
case tpe @ ThisType(_) =>
reifyProduct(tpe)
@@ -94,7 +94,7 @@ trait GenTypes {
}
case success =>
if (reifyDebug) println("implicit search has produced a result: " + success)
- state.reificationIsConcrete &= concrete || success.tpe <:< TypeTagClass.asTypeConstructor
+ state.reificationIsConcrete &= concrete || success.tpe <:< TypeTagClass.toTypeConstructor
Select(Apply(Select(success, nme.in), List(Ident(nme.MIRROR_SHORT))), nme.tpe)
}
if (result != EmptyTree) return result
@@ -109,7 +109,7 @@ trait GenTypes {
def searchForManifest(typer: analyzer.Typer): Tree =
analyzer.inferImplicit(
EmptyTree,
- appliedType(FullManifestClass.asTypeConstructor, List(tpe)),
+ appliedType(FullManifestClass.toTypeConstructor, List(tpe)),
reportAmbiguous = false,
isView = false,
context = typer.context,
diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala
index 80011368a8..a253effc1c 100644
--- a/src/compiler/scala/reflect/reify/package.scala
+++ b/src/compiler/scala/reflect/reify/package.scala
@@ -1,9 +1,8 @@
package scala.reflect
import language.implicitConversions
-import language.experimental.macros
import scala.reflect.base.{Universe => BaseUniverse}
-import scala.reflect.makro.{Context, ReificationError, UnexpectedReificationError}
+import scala.reflect.macros.{Context, ReificationError, UnexpectedReificationError}
import scala.tools.nsc.Global
package object reify {
@@ -29,7 +28,7 @@ package object reify {
import definitions._
val enclosingErasure = reifyEnclosingRuntimeClass(global)(typer0)
// JavaUniverse is defined in scala-reflect.jar, so we must be very careful in case someone reifies stuff having only scala-library.jar on the classpath
- val isJavaUniverse = JavaUniverseClass != NoSymbol && universe.tpe <:< JavaUniverseClass.asTypeConstructor
+ val isJavaUniverse = JavaUniverseClass != NoSymbol && universe.tpe <:< JavaUniverseClass.toTypeConstructor
if (isJavaUniverse && !enclosingErasure.isEmpty) Apply(Select(universe, nme.runtimeMirror), List(Select(enclosingErasure, sn.GetClassLoader)))
else Select(universe, nme.rootMirror)
}
@@ -69,7 +68,7 @@ package object reify {
if (isThisInScope) {
val enclosingClasses = typer0.context.enclosingContextChain map (_.tree) collect { case classDef: ClassDef => classDef }
val classInScope = enclosingClasses.headOption getOrElse EmptyTree
- if (!classInScope.isEmpty) reifyRuntimeClass(global)(typer0, classInScope.symbol.asTypeConstructor, concrete = true)
+ if (!classInScope.isEmpty) reifyRuntimeClass(global)(typer0, classInScope.symbol.toTypeConstructor, concrete = true)
else Select(This(tpnme.EMPTY), sn.GetClass)
} else EmptyTree
}
diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala
index 86265ec77a..ebe3957e69 100644
--- a/src/compiler/scala/reflect/reify/utils/Extractors.scala
+++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala
@@ -20,11 +20,6 @@ trait Extractors {
// ()
// };
// def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
- // val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe];
- // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- // applyImpl($m).asInstanceOf[U#Tree];
- // }
- // def applyImpl[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
// val $u: U = $m$untyped.universe;
// val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
// $u.Apply($u.Select($u.Select($u.build.This($m.staticPackage("scala.collection.immutable").moduleClass), $u.newTermName("List")), $u.newTermName("apply")), List($u.Literal($u.Constant(1)), $u.Literal($u.Constant(2))))
@@ -40,7 +35,7 @@ trait Extractors {
// def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
// val $u: U = $m$untyped.universe;
// val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- // $u.TypeRef($u.ThisType($m.staticPackage("scala.collection.immutable").moduleClass), $m.staticClass("scala.collection.immutable.List"), List($m.staticClass("scala.Int").asTypeConstructor))
+ // $u.TypeRef($u.ThisType($m.staticPackage("scala.collection.immutable").moduleClass), $m.staticClass("scala.collection.immutable.List"), List($m.staticClass("scala.Int").toTypeConstructor))
// }
// };
// new $typecreator1()
@@ -51,23 +46,7 @@ trait Extractors {
val tparamu = newTypeName("U")
val (reifierBase, reifierName, reifierTpt, reifierUniverse) = flavor match {
case tpnme.REIFY_TYPECREATOR_PREFIX => (TypeCreatorClass, nme.apply, SelectFromTypeTree(Ident(tparamu), tpnme.Type), BaseUniverseClass)
- case tpnme.REIFY_TREECREATOR_PREFIX => (TreeCreatorClass, nme.applyImpl, SelectFromTypeTree(Ident(BaseUniverseClass), tpnme.Tree), ApiUniverseClass)
- case _ => throw new Error(s"unexpected flavor $flavor")
- }
- val reifierPreamble = flavor match {
- case tpnme.REIFY_TYPECREATOR_PREFIX => Nil
- case tpnme.REIFY_TREECREATOR_PREFIX => List[Tree](
- DefDef(NoMods,
- nme.apply,
- List(TypeDef(Modifiers(PARAM), tparamu, List(), TypeBoundsTree(Ident(NothingClass), CompoundTypeTree(Template(List(Ident(BaseUniverseClass), Ident(SingletonClass)), emptyValDef, List()))))),
- List(List(ValDef(Modifiers(PARAM), nme.MIRROR_UNTYPED, AppliedTypeTree(Ident(MirrorOfClass), List(Ident(tparamu))), EmptyTree))),
- SelectFromTypeTree(Ident(tparamu), tpnme.Tree),
- Block(
- ValDef(NoMods, nme.UNIVERSE_SHORT, Ident(ApiUniverseClass), TypeApply(Select(Select(Ident(nme.MIRROR_UNTYPED), nme.universe), nme.asInstanceOf_), List(Ident(ApiUniverseClass)))),
- ValDef(NoMods, nme.MIRROR_SHORT, Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror), TypeApply(Select(Ident(nme.MIRROR_UNTYPED), nme.asInstanceOf_), List(Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror)))),
- TypeApply(Select(Apply(TypeApply(Ident(reifierName), List(SingletonTypeTree(Ident(nme.UNIVERSE_SHORT)))), List(Ident(nme.MIRROR_SHORT))), nme.asInstanceOf_), List(SelectFromTypeTree(Ident(tparamu), tpnme.Tree)))
- ))
- )
+ case tpnme.REIFY_TREECREATOR_PREFIX => (TreeCreatorClass, nme.apply, SelectFromTypeTree(Ident(tparamu), tpnme.Tree), BaseUniverseClass)
case _ => throw new Error(s"unexpected flavor $flavor")
}
val reifierBody = {
@@ -98,8 +77,7 @@ trait Extractors {
Template(List(Ident(reifierBase)),
emptyValDef,
List(
- DefDef(NoMods, nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(()))))
- ) ++ reifierPreamble ++ List(
+ DefDef(NoMods, nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))),
DefDef(NoMods,
reifierName,
List(TypeDef(Modifiers(PARAM), tparamu, List(), TypeBoundsTree(Ident(NothingClass), CompoundTypeTree(Template(List(Ident(reifierUniverse), Ident(SingletonClass)), emptyValDef, List()))))),
@@ -128,7 +106,7 @@ trait Extractors {
case Block(
List(udef @ ValDef(_, _, _, universe), mdef @ ValDef(_, _, _, mirror)),
Apply(
- Apply(TypeApply(_, List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, _, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable1, rtree)))))), _))),
+ Apply(TypeApply(_, List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable1, rtree)))))), _))),
// todo. doesn't take into account optimizations such as $u.TypeTag.Int or the upcoming closure optimization
List(Apply(TypeApply(tagFactory @ Select(_, _), _), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable2, rtpe)))))), _))))))
if udef.name == nme.UNIVERSE_SHORT && mdef.name == nme.MIRROR_SHORT =>
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
index e590a0b691..f681de93b6 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -993,8 +993,13 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
case sb@ScalaSigBytes(bytes) =>
// see http://www.scala-lang.org/sid/10 (Storage of pickled Scala signatures in class files)
// also JVMS Sec. 4.7.16.1 The element_value structure and JVMS Sec. 4.4.7 The CONSTANT_Utf8_info Structure.
- val assocValue = (if(sb.fitsInOneString) strEncode(sb) else arrEncode(sb))
- av.visit(name, assocValue)
+ if (sb.fitsInOneString)
+ av.visit(name, strEncode(sb))
+ else {
+ val arrAnnotV: asm.AnnotationVisitor = av.visitArray(name)
+ for(arg <- arrEncode(sb)) { arrAnnotV.visit(name, arg) }
+ arrAnnotV.visitEnd()
+ }
// for the lazy val in ScalaSigBytes to be GC'ed, the invoker of emitAnnotations() should hold the ScalaSigBytes in a method-local var that doesn't escape.
case ArrayAnnotArg(args) =>
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 00e6f3769e..8805f68634 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -380,7 +380,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
if (settings.docImplicits.value) makeImplicitConversions(sym, this) else Nil
// members as given by the compiler
- lazy val memberSyms = sym.info.members.filter(s => membersShouldDocument(s, this))
+ lazy val memberSyms = sym.info.members.filter(s => membersShouldDocument(s, this)).toList
// the inherited templates (classes, traits or objects)
var memberSymsLazy = memberSyms.filter(t => templateShouldDocument(t, this) && !inOriginalOwner(t, this))
@@ -712,7 +712,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
override def inheritedFrom = Nil
override def isRootPackage = true
override lazy val memberSyms =
- (bSym.info.members ++ EmptyPackage.info.members) filter { s =>
+ (bSym.info.members ++ EmptyPackage.info.members).toList filter { s =>
s != EmptyPackage && s != RootPackage
}
})
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
index a12b67c9ed..5a0cc602e5 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -386,7 +386,7 @@ trait ModelFactoryImplicitSupport {
lazy val memberImpls: List[MemberImpl] = {
// Obtain the members inherited by the implicit conversion
- val memberSyms = toType.members.filter(implicitShouldDocument(_))
+ val memberSyms = toType.members.filter(implicitShouldDocument(_)).toList
val existingSyms = sym.info.members
// Debugging part :)
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index 27b6cae2a6..77bc77e966 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -749,12 +749,20 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
val originalTypeParams = sym.owner.typeParams
parseAndEnter(unit)
val pre = adaptToNewRunMap(ThisType(sym.owner))
- val newsym = pre.typeSymbol.info.decl(sym.name) filter { alt =>
+ val rawsym = pre.typeSymbol.info.decl(sym.name)
+ val newsym = rawsym filter { alt =>
sym.isType || {
try {
val tp1 = pre.memberType(alt) onTypeError NoType
val tp2 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, sym.owner.typeParams)
- matchesType(tp1, tp2, false)
+ matchesType(tp1, tp2, false) || {
+ debugLog(s"getLinkPos matchesType($tp1, $tp2) failed")
+ val tp3 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, alt.owner.typeParams)
+ matchesType(tp1, tp3, false) || {
+ debugLog(s"getLinkPos fallback matchesType($tp1, $tp3) failed")
+ false
+ }
+ }
}
catch {
case ex: ControlThrowable => throw ex
@@ -766,8 +774,11 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
}
if (newsym == NoSymbol) {
- debugLog("link not found " + sym + " " + source + " " + pre)
- NoPosition
+ if (rawsym.exists && !rawsym.isOverloaded) rawsym.pos
+ else {
+ debugLog("link not found " + sym + " " + source + " " + pre)
+ NoPosition
+ }
} else if (newsym.isOverloaded) {
settings.uniqid.value = true
debugLog("link ambiguous " + sym + " " + source + " " + pre + " " + newsym.alternatives)
diff --git a/src/compiler/scala/tools/nsc/interpreter/Imports.scala b/src/compiler/scala/tools/nsc/interpreter/Imports.scala
index d579e0369e..5e72d2b661 100644
--- a/src/compiler/scala/tools/nsc/interpreter/Imports.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/Imports.scala
@@ -191,5 +191,5 @@ trait Imports {
prevRequestList flatMap (req => req.handlers map (req -> _))
private def membersAtPickler(sym: Symbol): List[Symbol] =
- beforePickler(sym.info.nonPrivateMembers)
+ beforePickler(sym.info.nonPrivateMembers.toList)
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
index c429e3b196..b9849e40d1 100644
--- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala
@@ -52,10 +52,10 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput
// XXX we'd like to say "filterNot (_.isDeprecated)" but this causes the
// compiler to crash for reasons not yet known.
- def members = afterTyper((effectiveTp.nonPrivateMembers ++ anyMembers) filter (_.isPublic))
- def methods = members filter (_.isMethod)
- def packages = members filter (_.isPackage)
- def aliases = members filter (_.isAliasType)
+ def members = afterTyper((effectiveTp.nonPrivateMembers.toList ++ anyMembers) filter (_.isPublic))
+ def methods = members.toList filter (_.isMethod)
+ def packages = members.toList filter (_.isPackage)
+ def aliases = members.toList filter (_.isAliasType)
def memberNames = members map tos
def methodNames = methods map tos
diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
index 236f3f23c5..5cea86d57d 100644
--- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -9,6 +9,7 @@ package interpreter
import scala.collection.{ mutable, immutable }
import scala.PartialFunction.cond
import scala.reflect.internal.Chars
+import scala.reflect.internal.Flags._
import language.implicitConversions
trait MemberHandlers {
@@ -126,7 +127,7 @@ trait MemberHandlers {
class DefHandler(member: DefDef) extends MemberDefHandler(member) {
private def vparamss = member.vparamss
- private def isMacro = member.mods.hasFlag(scala.reflect.internal.Flags.MACRO)
+ private def isMacro = member.symbol hasFlag MACRO
// true if not a macro and 0-arity
override def definesValue = !isMacro && flattensToEmpty(vparamss)
override def resultExtractionCode(req: Request) =
@@ -211,7 +212,7 @@ trait MemberHandlers {
beforePickler(individualNames map (targetType nonPrivateMember _))
lazy val wildcardSymbols: List[Symbol] =
- if (importsWildcard) beforePickler(targetType.nonPrivateMembers)
+ if (importsWildcard) beforePickler(targetType.nonPrivateMembers.toList)
else Nil
/** Complete list of names imported by a wildcard */
diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala
index 57d7cef726..ebc02d98ed 100644
--- a/src/compiler/scala/tools/nsc/interpreter/Power.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala
@@ -62,7 +62,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re
def discarded = seen.size - keep.size
def members(x: Symbol): List[Symbol] =
- if (x.rawInfo.isComplete) x.info.members
+ if (x.rawInfo.isComplete) x.info.members.toList
else Nil
var lastCount = -1
@@ -216,7 +216,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re
def declsOriginal = membersDeclared filterNot (_.isOverride)
def members = membersUnabridged filterNot excludeMember
- def membersUnabridged = tpe.members
+ def membersUnabridged = tpe.members.toList
def membersDeclared = members filterNot excludeMember
def membersInherited = members filterNot (membersDeclared contains _)
def memberTypes = members filter (_.name.isTypeName)
diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
index 56b9c7011c..202d5d3f82 100644
--- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
@@ -212,8 +212,7 @@ trait TypeStrings {
}
private def tparamString[T: ru.TypeTag] : String = {
- // [Eugene++ to Paul] needs review!!
- def typeArguments: List[ru.Type] = ru.typeOf[T].typeArguments
+ def typeArguments: List[ru.Type] = ru.typeOf[T] match { case ru.TypeRef(_, _, args) => args; case _ => Nil }
// [Eugene++] todo. need to use not the `rootMirror`, but a mirror with the REPL's classloader
// how do I get to it? acquiring context classloader seems unreliable because of multithreading
def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => ru.rootMirror.runtimeClass(targ))
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index aa30a7a45b..3906d7761f 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -205,8 +205,6 @@ trait ScalaSettings extends AbsScalaSettings
// Feature extensions
val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.")
- val XmacroPrimaryClasspath = PathSetting("-Xmacro-primary-classpath", "Classpath to load macros implementations from, defaults to compilation classpath (aka \"library classpath\".", "")
- val XmacroFallbackClasspath = PathSetting("-Xmacro-fallback-classpath", "Classpath to load macros implementations from if they cannot be loaded from library classpath.", "")
/**
* IDE-specific settings
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 0fc298e886..c7dab69f62 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -360,7 +360,7 @@ trait Contexts { self: Analyzer =>
private def unitError(pos: Position, msg: String) =
unit.error(pos, if (checking) "\n**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
-
+
@inline private def issueCommon(err: AbsTypeError)(pf: PartialFunction[AbsTypeError, Unit]) {
debugwarn("issue error: " + err.errMsg)
if (settings.Yissuedebug.value) (new Exception).printStackTrace()
@@ -611,8 +611,8 @@ trait Contexts { self: Analyzer =>
(e ne null) && (e.owner == scope)
})
- private def collectImplicits(syms: List[Symbol], pre: Type, imported: Boolean = false): List[ImplicitInfo] =
- for (sym <- syms if isQualifyingImplicit(sym.name, sym, pre, imported)) yield
+ private def collectImplicits(syms: Scope, pre: Type, imported: Boolean = false): List[ImplicitInfo] =
+ for (sym <- syms.toList if isQualifyingImplicit(sym.name, sym, pre, imported)) yield
new ImplicitInfo(sym.name, pre, sym)
private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = {
@@ -657,7 +657,7 @@ trait Contexts { self: Analyzer =>
}
} else if (scope != nextOuter.scope && !owner.isPackageClass) {
debuglog("collect local implicits " + scope.toList)//DEBUG
- collectImplicits(scope.toList, NoPrefix)
+ collectImplicits(scope, NoPrefix)
} else if (imports != nextOuter.imports) {
assert(imports.tail == nextOuter.imports, (imports, nextOuter.imports))
collectImplicitImports(imports.head)
@@ -725,7 +725,7 @@ trait Contexts { self: Analyzer =>
result
}
- def allImportedSymbols: List[Symbol] =
+ def allImportedSymbols: Iterable[Symbol] =
qual.tpe.members flatMap (transformImport(tree.selectors, _))
private def transformImport(selectors: List[ImportSelector], sym: Symbol): List[Symbol] = selectors match {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index da045e1a48..b442d16b1c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -957,7 +957,7 @@ trait Implicits {
companion.moduleClass match {
case mc: ModuleClassSymbol =>
val infos =
- for (im <- mc.implicitMembers) yield new ImplicitInfo(im.name, singleType(pre, companion), im)
+ for (im <- mc.implicitMembers.toList) yield new ImplicitInfo(im.name, singleType(pre, companion), im)
if (infos.nonEmpty)
infoMap += (sym -> infos)
case _ =>
@@ -1196,7 +1196,7 @@ trait Implicits {
gen.mkAttributedThis(thisSym)
case _ =>
// if ``pre'' is not a PDT, e.g. if someone wrote
- // implicitly[scala.reflect.makro.Context#TypeTag[Int]]
+ // implicitly[scala.reflect.macros.Context#TypeTag[Int]]
// then we need to fail, because we don't know the prefix to use during type reification
// upd. we also need to fail silently, because this is a very common situation
// e.g. quite often we're searching for BaseUniverse#TypeTag, e.g. for a type tag in any universe
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index d33857371d..1381450970 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -8,7 +8,7 @@ import scala.reflect.runtime.ReflectionUtils
import scala.collection.mutable.ListBuffer
import scala.compat.Platform.EOL
import reflect.internal.util.Statistics
-import scala.reflect.makro.util._
+import scala.reflect.macros.util._
import java.lang.{Class => jClass}
import java.lang.reflect.{Array => jArray, Method => jMethod}
@@ -24,7 +24,7 @@ import java.lang.reflect.{Array => jArray, Method => jMethod}
* Then fooBar needs to point to a static method of the following form:
*
* def fooBar[T: c.TypeTag]
- * (c: scala.reflect.makro.Context)
+ * (c: scala.reflect.macros.Context)
* (xs: c.Expr[List[T]])
* : c.Expr[T] = {
* ...
@@ -51,7 +51,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
/** A list of compatible macro implementation signatures.
*
* In the example above:
- * (c: scala.reflect.makro.Context)(xs: c.Expr[List[T]]): c.Expr[T]
+ * (c: scala.reflect.macros.Context)(xs: c.Expr[List[T]]): c.Expr[T]
*
* @param macroDef The macro definition symbol
* @param tparams The type parameters of the macro definition
@@ -591,53 +591,34 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
runtimeType
}
- /** Primary classloader that is used to resolve and run macro implementations.
- * Loads classes from -Xmacro-primary-classpath, or from -cp if the option is not specified.
+ /** Macro classloader that is used to resolve and run macro implementations.
+ * Loads classes from from -cp (aka the library classpath).
* Is also capable of detecting REPL and reusing its classloader.
*/
- private lazy val primaryClassloader: ClassLoader = {
+ private lazy val macroClassloader: ClassLoader = {
if (global.forMSIL)
throw new UnsupportedOperationException("Scala reflection not available on this platform")
- if (settings.XmacroPrimaryClasspath.value != "") {
- macroLogVerbose("primary macro classloader: initializing from -Xmacro-primary-classpath: %s".format(settings.XmacroPrimaryClasspath.value))
- val classpath = toURLs(settings.XmacroPrimaryClasspath.value)
- ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
- } else {
- macroLogVerbose("primary macro classloader: initializing from -cp: %s".format(global.classPath.asURLs))
- val classpath = global.classPath.asURLs
- var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
-
- // [Eugene] a heuristic to detect the REPL
- if (global.settings.exposeEmptyPackage.value) {
- macroLogVerbose("primary macro classloader: initializing from a REPL classloader".format(global.classPath.asURLs))
- import scala.tools.nsc.interpreter._
- val virtualDirectory = global.settings.outputDirs.getSingleOutput.get
- loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
- }
+ val classpath = global.classPath.asURLs
+ macroLogVerbose("macro classloader: initializing from -cp: %s".format(classpath))
+ val loader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
+ // [Eugene] a heuristic to detect the REPL
+ if (global.settings.exposeEmptyPackage.value) {
+ macroLogVerbose("macro classloader: initializing from a REPL classloader".format(global.classPath.asURLs))
+ import scala.tools.nsc.interpreter._
+ val virtualDirectory = global.settings.outputDirs.getSingleOutput.get
+ new AbstractFileClassLoader(virtualDirectory, loader) {}
+ } else {
loader
}
}
- /** Fallback classloader that is used to resolve and run macro implementations when `primaryClassloader` fails.
- * Loads classes from -Xmacro-fallback-classpath.
- */
- private lazy val fallbackClassloader: ClassLoader = {
- if (global.forMSIL)
- throw new UnsupportedOperationException("Scala reflection not available on this platform")
-
- macroLogVerbose("fallback macro classloader: initializing from -Xmacro-fallback-classpath: %s".format(settings.XmacroFallbackClasspath.value))
- val classpath = toURLs(settings.XmacroFallbackClasspath.value)
- ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
- }
-
/** Produces a function that can be used to invoke macro implementation for a given macro definition:
* 1) Looks up macro implementation symbol in this universe.
- * 2) Loads its enclosing class from the primary classloader.
- * 3) Loads the companion of that enclosing class from the primary classloader.
+ * 2) Loads its enclosing class from the macro classloader.
+ * 3) Loads the companion of that enclosing class from the macro classloader.
* 4) Resolves macro implementation within the loaded companion.
- * 5) If 2-4 fails, repeats them for the fallback classloader.
*
* @return Some(runtime) if macro implementation can be loaded successfully from either of the mirrors,
* None otherwise.
@@ -742,25 +723,10 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
}
}
- val primary = loadMacroImpl(primaryClassloader)
- primary match {
- case Some((implObj, implMeth)) =>
+ loadMacroImpl(macroClassloader) map {
+ case (implObj, implMeth) =>
def runtime(args: List[Any]) = implMeth.invoke(implObj, (args map (_.asInstanceOf[AnyRef])): _*).asInstanceOf[Any]
- Some(runtime _)
- case None =>
- if (settings.XmacroFallbackClasspath.value != "") {
- macroLogVerbose("trying to load macro implementation from the fallback mirror: %s".format(settings.XmacroFallbackClasspath.value))
- val fallback = loadMacroImpl(fallbackClassloader)
- fallback match {
- case Some((implObj, implMeth)) =>
- def runtime(args: List[Any]) = implMeth.invoke(implObj, (args map (_.asInstanceOf[AnyRef])): _*).asInstanceOf[Any]
- Some(runtime _)
- case None =>
- None
- }
- } else {
- None
- }
+ runtime _
}
}
@@ -913,7 +879,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
}
/** Keeps track of macros in-flight.
- * See more informations in comments to ``openMacros'' in ``scala.reflect.makro.Context''.
+ * See more informations in comments to ``openMacros'' in ``scala.reflect.macros.Context''.
*/
var openMacros = List[MacroContext]()
def enclosingMacroPosition = openMacros map (_.macroApplication.pos) find (_ ne NoPosition) getOrElse NoPosition
@@ -1147,9 +1113,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
val macroDef = expandee.symbol
def notFound() = {
typer.context.error(expandee.pos, "macro implementation not found: " + macroDef.name + " " +
- "(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)\n" +
- "if you do need to define macro implementations along with the rest of your program, consider two-phase compilation with -Xmacro-fallback-classpath " +
- "in the second phase pointing to the output of the first phase")
+ "(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)")
None
}
def fallBackToOverridden(tree: Tree): Option[Tree] = {
@@ -1191,7 +1155,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// [Eugene] any ideas about how to improve this one?
val realex = ReflectionUtils.unwrapThrowable(ex)
realex match {
- case realex: reflect.makro.runtime.AbortMacroException =>
+ case realex: reflect.macros.runtime.AbortMacroException =>
macroLogVerbose("macro expansion has failed: %s".format(realex.msg))
fail(typer, expandee) // error has been reported by abort
case err: TypeError =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index 7bd5f4caeb..bd2808d049 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -70,11 +70,8 @@ trait MethodSynthesis {
// [Eugene++->Martin] now this compiles, will soon check it out
def newMethodType[F](owner: Symbol)(implicit t: TT[F]): Type = {
val fnSymbol = compilerSymbolFromTag(t)
- assert(fnSymbol isSubClass FunctionClass(t.tpe.typeArguments.size - 1), (owner, t))
- // [Eugene++ to Paul] needs review!!
- // val symbols = m.typeArguments map (m => manifestToSymbol(m))
- // val formals = symbols.init map (_.typeConstructor)
val formals = compilerTypeFromTag(t).typeArguments
+ assert(fnSymbol isSubClass FunctionClass(formals.size - 1), (owner, t))
val params = owner newSyntheticValueParams formals
MethodType(params, formals.last)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index dc9f07cad9..44712ba286 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -983,15 +983,10 @@ trait Namers extends MethodSynthesis {
}
addDefaultGetters(meth, vparamss, tparams, overriddenSymbol)
- // macro defs need to be typechecked in advance
- // because @macroImpl annotation only gets assigned during typechecking
- // otherwise we might find ourselves in the situation when we specified -Xmacro-fallback-classpath
- // but macros still don't expand
- // that might happen because macro def doesn't have its link a macro impl yet
- if (ddef.symbol.isTermMacro) {
- val pt = resultPt.substSym(tparamSyms, tparams map (_.symbol))
- typer.computeMacroDefType(ddef, pt)
- }
+ // fast track macros, i.e. macros defined inside the compiler, are hardcoded
+ // hence we make use of that and let them have whatever right-hand side they need
+ // (either "macro ???" as they used to or just "???" to maximally simplify their compilation)
+ if (fastTrack contains ddef.symbol) ddef.symbol setFlag MACRO
thisMethodType({
val rt = (
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 3518316fbb..9501998152 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -122,7 +122,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
val defaultGetters = clazz.info.findMembers(0L, DEFAULTPARAM)
val defaultMethodNames = defaultGetters map (sym => nme.defaultGetterToMethod(sym.name))
- defaultMethodNames.distinct foreach { name =>
+ defaultMethodNames.toList.distinct foreach { name =>
val methods = clazz.info.findMember(name, 0L, METHOD, false).alternatives
val haveDefaults = methods filter (sym => sym.hasParamWhich(_.hasDefault) && !nme.isProtectedAccessorName(sym.name))
@@ -628,7 +628,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
matchingArity match {
// So far so good: only one candidate method
- case concrete :: Nil =>
+ case Scope(concrete) =>
val mismatches = abstractParams zip concrete.tpe.paramTypes filterNot { case (x, y) => x =:= y }
mismatches match {
// Only one mismatched parameter: say something useful.
diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
index 190b18711c..64c5b41638 100644
--- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala
@@ -4,7 +4,7 @@ package typechecker
trait StdAttachments {
self: Analyzer =>
- type UnaffiliatedMacroContext = scala.reflect.makro.runtime.Context
+ type UnaffiliatedMacroContext = scala.reflect.macros.runtime.Context
type MacroContext = UnaffiliatedMacroContext { val universe: self.global.type }
case class MacroRuntimeAttachment(delayed: Boolean, typerContext: Context, macroContext: Option[MacroContext])
} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala
index 052484e8e1..f82e009be8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Tags.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala
@@ -61,7 +61,7 @@ trait Tags {
*/
def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = {
val tagSym = if (concrete) TypeTagClass else AbsTypeTagClass
- val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.asTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name)
+ val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.toTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name)
val taggedTp = appliedType(tagTp, List(tp))
resolveTag(pos, taggedTp, allowMaterialization)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e57cae00e0..b06ea639b0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -5089,7 +5089,7 @@ trait Typers extends Modes with Adaptations with Tags {
// convert new Array^N[T](len) for N > 1 to evidence[ClassTag[Array[...Array[T]...]]].newArray(len), where Array HK gets applied (N-1) times
// [Eugene] no more MaxArrayDims. ClassTags are flexible enough to allow creation of arrays of arbitrary dimensionality (w.r.t JVM restrictions)
val Some((level, componentType)) = erasure.GenericArray.unapply(tpt.tpe)
- val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.asType, List(tpe))).last
+ val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.toTypeConstructor, List(tpe))).last
val newArrayApp = atPos(tree.pos) {
val tag = resolveClassTag(tree.pos, tagType)
if (tag.isEmpty) MissingClassTagError(tree, tagType)
diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala
index 237ef813c7..e093c64c72 100644
--- a/src/compiler/scala/tools/reflect/FastTrack.scala
+++ b/src/compiler/scala/tools/reflect/FastTrack.scala
@@ -38,7 +38,7 @@ trait FastTrack {
MacroInternal_materializeClassTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeClassTag(u, tt.tpe) }
MacroInternal_materializeAbsTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) }
MacroInternal_materializeTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = true) }
- ApiUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) }
+ BaseUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) }
ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree }
StringContext_f bindTo { case (c, app@Apply(Select(Apply(_, parts), _), args)) => c.macro_StringInterpolation_f(parts, args, app.pos) }
registry
diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala
index e1b959cefa..40ceefcc70 100644
--- a/src/compiler/scala/tools/reflect/MacroImplementations.scala
+++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala
@@ -1,7 +1,7 @@
package scala.tools.reflect
-import scala.reflect.makro.{ReificationError, UnexpectedReificationError}
-import scala.reflect.makro.runtime.Context
+import scala.reflect.macros.{ReificationError, UnexpectedReificationError}
+import scala.reflect.macros.runtime.Context
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.Stack
@@ -25,9 +25,9 @@ abstract class MacroImplementations {
c.abort(args(parts.length-1).pos,
"too many arguments for interpolated string")
}
- val stringParts = parts map {
+ val stringParts = parts map {
case Literal(Constant(s: String)) => s;
- case _ => throw new IllegalArgumentException("argument parts must be a list of string literals")
+ case _ => throw new IllegalArgumentException("argument parts must be a list of string literals")
}
val pi = stringParts.iterator
diff --git a/src/compiler/scala/tools/reflect/StdTags.scala b/src/compiler/scala/tools/reflect/StdTags.scala
index 25a42a82cd..0704189ddc 100644
--- a/src/compiler/scala/tools/reflect/StdTags.scala
+++ b/src/compiler/scala/tools/reflect/StdTags.scala
@@ -20,7 +20,7 @@ trait StdTags {
def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type = {
val u = m.universe
val pre = u.ThisType(m.staticPackage("scala.collection.immutable").moduleClass.asInstanceOf[u.Symbol])
- u.TypeRef(pre, u.definitions.ListClass, List(u.definitions.StringClass.asTypeConstructor))
+ u.TypeRef(pre, u.definitions.ListClass, List(u.definitions.StringClass.toTypeConstructor))
}
})
@@ -29,7 +29,7 @@ trait StdTags {
m,
new TypeCreator {
def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type =
- m.staticClass(classTag[T].runtimeClass.getName).asTypeConstructor.asInstanceOf[U # Type]
+ m.staticClass(classTag[T].runtimeClass.getName).toTypeConstructor.asInstanceOf[U # Type]
})
lazy val tagOfInt = u.TypeTag.Int
lazy val tagOfString = tagOfStaticClass[String]
@@ -52,7 +52,7 @@ object StdRuntimeTags extends StdTags {
}
abstract class StdContextTags extends StdTags {
- val tc: scala.reflect.makro.Context
+ val tc: scala.reflect.macros.Context
val u: tc.universe.type = tc.universe
val m = tc.mirror
}
diff --git a/src/compiler/scala/tools/reflect/ToolBox.scala b/src/compiler/scala/tools/reflect/ToolBox.scala
index edd22c60f4..2505c1afb7 100644
--- a/src/compiler/scala/tools/reflect/ToolBox.scala
+++ b/src/compiler/scala/tools/reflect/ToolBox.scala
@@ -24,40 +24,46 @@ trait ToolBox[U <: Universe] {
/** Typechecks a tree using this ToolBox.
* This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings.
*
- * If the tree has unresolved type variables (represented as instances of ``FreeTypeSymbol'' symbols),
- * then they might, might be partially or might not be specified in the ``freeTypes'' parameter.
+ * If the tree has unresolved type variables (represented as instances of `FreeTypeSymbol` symbols),
+ * then they all have to be resolved first using `Tree.substituteTypes`, or an error occurs.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of a typecheck error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of a typecheck error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Ydebug.
*
* Typechecking can be steered with the following optional parameters:
- * ``withImplicitViewsDisabled'' recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
- * ``withMacrosDisabled'' recursively prohibits macro expansions and macro-based implicits, default value is false
+ * `withImplicitViewsDisabled` recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
+ * `withMacrosDisabled` recursively prohibits macro expansions and macro-based implicits, default value is false
*/
- def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, freeTypes: Map[u.FreeTypeSymbol, u.Type] = Map[u.FreeTypeSymbol, u.Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
+ def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
-
- /** Infers an implicit value of the expected type ``pt'' in the macro callsite context.
+ /** Infers an implicit value of the expected type `pt` in top-level context.
+ * Optional `pos` parameter provides a position that will be associated with the implicit search.
+ *
+ * As mentioned in https://groups.google.com/forum/#!topic/scala-internals/ta-vbUT6JE8
+ * this API won't take into account the lexical context of the callsite, because
+ * currently it's impossible to reify it.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
+ * Unlike in `typeCheck`, `silent` is true by default.
*/
- def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false): u.Tree
+ def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree
- /** Infers an implicit view from the provided tree ``tree'' from the type ``from'' to the type ``to'' in the macro callsite context.
+ /** Infers an implicit view from the provided tree `tree` from the type `from` to the type `to` in the toplevel context.
+ * Optional `pos` parameter provides a position that will be associated with the implicit search.
*
- * Otional parameter, ``reportAmbiguous`` controls whether ambiguous implicit errors should be reported.
- * If we search for a view simply to find out whether one type is coercible to another, it might be desirable to set this flag to ``false''.
+ * As mentioned in https://groups.google.com/forum/#!topic/scala-internals/ta-vbUT6JE8
+ * this API won't take into account the lexical context of the callsite, because
+ * currently it's impossible to reify it.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
+ * Unlike in `typeCheck`, `silent` is true by default.
*/
- def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true): u.Tree
+ def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree
/** Recursively resets symbols and types in a given tree.
*
@@ -78,14 +84,14 @@ trait ToolBox[U <: Universe] {
/** Compiles and runs a tree using this ToolBox.
*
- * If the tree has unresolved type variables (represented as instances of ``FreeTypeSymbol'' symbols),
- * then they all have to be specified in the ``freeTypes'' parameter or an error occurs.
+ * If the tree has unresolved type variables (represented as instances of `FreeTypeSymbol` symbols),
+ * then they all have to be resolved first using `Tree.substituteTypes`, or an error occurs.
*
* This spawns the compiler at the Namer phase, and pipelines the tree through that compiler.
- * Currently ``runExpr'' does not accept trees that already typechecked, because typechecking isn't idempotent.
+ * Currently `runExpr` does not accept trees that already typechecked, because typechecking isn't idempotent.
* For more info, take a look at https://issues.scala-lang.org/browse/SI-5464.
*/
- def runExpr(tree: u.Tree, freeTypes: Map[u.FreeTypeSymbol, u.Type] = Map[u.FreeTypeSymbol, u.Type]()): Any
+ def runExpr(tree: u.Tree): Any
}
/** Represents an error during toolboxing
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index 589c5c7eb0..9987931cf3 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -85,7 +85,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
if (tree.hasSymbol && tree.symbol.isFreeTerm) {
tree match {
case Ident(_) =>
- val freeTermRef = Ident(freeTermNames(tree.symbol.asFreeTermSymbol))
+ val freeTermRef = Ident(freeTermNames(tree.symbol.asFreeTerm))
if (wrapFreeTermRefs) Apply(freeTermRef, List()) else freeTermRef
case _ =>
throw new Error("internal error: %s (%s, %s) is not supported".format(tree, tree.productPrefix, tree.getClass))
@@ -97,7 +97,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
(expr, freeTermNames)
}
- def typeCheckExpr(expr0: Tree, pt: Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree = {
+ def transformDuringTyper(expr0: Tree, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean)(transform: (analyzer.Typer, Tree) => Tree): Tree = {
verifyExpr(expr0)
// need to wrap the expr, because otherwise you won't be able to typecheck macros against something that contains free vars
@@ -121,34 +121,56 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
currentTyper.context.setReportErrors() // need to manually set context mode, otherwise typer.silent will throw exceptions
reporter.reset()
- trace("typing (implicit views = %s, macros = %s): ".format(!withImplicitViewsDisabled, !withMacrosDisabled))(showAttributed(expr, true, true, settings.Yshowsymkinds.value))
- wrapper(currentTyper.silent(_.typed(expr, analyzer.EXPRmode, pt)) match {
- case analyzer.SilentResultValue(result) =>
- trace("success: ")(showAttributed(result, true, true, settings.Yshowsymkinds.value))
- var (dummies, unwrapped) = result match {
- case Block(dummies, unwrapped) => (dummies, unwrapped)
- case unwrapped => (Nil, unwrapped)
+ val expr1 = wrapper(transform(currentTyper, expr))
+ var (dummies1, unwrapped) = expr1 match {
+ case Block(dummies, unwrapped) => (dummies, unwrapped)
+ case unwrapped => (Nil, unwrapped)
+ }
+ var invertedIndex = freeTerms map (_.swap)
+ // todo. also fixup singleton types
+ unwrapped = new Transformer {
+ override def transform(tree: Tree): Tree =
+ tree match {
+ case Ident(name) if invertedIndex contains name =>
+ Ident(invertedIndex(name)) setType tree.tpe
+ case _ =>
+ super.transform(tree)
}
- var invertedIndex = freeTerms map (_.swap)
- // todo. also fixup singleton types
- unwrapped = new Transformer {
- override def transform(tree: Tree): Tree =
- tree match {
- case Ident(name) if invertedIndex contains name =>
- Ident(invertedIndex(name)) setType tree.tpe
- case _ =>
- super.transform(tree)
- }
- }.transform(unwrapped)
- new TreeTypeSubstituter(dummies map (_.symbol), dummies map (dummy => SingleType(NoPrefix, invertedIndex(dummy.symbol.name)))).traverse(unwrapped)
- unwrapped
- case error @ analyzer.SilentTypeError(_) =>
- trace("failed: ")(error.err.errMsg)
- if (!silent) throw ToolBoxError("reflective typecheck has failed: %s".format(error.err.errMsg))
- EmptyTree
- })
+ }.transform(unwrapped)
+ new TreeTypeSubstituter(dummies1 map (_.symbol), dummies1 map (dummy => SingleType(NoPrefix, invertedIndex(dummy.symbol.name)))).traverse(unwrapped)
+ unwrapped
}
+ def typeCheckExpr(expr: Tree, pt: Type, silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree =
+ transformDuringTyper(expr, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)(
+ (currentTyper, expr) => {
+ trace("typing (implicit views = %s, macros = %s): ".format(!withImplicitViewsDisabled, !withMacrosDisabled))(showAttributed(expr, true, true, settings.Yshowsymkinds.value))
+ currentTyper.silent(_.typed(expr, analyzer.EXPRmode, pt)) match {
+ case analyzer.SilentResultValue(result) =>
+ trace("success: ")(showAttributed(result, true, true, settings.Yshowsymkinds.value))
+ result
+ case error @ analyzer.SilentTypeError(_) =>
+ trace("failed: ")(error.err.errMsg)
+ if (!silent) throw ToolBoxError("reflective typecheck has failed: %s".format(error.err.errMsg))
+ EmptyTree
+ }
+ })
+
+ def inferImplicit(tree: Tree, pt: Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: Position): Tree =
+ transformDuringTyper(tree, withImplicitViewsDisabled = false, withMacrosDisabled = withMacrosDisabled)(
+ (currentTyper, tree) => {
+ trace("inferring implicit %s (macros = %s): ".format(if (isView) "view" else "value", !withMacrosDisabled))(showAttributed(pt, true, true, settings.Yshowsymkinds.value))
+ val context = currentTyper.context
+ analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos) match {
+ case failure if failure.tree.isEmpty =>
+ trace("implicit search has failed. to find out the reason, turn on -Xlog-implicits: ")(failure.tree)
+ if (context.hasErrors) throw ToolBoxError("reflective implicit search has failed: %s".format(context.errBuffer.head.errMsg))
+ EmptyTree
+ case success =>
+ success.tree
+ }
+ })
+
def compileExpr(expr: Tree): (Object, java.lang.reflect.Method) = {
verifyExpr(expr)
@@ -254,7 +276,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
}
}
- def showAttributed(tree: Tree, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String = {
+ def showAttributed(artifact: Any, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String = {
val saved1 = settings.printtypes.value
val saved2 = settings.uniqid.value
val saved3 = settings.Yshowsymkinds.value
@@ -262,7 +284,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
settings.printtypes.value = printTypes
settings.uniqid.value = printIds
settings.Yshowsymkinds.value = printKinds
- tree.toString
+ artifact.toString
} finally {
settings.printtypes.value = saved1
settings.uniqid.value = saved2
@@ -312,29 +334,37 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
lazy val exporter = importer.reverse
lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, mirror.classLoader)
- def typeCheck(tree: u.Tree, expectedType: u.Type, freeTypes: Map[u.FreeTypeSymbol, u.Type], silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): u.Tree = {
- if (compiler.settings.verbose.value) println("typing "+tree+", expectedType = "+expectedType+", freeTypes = "+freeTypes)
+ def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = {
+ if (compiler.settings.verbose.value) println("importing "+tree+", expectedType = "+expectedType)
var ctree: compiler.Tree = importer.importTree(tree)
var cexpectedType: compiler.Type = importer.importType(expectedType)
- if (compiler.settings.verbose.value) println("substituting "+ctree+", expectedType = "+expectedType)
- val cfreeTypes: Map[compiler.FreeTypeSymbol, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeTypeSymbol], importer.importType(v)) }
- ctree = ctree.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
- cexpectedType = cexpectedType.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
-
if (compiler.settings.verbose.value) println("typing "+ctree+", expectedType = "+expectedType)
val ttree: compiler.Tree = compiler.typeCheckExpr(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)
val uttree = exporter.importTree(ttree)
uttree
}
- def inferImplicitValue(pt: u.Type, silent: Boolean, withMacrosDisabled: Boolean): u.Tree =
- // todo. implement this
- ???
+ def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree = {
+ inferImplicit(u.EmptyTree, pt, isView = false, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
+ }
+
+ def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree = {
+ val viewTpe = u.appliedType(u.definitions.FunctionClass(1).toTypeConstructor, List(from, to))
+ inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
+ }
- def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean, withMacrosDisabled: Boolean, reportAmbiguous: Boolean): u.Tree =
- // todo. implement this
- ???
+ private def inferImplicit(tree: u.Tree, pt: u.Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: u.Position): u.Tree = {
+ if (compiler.settings.verbose.value) println("importing "+pt, ", tree = "+tree+", pos = "+pos)
+ var ctree: compiler.Tree = importer.importTree(tree)
+ var cpt: compiler.Type = importer.importType(pt)
+ var cpos: compiler.Position = importer.importPosition(pos)
+
+ if (compiler.settings.verbose.value) println("inferring implicit %s of type %s, macros = %s".format(if (isView) "view" else "value", pt, !withMacrosDisabled))
+ val itree: compiler.Tree = compiler.inferImplicit(ctree, cpt, isView = isView, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = cpos)
+ val uitree = exporter.importTree(itree)
+ uitree
+ }
def resetAllAttrs(tree: u.Tree): u.Tree = {
val ctree: compiler.Tree = importer.importTree(tree)
@@ -360,14 +390,10 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
utree
}
- def runExpr(tree: u.Tree, freeTypes: Map[u.FreeTypeSymbol, u.Type]): Any = {
- if (compiler.settings.verbose.value) println("running "+tree+", freeTypes = "+freeTypes)
+ def runExpr(tree: u.Tree): Any = {
+ if (compiler.settings.verbose.value) println("importing "+tree)
var ctree: compiler.Tree = importer.importTree(tree)
- if (compiler.settings.verbose.value) println("substituting "+ctree)
- val cfreeTypes: Map[compiler.FreeTypeSymbol, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeTypeSymbol], importer.importType(v)) }
- ctree = ctree.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
-
if (compiler.settings.verbose.value) println("running "+ctree)
compiler.runExpr(ctree)
}
diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala
index 5f4e6d58c3..d89ebcb2a3 100644
--- a/src/compiler/scala/tools/util/PathResolver.scala
+++ b/src/compiler/scala/tools/util/PathResolver.scala
@@ -194,7 +194,7 @@ class PathResolver(settings: Settings, context: JavaContext) {
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
/** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as:
- * [scaladoc] ../scala-trunk/src/reflect/scala/reflect/makro/Reifiers.scala:89: error: object api is not a member of package reflect
+ * [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect
* [scaladoc] case class ReificationError(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
* [scaladoc] ^
* because the bootstrapping will look at the sourcepath and create package "reflect" in "<root>"