deprecated &f, .f, requires.
Added existential types. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@11911 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
141dd9d566
commit
184f59d66a
|
@ -94,17 +94,17 @@ object Futures {
|
|||
val reaction: PartialFunction[Any, unit] = new PartialFunction[Any, unit] {
|
||||
def isDefinedAt(msg: Any) = msg match {
|
||||
case TIMEOUT => true
|
||||
case _ => partFuns exists (.isDefinedAt(msg))
|
||||
case _ => partFuns exists (_ isDefinedAt msg)
|
||||
}
|
||||
def apply(msg: Any): unit = msg match {
|
||||
case TIMEOUT => // do nothing
|
||||
case _ => {
|
||||
val pfOpt = partFuns find (.isDefinedAt(msg))
|
||||
val pfOpt = partFuns find (_ isDefinedAt msg)
|
||||
val pf = pfOpt.get // succeeds always
|
||||
val Pair(idx, subres) = pf(msg)
|
||||
resultsMap(idx) = Some(subres)
|
||||
|
||||
val partFunsRest = partFuns filter (.!=(pf))
|
||||
val partFunsRest = partFuns filter (_ != pf)
|
||||
// wait on rest of partial functions
|
||||
if (partFunsRest.length > 0)
|
||||
awaitWith(partFunsRest)
|
||||
|
|
|
@ -95,7 +95,7 @@ class FastScalac extends Scalac {
|
|||
trim(
|
||||
List(settings.log) map (s => if (s.value.isEmpty) "" else s.name + ":" + s.value))
|
||||
|
||||
val args = (cmdOptions ::: (sourceFiles map (.toString()))).toArray
|
||||
val args = (cmdOptions ::: (sourceFiles map (_.toString))).toArray
|
||||
try {
|
||||
nsc.CompileClient.main0(args)
|
||||
} catch {
|
||||
|
|
|
@ -51,7 +51,7 @@ class ScalaTool extends MatchingTask {
|
|||
abstract class PermissibleValue {
|
||||
val values: List[String]
|
||||
def isPermissible(value: String): Boolean =
|
||||
(value == "") || values.exists(.startsWith(value))
|
||||
(value == "") || values.exists(_.startsWith(value))
|
||||
}
|
||||
|
||||
/** Defines valid values for the platforms property. */
|
||||
|
@ -222,7 +222,7 @@ class ScalaTool extends MatchingTask {
|
|||
* @returns The file as a file. */
|
||||
private def getFile: File =
|
||||
if (file.isEmpty) error("Member 'file' is empty.")
|
||||
else getProject().resolveFile(file.get.toString())
|
||||
else getProject().resolveFile(file.get.toString)
|
||||
|
||||
/** Gets the value of the bootclasspath attribute in a Scala-friendly form.
|
||||
* @returns The boot class path as a list of files. */
|
||||
|
@ -232,7 +232,7 @@ class ScalaTool extends MatchingTask {
|
|||
/** Gets the value of the bootclasspath attribute in a Scala-friendly form.
|
||||
* @returns The boot class path as a list of files. */
|
||||
private def getWinBootClasspath: String =
|
||||
bootclasspath.map(.replace('/', '\\')).
|
||||
bootclasspath.map(_.replace('/', '\\')).
|
||||
mkString("", ";", "")
|
||||
|
||||
/** Gets the value of the classpath attribute in a Scala-friendly form.
|
||||
|
@ -243,7 +243,7 @@ class ScalaTool extends MatchingTask {
|
|||
/** Gets the value of the classpath attribute in a Scala-friendly form.
|
||||
* @returns The class path as a list of files. */
|
||||
private def getWinExtClasspath: String =
|
||||
extclasspath.map(.replace('/', '\\')).
|
||||
extclasspath.map(_.replace('/', '\\')).
|
||||
mkString("", ";", "")
|
||||
|
||||
/** Gets the value of the classpath attribute in a Scala-friendly form.
|
||||
|
@ -289,15 +289,15 @@ class ScalaTool extends MatchingTask {
|
|||
token.append(char)
|
||||
char = chars.next
|
||||
}
|
||||
if (tokens.contains(token.toString()))
|
||||
builder.append(tokens(token.toString()))
|
||||
else if (token.toString() == "")
|
||||
if (tokens.contains(token.toString))
|
||||
builder.append(tokens(token.toString))
|
||||
else if (token.toString == "")
|
||||
builder.append('@')
|
||||
else
|
||||
builder.append("@" + token.toString() + "@")
|
||||
builder.append("@" + token.toString + "@")
|
||||
} else builder.append(char)
|
||||
}
|
||||
builder.toString()
|
||||
builder.toString
|
||||
}
|
||||
|
||||
private def writeFile(file: File, content: String) =
|
||||
|
|
|
@ -74,7 +74,7 @@ class Scalac extends MatchingTask {
|
|||
abstract class PermissibleValue {
|
||||
val values: List[String]
|
||||
def isPermissible(value: String): Boolean =
|
||||
(value == "") || values.exists(.startsWith(value))
|
||||
(value == "") || values.exists(_.startsWith(value))
|
||||
}
|
||||
|
||||
/** Defines valid values for the logging property. */
|
||||
|
@ -352,7 +352,7 @@ class Scalac extends MatchingTask {
|
|||
* @return The destination as a file. */
|
||||
private def getDestination: File =
|
||||
if (destination.isEmpty) error("Member 'destination' is empty.")
|
||||
else existing(getProject().resolveFile(destination.get.toString()))
|
||||
else existing(getProject().resolveFile(destination.get.toString))
|
||||
|
||||
/** Gets the value of the <code>sourcepath</code> attribute in a
|
||||
* Scala-friendly form.
|
||||
|
@ -406,7 +406,7 @@ class Scalac extends MatchingTask {
|
|||
* @return The same file. */
|
||||
private def existing(file: File): File = {
|
||||
if (!file.exists())
|
||||
log("Element '" + file.toString() + "' does not exist.",
|
||||
log("Element '" + file.toString + "' does not exist.",
|
||||
Project.MSG_WARN)
|
||||
file
|
||||
}
|
||||
|
@ -468,13 +468,13 @@ class Scalac extends MatchingTask {
|
|||
(if (list.length > 1) "s: " else ": "),
|
||||
", ",
|
||||
" "
|
||||
) + "to " + getDestination.toString()
|
||||
) + "to " + getDestination.toString
|
||||
)
|
||||
else if (list.length > 0)
|
||||
log(
|
||||
"Compiling " + list.length + " source file" +
|
||||
(if (list.length > 1) "s" else "") +
|
||||
(" to " + getDestination.toString())
|
||||
(" to " + getDestination.toString)
|
||||
)
|
||||
else
|
||||
log("No files selected for compilation", Project.MSG_VERBOSE)
|
||||
|
@ -483,7 +483,7 @@ class Scalac extends MatchingTask {
|
|||
}
|
||||
}
|
||||
yield {
|
||||
log(originFile.toString(), Project.MSG_DEBUG)
|
||||
log(originFile.toString, Project.MSG_DEBUG)
|
||||
nameToFile(originDir)(originFile)
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ class Scalac extends MatchingTask {
|
|||
log("Scalac params = '" + addParams + "'", Project.MSG_DEBUG)
|
||||
var args =
|
||||
if (addParams.trim() == "") Nil
|
||||
else List.fromArray(addParams.trim().split(" ")).map(.trim())
|
||||
else List.fromArray(addParams.trim().split(" ")).map(_.trim())
|
||||
while (!args.isEmpty) {
|
||||
val argsBuf = args
|
||||
if (args.head startsWith "-") {
|
||||
|
@ -542,7 +542,7 @@ class Scalac extends MatchingTask {
|
|||
// Compiles the actual code
|
||||
val compiler = new Global(settings, reporter)
|
||||
try {
|
||||
(new compiler.Run).compile(sourceFiles.map (.toString()))
|
||||
(new compiler.Run).compile(sourceFiles.map (_.toString))
|
||||
}
|
||||
catch {
|
||||
case exception: Throwable if (exception.getMessage ne null) =>
|
||||
|
|
|
@ -76,7 +76,7 @@ class Scaladoc extends MatchingTask {
|
|||
abstract class PermissibleValue {
|
||||
val values: List[String]
|
||||
def isPermissible(value: String): Boolean =
|
||||
(value == "") || values.exists(.startsWith(value))
|
||||
(value == "") || values.exists(_.startsWith(value))
|
||||
}
|
||||
|
||||
/** Defines valid values for the <code>deprecation</code> and
|
||||
|
@ -372,7 +372,7 @@ class Scaladoc extends MatchingTask {
|
|||
*/
|
||||
private def getDestination: File =
|
||||
if (destination.isEmpty) error("Member 'destination' is empty.")
|
||||
else existing(getProject().resolveFile(destination.get.toString()))
|
||||
else existing(getProject().resolveFile(destination.get.toString))
|
||||
|
||||
/** Gets the value of the <code>sourcepath</code> attribute in a
|
||||
* Scala-friendly form.
|
||||
|
@ -439,7 +439,7 @@ class Scaladoc extends MatchingTask {
|
|||
*/
|
||||
private def existing(file: File): File = {
|
||||
if (!file.exists())
|
||||
log("Element '" + file.toString() + "' does not exist.",
|
||||
log("Element '" + file.toString + "' does not exist.",
|
||||
Project.MSG_WARN)
|
||||
file
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ class Scaladoc extends MatchingTask {
|
|||
log(
|
||||
"Documenting " + list.length + " source file" +
|
||||
(if (list.length > 1) "s" else "") +
|
||||
(" to " + getDestination.toString())
|
||||
(" to " + getDestination.toString)
|
||||
)
|
||||
else
|
||||
log("No files selected for documentation", Project.MSG_VERBOSE)
|
||||
|
@ -508,7 +508,7 @@ class Scaladoc extends MatchingTask {
|
|||
list
|
||||
}
|
||||
} yield {
|
||||
log(originFile.toString(), Project.MSG_DEBUG)
|
||||
log(originFile.toString, Project.MSG_DEBUG)
|
||||
nameToFile(originDir)(originFile)
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,7 @@ class Scaladoc extends MatchingTask {
|
|||
log("Scaladoc params = '" + addParams + "'", Project.MSG_DEBUG)
|
||||
var args =
|
||||
if (addParams.trim() == "") Nil
|
||||
else List.fromArray(addParams.trim().split(" ")).map(.trim())
|
||||
else List.fromArray(addParams.trim().split(" ")).map(_.trim())
|
||||
while (!args.isEmpty) {
|
||||
val argsBuf = args
|
||||
if (args.head startsWith "-") {
|
||||
|
@ -571,7 +571,7 @@ class Scaladoc extends MatchingTask {
|
|||
val compiler = new Global(commandSettings, reporter)
|
||||
try {
|
||||
val run = new compiler.Run
|
||||
run.compile(sourceFiles.map (.toString()))
|
||||
run.compile(sourceFiles.map (_.toString))
|
||||
object generator extends DocDriver {
|
||||
val global: compiler.type = compiler
|
||||
def settings = commandSettings
|
||||
|
|
|
@ -10,7 +10,7 @@ import scala.tools.nsc.util.{FreshNameCreator,OffsetPosition,Position,SourceFile
|
|||
import scala.tools.nsc.io.AbstractFile
|
||||
import scala.collection.mutable.HashSet
|
||||
|
||||
trait CompilationUnits requires Global {
|
||||
trait CompilationUnits { self: Global =>
|
||||
|
||||
/** One unit of compilation that has been submitted to the compiler.
|
||||
* It typically corresponds to a single file of source code. It includes
|
||||
|
|
|
@ -26,10 +26,10 @@ class CompilerCommand(arguments: List[String], val settings: Settings,
|
|||
def usageMsg: String = {
|
||||
// todo: print -X and -javadoc options only on demand
|
||||
val helpSyntaxColumnWidth: int =
|
||||
Iterable.max(settings.allSettings map (. helpSyntax.length()))
|
||||
Iterable.max(settings.allSettings map (_.helpSyntax.length))
|
||||
def format(s: String): String = {
|
||||
val buf = new StringBuilder(s)
|
||||
var i = s.length()
|
||||
var i = s.length
|
||||
while (i < helpSyntaxColumnWidth) { buf.append(' '); i += 1 }
|
||||
buf.toString()
|
||||
}
|
||||
|
|
|
@ -574,7 +574,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
|
|||
error("can only compile one script at a time")
|
||||
val sources = filenames map (
|
||||
if (settings.Xscript.value)
|
||||
(x => ScriptRunner.wrappedScript(x, &getSourceFile))
|
||||
(x => ScriptRunner.wrappedScript(x, getSourceFile _))
|
||||
else
|
||||
getSourceFile)
|
||||
compileSources(sources)
|
||||
|
|
|
@ -845,7 +845,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
|
|||
def importsWildcard =
|
||||
trees.exists {
|
||||
case Import(_, selectors) =>
|
||||
selectors.map(._1).contains(nme.USCOREkw)
|
||||
selectors.map(_._1).contains(nme.USCOREkw)
|
||||
case _ => false
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ object ScriptRunner {
|
|||
setting.value = CompileClient.absFileNames(setting.value)
|
||||
|
||||
val compSettingNames =
|
||||
(new Settings(error)).allSettings.map(.name)
|
||||
(new Settings(error)).allSettings.map(_.name)
|
||||
|
||||
val compSettings =
|
||||
settings.allSettings.filter(stg =>
|
||||
|
@ -235,7 +235,7 @@ object ScriptRunner {
|
|||
val reporter = new ConsoleReporter(settings)
|
||||
val compiler = new Global(settings, reporter)
|
||||
val cr = new compiler.Run
|
||||
cr.compileSources(List(wrappedScript(scriptFile, &compiler.getSourceFile)))
|
||||
cr.compileSources(List(wrappedScript(scriptFile, compiler.getSourceFile _)))
|
||||
(compiledPath, !reporter.hasErrors)
|
||||
} else {
|
||||
val compok = compileWithDaemon(settings, scriptFile)
|
||||
|
|
|
@ -193,7 +193,8 @@ abstract class TreeInfo {
|
|||
def mayBeTypePat(tree: Tree): boolean = tree match {
|
||||
case CompoundTypeTree(Template(tps, _, List())) => tps exists mayBeTypePat
|
||||
case Annotated(_, tp) => mayBeTypePat(tp)
|
||||
case AppliedTypeTree(constr, args) => mayBeTypePat(constr) || args.exists(.isInstanceOf[Bind])
|
||||
case AppliedTypeTree(constr, args) =>
|
||||
mayBeTypePat(constr) || args.exists(_.isInstanceOf[Bind])
|
||||
case SelectFromTypeTree(tp, _) => mayBeTypePat(tp)
|
||||
case _ => false
|
||||
}
|
||||
|
|
|
@ -348,7 +348,7 @@ trait Trees {
|
|||
|
||||
def DefDef(sym: Symbol, mods: Modifiers, rhs: List[List[Symbol]] => Tree): DefDef = {
|
||||
val vparamss = syntheticParams(sym, sym.tpe)
|
||||
DefDef(sym, mods, vparamss map (.map(ValDef)), rhs(vparamss))
|
||||
DefDef(sym, mods, vparamss map (_.map(ValDef)), rhs(vparamss))
|
||||
}
|
||||
|
||||
def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef =
|
||||
|
@ -459,14 +459,14 @@ trait Trees {
|
|||
*/
|
||||
def Template(parents: List[Tree], self: ValDef, constrMods: Modifiers, vparamss: List[List[ValDef]], argss: List[List[Tree]], body: List[Tree]): Template = {
|
||||
/** Add constructor to template */
|
||||
var vparamss1 =
|
||||
vparamss map (.map (vd => {
|
||||
var vparamss1 =
|
||||
vparamss map (vps => vps.map { vd =>
|
||||
val ret = ValDef(Modifiers(vd.mods.flags & IMPLICIT | PARAM) withAnnotations vd.mods.annotations,
|
||||
vd.name, vd.tpt.duplicate, EmptyTree).setPos(vd.pos)
|
||||
if (inIDE && vd.symbol != NoSymbol)
|
||||
ret.symbol = vd.symbol
|
||||
ret
|
||||
}))
|
||||
})
|
||||
val (vdefs, rest) = body span treeInfo.isPreSuper
|
||||
val (lvdefs, gvdefs) = List.unzip {
|
||||
vdefs map {
|
||||
|
@ -728,6 +728,9 @@ trait Trees {
|
|||
case class WildcardTypeTree(lo: Tree, hi: Tree)
|
||||
extends TypTree
|
||||
|
||||
case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree])
|
||||
extends TypTree
|
||||
|
||||
/* A standard pattern match
|
||||
case EmptyTree =>
|
||||
case PackageDef(name, stats) =>
|
||||
|
@ -818,6 +821,8 @@ trait Trees {
|
|||
// tpt[args]
|
||||
case WildcardTypeTree(lo, hi) => (eliminated by uncurry)
|
||||
// todo: get rid of that!
|
||||
case ExistentialTypeTree(tpt, whereClauses) =>
|
||||
|
||||
*/
|
||||
|
||||
abstract class TreeCopier {
|
||||
|
@ -865,6 +870,7 @@ trait Trees {
|
|||
def CompoundTypeTree(tree: Tree, templ: Template): CompoundTypeTree
|
||||
def AppliedTypeTree(tree: Tree, tpt: Tree, args: List[Tree]): AppliedTypeTree
|
||||
def WildcardTypeTree(tree: Tree, lo: Tree, hi: Tree): WildcardTypeTree
|
||||
def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]): ExistentialTypeTree
|
||||
}
|
||||
|
||||
class StrictTreeCopier extends TreeCopier {
|
||||
|
@ -956,6 +962,8 @@ trait Trees {
|
|||
new AppliedTypeTree(tpt, args).copyAttrs(tree)
|
||||
def WildcardTypeTree(tree: Tree, lo: Tree, hi: Tree) =
|
||||
new WildcardTypeTree(lo, hi).copyAttrs(tree)
|
||||
def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) =
|
||||
new ExistentialTypeTree(tpt, whereClauses).copyAttrs(tree)
|
||||
}
|
||||
|
||||
class LazyTreeCopier(copy: TreeCopier) extends TreeCopier {
|
||||
|
@ -1180,6 +1188,11 @@ trait Trees {
|
|||
if (lo0 == lo) && (hi0 == hi) => t
|
||||
case _ => copy.WildcardTypeTree(tree, lo, hi)
|
||||
}
|
||||
def ExistentialTypeTree(tree: Tree, tpt: Tree, whereClauses: List[Tree]) = tree match {
|
||||
case t @ ExistentialTypeTree(tpt0, whereClauses0)
|
||||
if (tpt0 == tpt) && (whereClauses0 == whereClauses) => t
|
||||
case _ => copy.ExistentialTypeTree(tree, tpt, whereClauses)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Transformer {
|
||||
|
@ -1295,7 +1308,9 @@ trait Trees {
|
|||
case AppliedTypeTree(tpt, args) =>
|
||||
copy.AppliedTypeTree(tree, transform(tpt), transformTrees(args))
|
||||
case WildcardTypeTree(lo, hi) =>
|
||||
copy.WildcardTypeTree(tree, transform(lo), transform(hi))
|
||||
copy.WildcardTypeTree(tree, transform(lo), transform(hi))
|
||||
case ExistentialTypeTree(tpt, whereClauses) =>
|
||||
copy.ExistentialTypeTree(tree, transform(tpt), transformTrees(whereClauses))
|
||||
}
|
||||
|
||||
def transformTrees(trees: List[Tree]): List[Tree] =
|
||||
|
@ -1440,6 +1455,8 @@ trait Trees {
|
|||
traverse(tpt); traverseTrees(args)
|
||||
case WildcardTypeTree(lo, hi) =>
|
||||
traverse(lo); traverse(hi)
|
||||
case ExistentialTypeTree(tpt, whereClauses) =>
|
||||
traverse(tpt); traverseTrees(whereClauses)
|
||||
}
|
||||
|
||||
def traverseTrees(trees: List[Tree]): unit =
|
||||
|
|
|
@ -127,6 +127,11 @@ trait Parsers {
|
|||
*/
|
||||
var implicitParams: List[ValDef] = Nil
|
||||
|
||||
/** The wildcards introduced by `_' in the current type.
|
||||
* Parameters appear in reverse order
|
||||
*/
|
||||
var wildcards: List[AbsTypeDef] = Nil
|
||||
|
||||
/** this is the general parse method
|
||||
*/
|
||||
def parse(): Tree = {
|
||||
|
@ -618,12 +623,10 @@ trait Parsers {
|
|||
/** RequiresTypedOpt ::= [requires AnnotType]
|
||||
*/
|
||||
def requiresTypeOpt(): Tree =
|
||||
if (inToken == COLON | inToken == REQUIRES) {
|
||||
if (inToken == COLON)
|
||||
warning("`:' has been deprecated; use `requires' instead")
|
||||
if (inToken == REQUIRES) {
|
||||
warning("`requires T' has been deprecated; use `{ self: T => ...' instead")
|
||||
inNextToken; annotType(false)
|
||||
}
|
||||
else TypeTree()
|
||||
} else TypeTree()
|
||||
|
||||
/** Types ::= Type {`,' Type}
|
||||
* ArgTypePats ::= ArgTypePat {`,' ArgTypePat}
|
||||
|
@ -645,32 +648,63 @@ trait Parsers {
|
|||
private final val LeftOp = 1 // left associative
|
||||
private final val RightOp = 2 // right associative
|
||||
|
||||
/** Type ::= InfixType [`=>' Type]
|
||||
* | `(' [`=>' Type] `)' `=>' Type
|
||||
* XXX: Hook for IDE.
|
||||
/** GlobalType ::= Type
|
||||
*/
|
||||
def globalTyp(): Tree = {
|
||||
val savedWildcards = wildcards
|
||||
wildcards = List()
|
||||
var t = typ()
|
||||
if (!wildcards.isEmpty) t = ExistentialTypeTree(t, wildcards)
|
||||
wildcards = savedWildcards
|
||||
t
|
||||
}
|
||||
|
||||
/** Type ::= Type1 [where `{' {WhereClause} `}']
|
||||
*/
|
||||
def typ(): Tree = {
|
||||
val t = typ1()
|
||||
if (inToken == FORSOME) {
|
||||
atPos(inSkipToken) {
|
||||
val whereClauses = refinement()
|
||||
for (wc <- whereClauses) {
|
||||
wc match {
|
||||
case AbsTypeDef(_, _, _, _, _) | ValDef(_, _, _, EmptyTree) =>
|
||||
;
|
||||
case _ =>
|
||||
syntaxError(wc.pos, "not a legal where clause", false)
|
||||
}
|
||||
}
|
||||
ExistentialTypeTree(t, whereClauses)
|
||||
}
|
||||
} else t
|
||||
}
|
||||
|
||||
/** Type1 ::= InfixType [`=>' Type1]
|
||||
* | `(' [`=>' Type] `)' `=>' Type1
|
||||
* XXX: Hook for IDE.
|
||||
*/
|
||||
def typ1(): Tree = {
|
||||
val t =
|
||||
if (inToken == LPAREN) {
|
||||
val pos = inSkipToken
|
||||
if (inToken == RPAREN) {
|
||||
inNextToken
|
||||
atPos(accept(ARROW)) { makeFunctionTypeTree(List(), typ()) }
|
||||
atPos(accept(ARROW)) { makeFunctionTypeTree(List(), typ1()) }
|
||||
} else if (inToken == ARROW) {
|
||||
inNextToken
|
||||
val t0 = typ()
|
||||
val t0 = typ1()
|
||||
accept(RPAREN)
|
||||
atPos(accept(ARROW)) { makeByNameFunctionTypeTree(t0, typ()) }
|
||||
atPos(accept(ARROW)) { makeByNameFunctionTypeTree(t0, typ1()) }
|
||||
} else {
|
||||
val ts = types(false)
|
||||
accept(RPAREN)
|
||||
if (inToken == ARROW) atPos(inSkipToken) { makeFunctionTypeTree(ts, typ()) }
|
||||
if (inToken == ARROW) atPos(inSkipToken) { makeFunctionTypeTree(ts, typ1()) }
|
||||
else infixTypeRest(pos, makeTupleType(ts, true), false, FirstOp)
|
||||
}
|
||||
} else {
|
||||
infixType(false, FirstOp)
|
||||
}
|
||||
if (inToken == ARROW) atPos(inSkipToken) { makeFunctionTypeTree(List(t), typ()) }
|
||||
if (inToken == ARROW) atPos(inSkipToken) { makeFunctionTypeTree(List(t), typ1()) }
|
||||
else t
|
||||
}
|
||||
|
||||
|
@ -856,8 +890,8 @@ trait Parsers {
|
|||
* | Expr1
|
||||
* ResultExpr ::= (Bindings | Id `:' CompoundType) `=>' Block
|
||||
* | Expr1
|
||||
* Expr1 ::= if `(' Expr `)' {nl} Expr [semi] else Expr]
|
||||
* | try `{' block `}' [catch `{' caseClauses `}'] [finally Expr]
|
||||
* Expr1 ::= if `(' Expr `)' {nl} Expr [[semi] else Expr]
|
||||
* | try `{' Block `}' [catch `{' CaseClauses `}'] [finally Expr]
|
||||
* | while `(' Expr `)' {nl} Expr
|
||||
* | do Expr [semi] while `(' Expr `)'
|
||||
* | for (`(' Enumerators `)' | '{' Enumerators '}') {nl} [yield] Expr
|
||||
|
@ -865,10 +899,8 @@ trait Parsers {
|
|||
* | return [Expr]
|
||||
* | [SimpleExpr `.'] Id `=' Expr
|
||||
* | SimpleExpr1 ArgumentExprs `=' Expr
|
||||
* | `.' SimpleExpr
|
||||
* | PostfixExpr Ascription
|
||||
* | PostfixExpr match `{' CaseClauses `}'
|
||||
* | `.' Id {`.' Id | TypeArgs | ArgumentExprs}
|
||||
* Bindings ::= `(' [Binding {`,' Binding}] `)'
|
||||
* Binding ::= Id [`:' Type]
|
||||
* Ascription ::= `:' CompoundType
|
||||
|
@ -956,7 +988,7 @@ trait Parsers {
|
|||
Throw(expr())
|
||||
}
|
||||
case DOT =>
|
||||
//todo: deprecate
|
||||
warning("`.f' has been deprecated; use `_.f' instead")
|
||||
atPos(inSkipToken) {
|
||||
if (isIdent) {
|
||||
makeDotClosure(stripParens(simpleExpr()))
|
||||
|
@ -1066,6 +1098,7 @@ trait Parsers {
|
|||
val name = unaryOp()
|
||||
atPos(pos) { Select(stripParens(simpleExpr()), name) }
|
||||
} else if (isIdent && inName == AMP) {
|
||||
warning("`&f' has been deprecated; use `f _' instead")
|
||||
val pos = inCurrentPos
|
||||
val name = ident()
|
||||
atPos(pos) { Typed(stripParens(simpleExpr()), Function(List(), EmptyTree)) }
|
||||
|
@ -1218,7 +1251,7 @@ trait Parsers {
|
|||
* | val Pattern1 `=' Expr
|
||||
*/
|
||||
def enumerators(): List[Enumerator] = {
|
||||
val newStyle = inToken != VAL
|
||||
val newStyle = inToken != VAL // todo: deprecate old style
|
||||
val enums = new ListBuffer[Enumerator]
|
||||
generator(enums, false)
|
||||
while (isStatSep) {
|
||||
|
@ -1940,7 +1973,7 @@ trait Parsers {
|
|||
atPos(inSkipToken) {
|
||||
if (inToken == THIS) {
|
||||
inNextToken
|
||||
val vparamss = paramClauses(nme.CONSTRUCTOR, implicitClassViews map (.duplicate), false)
|
||||
val vparamss = paramClauses(nme.CONSTRUCTOR, implicitClassViews map (_.duplicate), false)
|
||||
newLineOptWhenFollowedBy(LBRACE)
|
||||
val rhs = if (inToken == LBRACE) constrBlock(vparamss)
|
||||
else { accept(EQUALS); constrExpr(vparamss) }
|
||||
|
|
|
@ -120,6 +120,7 @@ trait Scanners {
|
|||
enterKeyword(nme.FINALkw, FINAL)
|
||||
enterKeyword(nme.FINALLYkw, FINALLY)
|
||||
enterKeyword(nme.FORkw, FOR)
|
||||
enterKeyword(nme.FORSOMEkw, FORSOME)
|
||||
enterKeyword(nme.IFkw, IF)
|
||||
enterKeyword(nme.IMPLICITkw, IMPLICIT)
|
||||
enterKeyword(nme.IMPORTkw, IMPORT)
|
||||
|
@ -675,7 +676,7 @@ trait Scanners {
|
|||
}
|
||||
|
||||
def inFirstOfStat(token: int) = token match {
|
||||
case EOF | CASE | CATCH | ELSE | EXTENDS | FINALLY | MATCH | REQUIRES | WITH | YIELD |
|
||||
case EOF | CASE | CATCH | ELSE | EXTENDS | FINALLY | FORSOME | MATCH | REQUIRES | WITH | YIELD |
|
||||
COMMA | SEMI | NEWLINE | NEWLINES | DOT | USCORE | COLON | EQUALS | ARROW |
|
||||
LARROW | SUBTYPE | VIEWBOUND | SUPERTYPE | HASH | // todo: add LBRACKET
|
||||
RPAREN | RBRACKET | RBRACE =>
|
||||
|
|
|
@ -72,7 +72,8 @@ object Tokens {
|
|||
final val WHILE = 56
|
||||
final val RETURN = 57
|
||||
final val MATCH = 58
|
||||
final val REQUIRES = 59
|
||||
final val FORSOME = 59
|
||||
final val REQUIRES = 60
|
||||
|
||||
def isKeyword(code : Int) =
|
||||
code >= IF && code <= REQUIRES
|
||||
|
|
|
@ -300,7 +300,7 @@ abstract class TreeBuilder {
|
|||
ValFrom(pos, pat, makeCombination(nme.filter, rhs, pat.duplicate, test)) :: rest,
|
||||
body)
|
||||
case ValFrom(pos, pat, rhs) :: rest =>
|
||||
val valeqs = rest.take(definitions.MaxTupleArity - 1).takeWhile(.isInstanceOf[ValEq]);
|
||||
val valeqs = rest.take(definitions.MaxTupleArity - 1).takeWhile(_.isInstanceOf[ValEq]);
|
||||
assert(!valeqs.isEmpty)
|
||||
val rest1 = rest.drop(valeqs.length)
|
||||
val pats = valeqs map { case ValEq(_, pat, _) => pat }
|
||||
|
@ -408,7 +408,7 @@ abstract class TreeBuilder {
|
|||
val matchExpr = atPos(pat1.pos){
|
||||
Match(
|
||||
makeUnchecked(rhs),
|
||||
List(CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (._1) map Ident, true))))
|
||||
List(CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map Ident, true))))
|
||||
}
|
||||
vars match {
|
||||
case List() =>
|
||||
|
|
|
@ -380,7 +380,7 @@ trait BasicBlocks {
|
|||
// TODO: Take care of exception handlers!
|
||||
def successors : List[BasicBlock] = if (isEmpty) Nil else {
|
||||
var res = lastInstruction match {
|
||||
case JUMP (where) => List(where)
|
||||
case JUMP (whereto) => List(whereto)
|
||||
case CJUMP(success, failure, _, _) => success :: failure :: Nil
|
||||
case CZJUMP(success, failure, _, _) => success :: failure :: Nil
|
||||
case SWITCH(_,labels) => labels
|
||||
|
@ -404,7 +404,7 @@ trait BasicBlocks {
|
|||
* in different code 'chunks' than the rest of the method.
|
||||
*/
|
||||
def predecessors: List[BasicBlock] = {
|
||||
preds = code.blocks.elements.filter (.successors.contains(this)).toList
|
||||
preds = code.blocks.elements.filter (_.successors.contains(this)).toList
|
||||
preds
|
||||
}
|
||||
|
||||
|
|
|
@ -479,9 +479,9 @@ abstract class Checkers {
|
|||
checkBool(labels forall (b => code.blocks contains b),
|
||||
"Switch target cannot be found in code.")
|
||||
|
||||
case JUMP(where) =>
|
||||
checkBool(code.blocks contains where,
|
||||
"Jump to non-existant block " + where)
|
||||
case JUMP(whereto) =>
|
||||
checkBool(code.blocks contains whereto,
|
||||
"Jump to non-existant block " + whereto)
|
||||
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
checkBool(code.blocks contains success,
|
||||
|
|
|
@ -17,7 +17,7 @@ import scala.collection.mutable.HashSet;
|
|||
* all our handlers will catch `Throwable' and rely on proper ordering
|
||||
* in the generated code to preserve nesting.
|
||||
*/
|
||||
trait ExceptionHandlers requires ICodes {
|
||||
trait ExceptionHandlers { self: ICodes =>
|
||||
import global.{Symbol, NoSymbol};
|
||||
|
||||
class ExceptionHandler(val method: IMethod, val label: String, val cls: Symbol) {
|
||||
|
|
|
@ -197,7 +197,7 @@ abstract class GenICode extends SubComponent {
|
|||
private def genLoad(tree: Tree, ctx: Context, expectedType: TypeKind): Context = {
|
||||
var generatedType = expectedType
|
||||
if (settings.debug.value)
|
||||
log("at line: " + (tree.pos).line.map(.toString).get(tree.pos.toString))
|
||||
log("at line: " + (tree.pos).line.map(_.toString).get(tree.pos.toString))
|
||||
|
||||
/**
|
||||
* Generate code for primitive arithmetic operations.
|
||||
|
@ -387,7 +387,7 @@ abstract class GenICode extends SubComponent {
|
|||
label.patch(ctx.method.code)
|
||||
|
||||
case None =>
|
||||
ctx1.labels += tree.symbol -> (new Label(tree.symbol) anchor ctx1.bb setParams (params map (.symbol)));
|
||||
ctx1.labels += tree.symbol -> (new Label(tree.symbol) anchor ctx1.bb setParams (params map (_.symbol)));
|
||||
ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false)));
|
||||
if (settings.debug.value)
|
||||
log("Adding label " + tree.symbol);
|
||||
|
@ -1231,7 +1231,7 @@ abstract class GenICode extends SubComponent {
|
|||
|
||||
case LabelDef(name, params, rhs) =>
|
||||
if (!ctx.labels.contains(tree.symbol)) {
|
||||
ctx.labels += tree.symbol -> (new Label(tree.symbol) setParams(params map (.symbol)));
|
||||
ctx.labels += tree.symbol -> (new Label(tree.symbol) setParams(params map (_.symbol)));
|
||||
ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false)));
|
||||
}
|
||||
super.traverse(rhs)
|
||||
|
@ -1574,8 +1574,8 @@ abstract class GenICode extends SubComponent {
|
|||
log("Removing block: " + block)
|
||||
method.code.removeBlock(block)
|
||||
for (e <- method.exh) {
|
||||
e.covered = e.covered filter (.!=(block))
|
||||
e.blocks = e.blocks filter (.!=(block))
|
||||
e.covered = e.covered filter (_ != block)
|
||||
e.blocks = e.blocks filter (_ != block)
|
||||
if (e.startBlock eq block)
|
||||
e setStartBlock cont;
|
||||
}
|
||||
|
@ -1654,7 +1654,7 @@ abstract class GenICode extends SubComponent {
|
|||
val tree = copy.LabelDef(t, name1, params, transform(rhs))
|
||||
tree.symbol = labels(t.symbol)
|
||||
|
||||
ctx.labels += tree.symbol -> (new Label(tree.symbol) setParams(params map (.symbol)));
|
||||
ctx.labels += tree.symbol -> (new Label(tree.symbol) setParams(params map (_.symbol)));
|
||||
ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false)));
|
||||
|
||||
tree
|
||||
|
@ -1962,7 +1962,7 @@ abstract class GenICode extends SubComponent {
|
|||
}
|
||||
|
||||
val map = substMap
|
||||
code traverse (.subst(map))
|
||||
code traverse (_.subst(map))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2019,7 +2019,7 @@ abstract class GenICode extends SubComponent {
|
|||
label.addCallingInstruction(this);
|
||||
}
|
||||
|
||||
case class PJUMP(where: Label) extends PseudoJUMP(where)
|
||||
case class PJUMP(whereto: Label) extends PseudoJUMP(whereto)
|
||||
|
||||
case class PCJUMP(success: Label, failure: Label, cond: TestOp, kind: TypeKind)
|
||||
extends PseudoJUMP(success) {
|
||||
|
|
|
@ -10,7 +10,7 @@ package scala.tools.nsc.backend.icode;
|
|||
import scala.tools.nsc.ast._;
|
||||
import scala.collection.mutable.{Stack, HashSet};
|
||||
|
||||
trait Linearizers requires ICodes {
|
||||
trait Linearizers { self: ICodes =>
|
||||
import opcodes._;
|
||||
|
||||
abstract class Linearizer {
|
||||
|
@ -38,7 +38,7 @@ trait Linearizers requires ICodes {
|
|||
blocks = Nil;
|
||||
|
||||
run {
|
||||
worklist ++= (m.exh map (.startBlock));
|
||||
worklist ++= (m.exh map (_.startBlock));
|
||||
worklist.push(b);
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ trait Linearizers requires ICodes {
|
|||
if (b.size > 0) {
|
||||
add(b);
|
||||
b.lastInstruction match {
|
||||
case JUMP(where) =>
|
||||
add(where);
|
||||
case JUMP(whereto) =>
|
||||
add(whereto);
|
||||
case CJUMP(success, failure, _, _) =>
|
||||
add(success);
|
||||
add(failure);
|
||||
|
@ -154,7 +154,7 @@ trait Linearizers requires ICodes {
|
|||
if (m.code.startBlock.predecessors eq Nil)
|
||||
blocks
|
||||
else
|
||||
m.code.startBlock :: (blocks.remove(.==(m.code.startBlock)))
|
||||
m.code.startBlock :: (blocks.remove(_ == m.code.startBlock))
|
||||
}
|
||||
|
||||
def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = {
|
||||
|
|
|
@ -15,7 +15,7 @@ import scala.{Symbol => scala_Symbol};
|
|||
|
||||
import scala.tools.nsc.symtab.Flags;
|
||||
|
||||
trait Members requires ICodes {
|
||||
trait Members { self: ICodes =>
|
||||
import global._;
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ import scala.tools.nsc.util.{Position,NoPosition};
|
|||
case IS_INSTANCE(tpe) =>
|
||||
case CHECK_CAST(tpe) =>
|
||||
case SWITCH(tags, labels) =>
|
||||
case JUMP(where) =>
|
||||
case JUMP(whereto) =>
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
case CZJUMP(success, failure, cond, kind) =>
|
||||
case RETURN(kind) =>
|
||||
|
@ -51,7 +51,7 @@ import scala.tools.nsc.util.{Position,NoPosition};
|
|||
* erased types of Scala and references Symbols to refer named entities
|
||||
* in the source files.
|
||||
*/
|
||||
trait Opcodes requires ICodes {
|
||||
trait Opcodes { self: ICodes =>
|
||||
import global.{Symbol, NoSymbol, Type, Name, Constant};
|
||||
|
||||
/** This class represents an instruction of the intermediate code.
|
||||
|
@ -420,9 +420,9 @@ trait Opcodes requires ICodes {
|
|||
* Stack: ...
|
||||
* ->: ...
|
||||
*/
|
||||
case class JUMP(where: BasicBlock) extends Instruction {
|
||||
case class JUMP(whereto: BasicBlock) extends Instruction {
|
||||
/** Returns a string representation of this instruction */
|
||||
override def toString(): String ="JUMP "+where.label;
|
||||
override def toString(): String ="JUMP "+whereto.label;
|
||||
|
||||
override def consumed = 0;
|
||||
override def produced = 0;
|
||||
|
|
|
@ -9,7 +9,7 @@ package scala.tools.nsc.backend.icode;
|
|||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
trait Primitives requires ICodes {
|
||||
trait Primitives { self: ICodes =>
|
||||
|
||||
/** This class represents a primitive operation. */
|
||||
class Primitive {
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.io.PrintWriter;
|
|||
import scala.tools.nsc.util.Position;
|
||||
import scala.tools.nsc.symtab.Flags;
|
||||
|
||||
trait Printers requires ICodes {
|
||||
// val global: Global;
|
||||
trait Printers { self: ICodes =>
|
||||
// val global: Global;
|
||||
import global._;
|
||||
import global.icodes.opcodes._;
|
||||
import global.icodes._;
|
||||
|
|
|
@ -25,7 +25,7 @@ package scala.tools.nsc.backend.icode
|
|||
|
||||
import scala.collection.mutable.{Map, HashMap}
|
||||
|
||||
trait TypeKinds requires ICodes {
|
||||
trait TypeKinds { self: ICodes =>
|
||||
import global._
|
||||
|
||||
/** This class represents a type kind. Type kinds
|
||||
|
|
|
@ -12,7 +12,7 @@ package scala.tools.nsc.backend.icode
|
|||
* @author Iulian Dragos
|
||||
* @version 1.0
|
||||
*/
|
||||
trait TypeStacks requires ICodes {
|
||||
trait TypeStacks { self: ICodes =>
|
||||
import opcodes._
|
||||
import global.{Symbol, Type, definitions}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ abstract class CopyPropagation {
|
|||
|
||||
init {
|
||||
worklist += m.code.startBlock
|
||||
worklist ++= (m.exh map (.startBlock))
|
||||
worklist ++= (m.exh map (_.startBlock))
|
||||
m.code.blocks.foreach { b =>
|
||||
in(b) = lattice.bottom
|
||||
out(b) = lattice.bottom
|
||||
|
@ -340,7 +340,7 @@ abstract class CopyPropagation {
|
|||
case SWITCH(tags, labels) =>
|
||||
out.stack = out.stack.drop(1)
|
||||
|
||||
case JUMP(where) =>
|
||||
case JUMP(whereto) =>
|
||||
()
|
||||
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
|
@ -467,7 +467,7 @@ abstract class CopyPropagation {
|
|||
// this relies on having the same order in paramAccessors and
|
||||
// the arguments on the stack. It should be the same!
|
||||
for (val (p, i) <- paramAccessors.zipWithIndex) {
|
||||
// assert(p.tpe == ctor.tpe.paramTypes(i), "In: " + ctor.fullNameString + " having: " + (paramAccessors map (.tpe))+ " vs. " + ctor.tpe.paramTypes)
|
||||
// assert(p.tpe == ctor.tpe.paramTypes(i), "In: " + ctor.fullNameString + " having: " + (paramAccessors map (_.tpe))+ " vs. " + ctor.tpe.paramTypes)
|
||||
if (p.tpe == ctor.tpe.paramTypes(i))
|
||||
bindings += p -> values.head;
|
||||
values = values.tail;
|
||||
|
|
|
@ -121,7 +121,7 @@ abstract class TypeFlowAnalysis {
|
|||
|
||||
init {
|
||||
worklist += m.code.startBlock
|
||||
worklist ++= (m.exh map (.startBlock))
|
||||
worklist ++= (m.exh map (_.startBlock))
|
||||
m.code.blocks.foreach { b =>
|
||||
in(b) = typeFlowLattice.bottom
|
||||
out(b) = typeFlowLattice.bottom
|
||||
|
@ -289,7 +289,7 @@ abstract class TypeFlowAnalysis {
|
|||
case SWITCH(tags, labels) =>
|
||||
stack.pop
|
||||
|
||||
case JUMP(where) =>
|
||||
case JUMP(whereto) =>
|
||||
()
|
||||
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
|
|
|
@ -301,7 +301,7 @@ abstract class GenJVM extends SubComponent {
|
|||
}
|
||||
|
||||
def addAnnotations(jmember: JMember, attributes: List[AnnotationInfo]): Unit = {
|
||||
val toEmit = attributes.filter(.isConstant)
|
||||
val toEmit = attributes.filter(_.isConstant)
|
||||
|
||||
if (toEmit.isEmpty) return
|
||||
|
||||
|
@ -317,7 +317,7 @@ abstract class GenJVM extends SubComponent {
|
|||
for (attr @ AnnotationInfo(tpe, _, _) <- attrs;
|
||||
if attr.isConstant;
|
||||
if tpe.symbol isNonBottomSubClass definitions.ClassfileAnnotationClass) yield attr;
|
||||
if (attributes.forall(.isEmpty)) return;
|
||||
if (attributes.forall(_.isEmpty)) return;
|
||||
|
||||
val buf: ByteBuffer = ByteBuffer.allocate(2048)
|
||||
|
||||
|
@ -407,8 +407,8 @@ abstract class GenJVM extends SubComponent {
|
|||
jmethod = jclass.addNewMethod(flags,
|
||||
javaName(m.symbol),
|
||||
resTpe,
|
||||
javaTypes(m.params map (.kind)),
|
||||
javaNames(m.params map (.sym)));
|
||||
javaTypes(m.params map (_.kind)),
|
||||
javaNames(m.params map (_.sym)));
|
||||
|
||||
if (m.symbol.hasFlag(Flags.BRIDGE))
|
||||
jmethod.addAttribute(fjbgContext.JOtherAttribute(jclass, jmethod, "Bridge",
|
||||
|
@ -455,7 +455,7 @@ abstract class GenJVM extends SubComponent {
|
|||
|
||||
addExceptionsAttribute(m.symbol)
|
||||
addAnnotations(jmethod, m.symbol.attributes)
|
||||
addParamAnnotations(m.params.map(.sym.attributes))
|
||||
addParamAnnotations(m.params.map(_.sym.attributes))
|
||||
}
|
||||
|
||||
def isClosureApply(sym: Symbol): Boolean = {
|
||||
|
@ -850,9 +850,9 @@ abstract class GenJVM extends SubComponent {
|
|||
labels(branches.last),
|
||||
MIN_SWITCH_DENSITY);
|
||||
|
||||
case JUMP(where) =>
|
||||
if (nextBlock != where)
|
||||
jcode.emitGOTO_maybe_W(labels(where), false); // default to short jumps
|
||||
case JUMP(whereto) =>
|
||||
if (nextBlock != whereto)
|
||||
jcode.emitGOTO_maybe_W(labels(whereto), false); // default to short jumps
|
||||
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
kind match {
|
||||
|
|
|
@ -325,7 +325,7 @@ abstract class GenMSIL extends SubComponent {
|
|||
|
||||
val args: Array[Byte] =
|
||||
getAttributeArgs(
|
||||
annArgs map (.constant.get),
|
||||
annArgs map (_.constant.get),
|
||||
(for((n,v) <- nvPairs) yield (n, v.constant.get)))
|
||||
member.SetCustomAttribute(constr, args)
|
||||
}
|
||||
|
@ -715,7 +715,7 @@ abstract class GenMSIL extends SubComponent {
|
|||
cb.basicBlocks = bb :: cb.basicBlocks
|
||||
}
|
||||
override def close() {
|
||||
blocks.foreach(.close)
|
||||
blocks.foreach(_.close)
|
||||
blocks = blocks.reverse
|
||||
closed = true
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ abstract class GenMSIL extends SubComponent {
|
|||
}
|
||||
override def close() {
|
||||
tryBlock.close
|
||||
catchBlocks.foreach(.close)
|
||||
catchBlocks.foreach(_.close)
|
||||
catchBlocks = catchBlocks.reverse
|
||||
finallyBlock.close
|
||||
closed = true
|
||||
|
@ -920,8 +920,8 @@ abstract class GenMSIL extends SubComponent {
|
|||
|
||||
def replaceOutJumps(blocks: List[BasicBlock], leaving: List[(BasicBlock, List[BasicBlock])], exh: ExceptionHandler): (List[BasicBlock], Option[BasicBlock]) = {
|
||||
def replaceJump(block: BasicBlock, from: BasicBlock, to: BasicBlock) = block.lastInstruction match {
|
||||
case JUMP(where) =>
|
||||
//assert(from == where)
|
||||
case JUMP(whereto) =>
|
||||
//assert(from == whereto)
|
||||
block.replaceInstruction(block.lastInstruction, JUMP(to))
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
if (from == success)
|
||||
|
@ -1522,9 +1522,9 @@ abstract class GenMSIL extends SubComponent {
|
|||
mcode.Emit(OpCodes.Br, defaultTarget)
|
||||
|
||||
|
||||
case JUMP(where) =>
|
||||
if (nextBlock != where && !omitJumpBlocks.contains(currentBlock))
|
||||
mcode.Emit(OpCodes.Br, labels(where))
|
||||
case JUMP(whereto) =>
|
||||
if (nextBlock != whereto && !omitJumpBlocks.contains(currentBlock))
|
||||
mcode.Emit(OpCodes.Br, labels(whereto))
|
||||
|
||||
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
|
|
|
@ -260,7 +260,7 @@ abstract class DeadCodeElimination extends SubComponent {
|
|||
} else {
|
||||
val stack = rdef.in(bb)._2
|
||||
assert(stack.length >= m, "entry stack is too small, expected: " + m + " found: " + stack)
|
||||
stack.take(m) flatMap (.toList)
|
||||
stack.take(m) flatMap (_.toList)
|
||||
}
|
||||
|
||||
/** Is 'sym' a side-effecting method? TODO: proper analysis. */
|
||||
|
|
|
@ -76,7 +76,7 @@ abstract class Inliners extends SubComponent {
|
|||
val a = new analysis.MethodTFA(callee)
|
||||
|
||||
/* The exception handlers that are active at the current block. */
|
||||
val activeHandlers = caller.exh.filter(.covered.contains(block))
|
||||
val activeHandlers = caller.exh.filter(_.covered.contains(block))
|
||||
|
||||
/* Map 'original' blocks to the ones inlined in the caller. */
|
||||
val inlinedBlock: Map[BasicBlock, BasicBlock] = new HashMap
|
||||
|
@ -106,7 +106,7 @@ abstract class Inliners extends SubComponent {
|
|||
/** Add a new block in the current context. */
|
||||
def newBlock = {
|
||||
val b = caller.code.newBlock
|
||||
activeHandlers.foreach (.addCoveredBlock(b))
|
||||
activeHandlers.foreach (_.addCoveredBlock(b))
|
||||
if (retVal ne null) b.varsInScope += retVal
|
||||
b.varsInScope += inlinedThis
|
||||
b.varsInScope ++= varsInScope
|
||||
|
@ -147,8 +147,8 @@ abstract class Inliners extends SubComponent {
|
|||
case THIS(clasz) =>
|
||||
LOAD_LOCAL(inlinedThis);
|
||||
|
||||
case JUMP(where) =>
|
||||
JUMP(inlinedBlock(where));
|
||||
case JUMP(whereto) =>
|
||||
JUMP(inlinedBlock(whereto));
|
||||
|
||||
case CJUMP(success, failure, cond, kind) =>
|
||||
CJUMP(inlinedBlock(success), inlinedBlock(failure), cond, kind);
|
||||
|
@ -422,7 +422,7 @@ abstract class Inliners extends SubComponent {
|
|||
|
||||
if (stack.length > (1 + callee.symbol.info.paramTypes.length) &&
|
||||
callee.exh != Nil) {
|
||||
// (callee.exh exists (.covered.contains(callee.code.startBlock)))) {
|
||||
// (callee.exh exists (_.covered.contains(callee.code.startBlock)))) {
|
||||
if (settings.debug.value) log("method " + callee.symbol + " is used on a non-empty stack with finalizer.");
|
||||
false
|
||||
} else
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class DocDriver extends ModelFrames with ModelToXML {
|
|||
|
||||
def g(pkg: Package, clazz: ClassOrObject) {
|
||||
allClasses(pkg) += clazz;
|
||||
clazz.decls.map(._2).foreach {
|
||||
clazz.decls.map(_._2).foreach {
|
||||
case clazz : ClassOrObject => g(pkg, clazz)
|
||||
case _ =>
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ abstract class DocDriver extends ModelFrames with ModelToXML {
|
|||
object organized extends jcl.LinkedHashMap[(List[String],Boolean),List[ClassOrObject]] {
|
||||
override def default(key : (List[String],Boolean)) = Nil;
|
||||
classes.foreach(cls => {
|
||||
val path = cls.path.map(.name);
|
||||
val path = cls.path.map(_.name);
|
||||
this((path,cls.isInstanceOf[Clazz])) = cls :: this((path,cls.isInstanceOf[Clazz]));
|
||||
});
|
||||
}
|
||||
|
@ -81,8 +81,8 @@ abstract class DocDriver extends ModelFrames with ModelToXML {
|
|||
def navLabel = null; // "root-page"
|
||||
// override protected def navSuffix = ".html";
|
||||
override def optional(cls : ClassOrObject) : NodeSeq = {
|
||||
val path = cls.path.map(.name);
|
||||
val key = (cls.path.map(.name), cls.isInstanceOf[Clazz]);
|
||||
val path = cls.path.map(_.name);
|
||||
val key = (cls.path.map(_.name), cls.isInstanceOf[Clazz]);
|
||||
assert(!organized(key).isEmpty);
|
||||
(if (!organized(key).tail.isEmpty) Text(" (" +{
|
||||
//Console.println("CONFLICT: " + path + " " + organized(key));
|
||||
|
@ -157,7 +157,7 @@ abstract class DocDriver extends ModelFrames with ModelToXML {
|
|||
<dl>
|
||||
<dt style="margin:10px 0 0 20px;"><b>Direct Known Subclasses:</b></dt>
|
||||
<dd>{symbols.mkXML("",", ","")(cls => {
|
||||
aref(urlFor(cls.sym), cls.path.map(.name).mkString("",".",""));
|
||||
aref(urlFor(cls.sym), cls.path.map(_.name).mkString("",".",""));
|
||||
})}</dd>
|
||||
</dl><hr/>;
|
||||
case None =>
|
||||
|
|
|
@ -208,7 +208,7 @@ trait ModelExtractor {
|
|||
|
||||
trait ClassOrObject extends Entity {
|
||||
def path : List[ClassOrObject] = this :: Nil;
|
||||
override def listName = path.map(.name).mkString("",".","");
|
||||
override def listName = path.map(_.name).mkString("",".","");
|
||||
|
||||
object freshParents extends jcl.LinkedHashSet[Type] {
|
||||
this addAll sym.tpe.parents;
|
||||
|
@ -286,7 +286,7 @@ trait ModelExtractor {
|
|||
override def typeParams = sym.tpe.typeParams.map(TypeParam);
|
||||
override def params = methodArgumentNames.get(sym) match {
|
||||
case Some(argss) if argss.length > 1 || (!argss.isEmpty && !argss(0).isEmpty) =>
|
||||
argss.map(.map(Param));
|
||||
argss.map(_.map(Param));
|
||||
case _ =>
|
||||
var i = 0
|
||||
val ret = for (tpe <- sym.tpe.paramTypes) yield {
|
||||
|
@ -371,8 +371,8 @@ trait ModelExtractor {
|
|||
val Constructors = new Category("Additional Constructor")(e => e.isConstructor && !e.isPrimaryConstructor) {
|
||||
// override def plural = "Additional Constructors";
|
||||
}
|
||||
val Objects = Category("Object")(.isModule);
|
||||
val Classes = new Category("Class")(.isClass) {
|
||||
val Objects = Category("Object")(_.isModule);
|
||||
val Classes = new Category("Class")(_.isClass) {
|
||||
override def plural = "Classes";
|
||||
}
|
||||
val Values = new Category("Value")(e => (e.isValue) && e.hasFlag(symtab.Flags.ACCESSOR)) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class PlainFile(val file: File) extends AbstractFile {
|
|||
val names: Array[String] = file.list()
|
||||
if ((names eq null) || names.length == 0) Iterator.empty
|
||||
else Iterator.fromArray(names).map { name: String => new File(file, name) }
|
||||
.filter(.exists()).map(file => new PlainFile(file))
|
||||
.filter(_.exists).map(file => new PlainFile(file))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@ package scala.tools.nsc.matching
|
|||
|
||||
import scala.tools.nsc.util.Position
|
||||
|
||||
trait CodeFactory requires transform.ExplicitOuter {
|
||||
trait CodeFactory { self: transform.ExplicitOuter =>
|
||||
|
||||
import global._
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ trait ParallelMatching {
|
|||
|
||||
val isExhaustive = !scrutinee.tpe.symbol.hasFlag(symtab.Flags.SEALED) || {
|
||||
//DEBUG("check exha for column "+column)
|
||||
val tpes = column.map (.tpe.symbol)
|
||||
val tpes = column.map (_.tpe.symbol)
|
||||
scrutinee.tpe.symbol.children.forall { sym => tpes.contains(sym) }
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ trait ParallelMatching {
|
|||
// this weird thing should only be done for shared states.
|
||||
var nbody: Tree = b
|
||||
val vrefs = vdefs.map { p:ValDef => Ident(p.symbol) }
|
||||
nbody = Block(vdefs:::List(Apply(Ident(theLabel), vrefs)), LabelDef(theLabel, subst.map(._1), nbody))
|
||||
nbody = Block(vdefs:::List(Apply(Ident(theLabel), vrefs)), LabelDef(theLabel, subst.map(_._1), nbody))
|
||||
bodies(b) = (EmptyTree, nbody, theLabel)
|
||||
nbody
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import scala.tools.nsc.util.{Position, NoPosition}
|
|||
* @author Burak Emir
|
||||
* @version 1.0
|
||||
*/
|
||||
trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes with ParallelMatching) {
|
||||
trait PatternMatchers { self: transform.ExplicitOuter with PatternNodes with ParallelMatching =>
|
||||
import global._
|
||||
import typer.typed
|
||||
import symtab.Flags
|
||||
|
|
|
@ -9,7 +9,7 @@ package scala.tools.nsc.matching
|
|||
import compat.StringBuilder
|
||||
import scala.tools.nsc.util.{Position, NoPosition}
|
||||
|
||||
trait PatternNodes requires transform.ExplicitOuter {
|
||||
trait PatternNodes { self: transform.ExplicitOuter =>
|
||||
|
||||
import global._
|
||||
|
||||
|
|
|
@ -10,10 +10,7 @@ package scala.tools.nsc.matching
|
|||
*
|
||||
* @author Burak Emir
|
||||
*/
|
||||
trait TransMatcher requires transform.ExplicitOuter /*extends transform.Transform
|
||||
with PatternNodes
|
||||
with CodeFactory
|
||||
with PatternMatchers */ {
|
||||
trait TransMatcher { self: transform.ExplicitOuter =>
|
||||
|
||||
import global._
|
||||
import definitions._
|
||||
|
|
|
@ -59,11 +59,11 @@ trait AnnotationInfos {
|
|||
|
||||
val mems = trees.map(refltree2cons)
|
||||
|
||||
if(mems.exists(.isEmpty))
|
||||
if(mems.exists(_.isEmpty))
|
||||
None
|
||||
else
|
||||
Some(new ArrayConstant(
|
||||
mems.map(.get).toArray,
|
||||
mems.map(_.get).toArray,
|
||||
symbolReifier.unreify(arrayType)))
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ trait AnnotationInfos {
|
|||
|
||||
/** Check whether all arguments and assocations are constants */
|
||||
def isConstant =
|
||||
((args forall (.isConstant)) &&
|
||||
(assocs map (._2) forall (.isConstant)))
|
||||
((args forall (_.isConstant)) &&
|
||||
(assocs map (_._2) forall (_.isConstant)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ trait Definitions {
|
|||
|
||||
var AllRefClass: Symbol = _
|
||||
var AllClass: Symbol = _
|
||||
var SingletonClass: Symbol = _
|
||||
|
||||
var ClassClass: Symbol = _
|
||||
var StringClass: Symbol = _
|
||||
|
@ -392,7 +393,7 @@ trait Definitions {
|
|||
j = fullname.pos('.', i)
|
||||
}
|
||||
val result =
|
||||
if (module) sym.info.member(fullname.subName(i, j)).suchThat(.hasFlag(MODULE))
|
||||
if (module) sym.info.member(fullname.subName(i, j)).suchThat(_ hasFlag MODULE)
|
||||
else sym.info.member(fullname.subName(i, j).toTypeName)
|
||||
if (result == NoSymbol) {
|
||||
if (settings.debug.value)
|
||||
|
@ -751,6 +752,9 @@ trait Definitions {
|
|||
AllClass = newClass(ScalaPackageClass, nme.Nothing, anyparam)
|
||||
.setFlag(ABSTRACT | TRAIT | FINAL)
|
||||
|
||||
SingletonClass = newClass(RootClass, "<singleton>", anyparam)
|
||||
.setFlag(ABSTRACT | TRAIT | FINAL)
|
||||
|
||||
StringClass = getClass(if (forMSIL) "System.String" else "java.lang.String")
|
||||
|
||||
ClassClass = getClass(if (forMSIL) "System.Type" else "java.lang.Class")
|
||||
|
|
|
@ -266,7 +266,7 @@ trait Scopes {
|
|||
if (!(toList forall p)) newScope(toList filter p) else this
|
||||
|
||||
def mkString(start: String, sep: String, end: String) =
|
||||
toList.map(.defString).mkString(start, sep, end)
|
||||
toList.map(_.defString).mkString(start, sep, end)
|
||||
|
||||
override def toString(): String = mkString("{\n ", ";\n ", "\n}")
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ trait StdNames {
|
|||
val FINALkw = newTermName("final")
|
||||
val FINALLYkw = newTermName("finally")
|
||||
val FORkw = newTermName("for")
|
||||
val FORSOMEkw = newTermName("for_some")
|
||||
val IFkw = newTermName("if")
|
||||
val IMPLICITkw = newTermName("implicit")
|
||||
val IMPORTkw = newTermName("import")
|
||||
|
|
|
@ -555,7 +555,7 @@ trait Symbols {
|
|||
if (isMonomorphicType) List() else { rawInfo.load(this); rawInfo.typeParams }
|
||||
|
||||
def getAttributes(clazz: Symbol): List[AnnotationInfo] =
|
||||
attributes.filter(.atp.symbol.isNonBottomSubClass(clazz))
|
||||
attributes.filter(_.atp.symbol.isNonBottomSubClass(clazz))
|
||||
|
||||
/** Reset symbol to initial state
|
||||
*/
|
||||
|
@ -841,12 +841,12 @@ trait Symbols {
|
|||
*/
|
||||
final def getter(base: Symbol): Symbol = {
|
||||
val getterName = if (isSetter) nme.setterToGetter(name) else nme.getterName(name)
|
||||
base.info.decl(getterName) filter (.hasFlag(ACCESSOR))
|
||||
base.info.decl(getterName) filter (_.hasFlag(ACCESSOR))
|
||||
}
|
||||
|
||||
/** The setter of this value or getter definition, or NoSymbol if none exists */
|
||||
final def setter(base: Symbol): Symbol =
|
||||
base.info.decl(nme.getterToSetter(nme.getterName(name))) filter (.hasFlag(ACCESSOR))
|
||||
base.info.decl(nme.getterToSetter(nme.getterName(name))) filter (_.hasFlag(ACCESSOR))
|
||||
|
||||
/** The case factory corresponding to this case class
|
||||
* @pre case class is a member of some other class or package
|
||||
|
@ -855,7 +855,7 @@ trait Symbols {
|
|||
var facname = name.toTermName
|
||||
if (privateWithin.isClass && !privateWithin.isModuleClass && !hasFlag(EXPANDEDNAME))
|
||||
facname = privateWithin.expandedName(facname)
|
||||
initialize.owner.info.decl(facname).suchThat(.isCaseFactory)
|
||||
initialize.owner.info.decl(facname).suchThat(_.isCaseFactory)
|
||||
}
|
||||
|
||||
/** If this symbol is a skolem, its corresponding type parameter, otherwise this */
|
||||
|
@ -1008,7 +1008,7 @@ trait Symbols {
|
|||
final def infoString(tp: Type): String = {
|
||||
def typeParamsString: String = tp match {
|
||||
case PolyType(tparams, _) if (tparams.length != 0) =>
|
||||
(tparams map (.defString)).mkString("[", ",", "]")
|
||||
(tparams map (_.defString)).mkString("[", ",", "]")
|
||||
case _ =>
|
||||
""
|
||||
}
|
||||
|
@ -1164,7 +1164,7 @@ trait Symbols {
|
|||
if (isInitialized) tpePeriod = currentPeriod
|
||||
tpeCache = NoType
|
||||
val targs = if (phase.erasedTypes && this != ArrayClass) List()
|
||||
else unsafeTypeParams map (.typeConstructor) //@M! use typeConstructor to generate dummy type arguments,
|
||||
else unsafeTypeParams map (_.typeConstructor) //@M! use typeConstructor to generate dummy type arguments,
|
||||
// sym.tpe should not be called on a symbol that's supposed to be a higher-kinded type
|
||||
// memberType should be used instead, that's why it uses tpeHK and not tpe
|
||||
tpeCache = typeRef(if (isTypeParameterOrSkolem) NoPrefix else owner.thisType, this, targs)
|
||||
|
@ -1353,13 +1353,13 @@ trait Symbols {
|
|||
|
||||
|
||||
def cloneSymbols(syms: List[Symbol]): List[Symbol] = {
|
||||
val syms1 = syms map (.cloneSymbol)
|
||||
val syms1 = syms map (_.cloneSymbol)
|
||||
for (sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
|
||||
syms1
|
||||
}
|
||||
|
||||
def cloneSymbols(syms: List[Symbol], owner: Symbol): List[Symbol] = {
|
||||
val syms1 = syms map (.cloneSymbol(owner))
|
||||
val syms1 = syms map (_.cloneSymbol(owner))
|
||||
for (sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
|
||||
syms1
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -209,13 +209,13 @@ abstract class ClassfileParser {
|
|||
} else {
|
||||
val owner = if (static) ownerTpe.symbol.linkedClassOfClass else ownerTpe.symbol
|
||||
// println("\t" + owner.info.member(name).tpe.widen + " =:= " + tpe)
|
||||
f = owner.info.member(name).suchThat(.tpe.widen.=:=(tpe))
|
||||
f = owner.info.member(name).suchThat(_.tpe.widen =:= tpe)
|
||||
if (f == NoSymbol)
|
||||
f = owner.info.member(newTermName(name.toString + nme.LOCAL_SUFFIX)).suchThat(.tpe.=:=(tpe))
|
||||
f = owner.info.member(newTermName(name.toString + nme.LOCAL_SUFFIX)).suchThat(_.tpe =:= tpe)
|
||||
if (f == NoSymbol) {
|
||||
// if it's an impl class, try to find it's static member inside the class
|
||||
assert(ownerTpe.symbol.isImplClass, "Not an implementation class: " + owner + " couldn't find " + name + ": " + tpe + " inside: \n" + ownerTpe.members);
|
||||
f = ownerTpe.member(name).suchThat(.tpe.=:=(tpe))
|
||||
f = ownerTpe.member(name).suchThat(_.tpe =:= tpe)
|
||||
// println("\townerTpe.decls: " + ownerTpe.decls)
|
||||
// println("Looking for: " + name + ": " + tpe + " inside: " + ownerTpe.symbol + "\n\tand found: " + ownerTpe.members)
|
||||
}
|
||||
|
|
|
@ -196,6 +196,7 @@ object PickleFormat {
|
|||
final val LABELSYMBOLrsym = 9
|
||||
|
||||
final val DEBRUIJNINDEXtpe = 47
|
||||
final val EXISTENTIALtpe = 48
|
||||
|
||||
final val firstSymTag = NONEsym
|
||||
final val lastSymTag = VALsym
|
||||
|
|
|
@ -109,7 +109,7 @@ abstract class Pickler extends SubComponent {
|
|||
putType(sym.typeOfThis);
|
||||
putSymbol(sym.alias)
|
||||
if (!sym.children.isEmpty) {
|
||||
val (locals, globals) = sym.children.toList.partition(.isLocalClass)
|
||||
val (locals, globals) = sym.children.toList.partition(_.isLocalClass)
|
||||
val children =
|
||||
if (locals.isEmpty) globals
|
||||
else {
|
||||
|
@ -158,6 +158,8 @@ abstract class Pickler extends SubComponent {
|
|||
putType(restpe); putTypes(formals)
|
||||
case PolyType(tparams, restpe) =>
|
||||
putType(restpe); putSymbols(tparams)
|
||||
case ExistentialType(tparams, restpe) =>
|
||||
putType(restpe); putSymbols(tparams)
|
||||
case AnnotatedType(attribs, tp) =>
|
||||
putType(tp); putAnnotations(attribs)
|
||||
case _ =>
|
||||
|
@ -389,6 +391,8 @@ abstract class Pickler extends SubComponent {
|
|||
else METHODtpe
|
||||
case PolyType(tparams, restpe) =>
|
||||
writeRef(restpe); writeRefs(tparams); POLYtpe
|
||||
case ExistentialType(tparams, restpe) =>
|
||||
writeRef(restpe); writeRefs(tparams); EXISTENTIALtpe
|
||||
case DeBruijnIndex(l, i) =>
|
||||
writeNat(l); writeNat(i); DEBRUIJNINDEXtpe
|
||||
case c @ Constant(_) =>
|
||||
|
|
|
@ -254,6 +254,9 @@ abstract class UnPickler {
|
|||
case POLYtpe =>
|
||||
val restpe = readTypeRef()
|
||||
PolyType(until(end, readSymbolRef), restpe)
|
||||
case EXISTENTIALtpe =>
|
||||
val restpe = readTypeRef()
|
||||
ExistentialType(until(end, readSymbolRef), restpe)
|
||||
case ANNOTATEDtpe =>
|
||||
val tp = readTypeRef()
|
||||
val attribs = until(end, readTreeAttribRef)
|
||||
|
|
|
@ -199,7 +199,7 @@ abstract class TypeParser {
|
|||
|| adder.IsFamilyAndAssembly))
|
||||
{
|
||||
assert(adder.ReturnType == clrTypes.VOID);
|
||||
assert(adder.GetParameters().map(.ParameterType).toList == List(event.EventHandlerType));
|
||||
assert(adder.GetParameters().map(_.ParameterType).toList == List(event.EventHandlerType));
|
||||
val name = encode("+=");
|
||||
val flags = translateAttributes(adder);
|
||||
val mtype: Type = methodType(adder, adder.ReturnType);
|
||||
|
@ -210,7 +210,7 @@ abstract class TypeParser {
|
|||
|| remover.IsFamilyAndAssembly))
|
||||
{
|
||||
assert(remover.ReturnType == clrTypes.VOID);
|
||||
assert(remover.GetParameters().map(.ParameterType).toList == List(event.EventHandlerType));
|
||||
assert(remover.GetParameters().map(_.ParameterType).toList == List(event.EventHandlerType));
|
||||
val name = encode("-=");
|
||||
val flags = translateAttributes(remover);
|
||||
val mtype: Type = methodType(remover, remover.ReturnType);
|
||||
|
@ -301,7 +301,7 @@ abstract class TypeParser {
|
|||
private def createDelegateView(typ: MSILType) = {
|
||||
val invoke: MethodInfo = typ.GetMember("Invoke")(0).asInstanceOf[MethodInfo];
|
||||
val invokeRetType: Type = getCLRType(invoke.ReturnType);
|
||||
val invokeParamTypes: List[Type] =invoke.GetParameters().map(.ParameterType).map(getCLSType).toList;
|
||||
val invokeParamTypes: List[Type] =invoke.GetParameters().map(_.ParameterType).map(getCLSType).toList;
|
||||
val funType: Type = definitions.functionType(invokeParamTypes, invokeRetType);
|
||||
|
||||
val typClrType: Type = getCLRType(typ);
|
||||
|
@ -355,7 +355,7 @@ abstract class TypeParser {
|
|||
|
||||
/** Return a method type for the given method. */
|
||||
private def methodType(method: MethodBase, rettype: Type): Type =
|
||||
methodType(method.GetParameters().map(.ParameterType), rettype);
|
||||
methodType(method.GetParameters().map(_.ParameterType), rettype);
|
||||
|
||||
/** Return a method type for the provided argument types and return type. */
|
||||
private def methodType(argtypes: Array[MSILType], rettype: Type): Type = {
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract class Constructors extends Transform {
|
|||
case ddef @ DefDef(_, _, _, List(vparams), _, rhs @ Block(_, Literal(_))) =>
|
||||
if (ddef.symbol.isPrimaryConstructor) {
|
||||
constr = ddef
|
||||
constrParams = vparams map (.symbol)
|
||||
constrParams = vparams map (_.symbol)
|
||||
constrBody = rhs
|
||||
}
|
||||
case _ =>
|
||||
|
|
|
@ -58,7 +58,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
* </ul>
|
||||
*/
|
||||
val erasure = new TypeMap {
|
||||
def apply(tp: Type): Type = { //val tp = tp0.normalize MARTIN: I don't think this is needed?
|
||||
def apply(tp: Type): Type = {
|
||||
tp match {
|
||||
case ConstantType(_) =>
|
||||
tp
|
||||
|
@ -77,6 +77,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
else apply(sym.info)
|
||||
case PolyType(tparams, restpe) =>
|
||||
apply(restpe)
|
||||
case ExistentialType(tparams, restpe) =>
|
||||
apply(restpe)
|
||||
case MethodType(formals, restpe) =>
|
||||
MethodType(
|
||||
formals map apply,
|
||||
|
@ -108,7 +110,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
private def removeDoubleObject(tps: List[Type]): List[Type] = tps match {
|
||||
case List() => List()
|
||||
case tp :: tps1 =>
|
||||
if (tp.symbol == ObjectClass) tp :: tps1.filter(.symbol.!=(ObjectClass))
|
||||
if (tp.symbol == ObjectClass) tp :: tps1.filter(_.symbol != ObjectClass)
|
||||
else tp :: removeDoubleObject(tps1)
|
||||
}
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ abstract class LambdaLift extends InfoTransform {
|
|||
tree match {
|
||||
case DefDef(mods, name, tparams, List(vparams), tpt, rhs) =>
|
||||
sym.updateInfo(
|
||||
lifted(MethodType(sym.info.paramTypes ::: (ps map (.tpe)), sym.info.resultType)));
|
||||
lifted(MethodType(sym.info.paramTypes ::: (ps map (_.tpe)), sym.info.resultType)));
|
||||
copy.DefDef(tree, mods, name, tparams, List(vparams ::: freeParams), tpt, rhs)
|
||||
case ClassDef(mods, name, tparams, impl @ Template(parents, self, body)) =>
|
||||
copy.ClassDef(tree, mods, name, tparams,
|
||||
|
|
|
@ -56,7 +56,7 @@ abstract class LiftCode extends Transform {
|
|||
case Some(tgt) => tgt
|
||||
}
|
||||
def hasAllTargets: Boolean =
|
||||
targets.elements.map(._2).forall {
|
||||
targets.elements.map(_._2).forall {
|
||||
case Some(_) => true
|
||||
case None => false
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ abstract class LiftCode extends Transform {
|
|||
reflect.Apply(reify(fun), args map reify)
|
||||
|
||||
case TypeApply(fun, args) =>
|
||||
reflect.TypeApply(reify(fun), args map (.tpe) map reify)
|
||||
reflect.TypeApply(reify(fun), args map (_.tpe) map reify)
|
||||
|
||||
case Function(vparams, body) =>
|
||||
var env1 = env
|
||||
|
@ -109,7 +109,7 @@ abstract class LiftCode extends Transform {
|
|||
currentOwner, vparam.symbol.name.toString(), reify(vparam.symbol.tpe));
|
||||
env1.update(vparam.symbol, local);
|
||||
}
|
||||
reflect.Function(vparams map (.symbol) map env1,
|
||||
reflect.Function(vparams map (_.symbol) map env1,
|
||||
new Reifier(env1, currentOwner).reify(body))
|
||||
case This(_) =>
|
||||
reflect.This(reify(tree.symbol))
|
||||
|
|
|
@ -452,7 +452,7 @@ abstract class Mixin extends InfoTransform {
|
|||
* <code>newDefs</code>.
|
||||
*/
|
||||
def add(stats: List[Tree], newDefs: List[Tree]) = {
|
||||
val newSyms = newDefs map (.symbol)
|
||||
val newSyms = newDefs map (_.symbol)
|
||||
def isNotDuplicate(tree: Tree) = tree match {
|
||||
case DefDef(_, _, _, _, _, _) =>
|
||||
val sym = tree.symbol;
|
||||
|
|
|
@ -84,6 +84,7 @@ trait SymbolReifier {
|
|||
tparams.map(reify),
|
||||
boundss,
|
||||
reify(result))
|
||||
//todo: treat ExistentialType
|
||||
case AnnotatedType(attribs, tp) =>
|
||||
reify(tp)
|
||||
case _ =>
|
||||
|
@ -141,6 +142,7 @@ trait SymbolReifier {
|
|||
MethodType(formals.map(unreify), unreify(restpe))
|
||||
case reflect.PolyType(typeParams, typeBounds, resultType) =>
|
||||
PolyType(typeParams.map(unreify), unreify(resultType))
|
||||
//todo: treat ExistentialType
|
||||
case _ => NoType
|
||||
}
|
||||
|
||||
|
|
|
@ -159,9 +159,9 @@ abstract class TailCalls extends Transform
|
|||
log(" Considering " + name + " for tailcalls")
|
||||
tree.symbol.tpe match {
|
||||
case PolyType(tpes, restpe) =>
|
||||
newCtx.tparams = tparams map (.symbol)
|
||||
newCtx.tparams = tparams map (_.symbol)
|
||||
newCtx.label.setInfo(
|
||||
restpe.substSym(tpes, tparams map (.symbol)))
|
||||
restpe.substSym(tpes, tparams map (_.symbol)))
|
||||
case _ => ()
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ abstract class TailCalls extends Transform
|
|||
newRHS =
|
||||
typed(atPos(tree.pos)(
|
||||
LabelDef(newCtx.label,
|
||||
List.flatten(vparams) map (.symbol),
|
||||
List.flatten(vparams) map (_.symbol),
|
||||
newRHS)));
|
||||
copy.DefDef(tree, mods, name, tparams, vparams, tpt, newRHS);
|
||||
} else
|
||||
|
@ -239,7 +239,7 @@ abstract class TailCalls extends Transform
|
|||
case Apply(tapply @ TypeApply(fun, targs), vargs) =>
|
||||
if ( ctx.currentMethod.isFinal &&
|
||||
ctx.tailPos &&
|
||||
isSameTypes(ctx.tparams, targs map (.tpe.symbol)) &&
|
||||
isSameTypes(ctx.tparams, targs map (_.tpe.symbol)) &&
|
||||
isRecursiveCall(fun))
|
||||
rewriteTailCall(fun, transformTrees(vargs, mkContext(ctx, false)))
|
||||
else
|
||||
|
|
|
@ -381,13 +381,13 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
|
|||
case Apply(Select(Block(List(), Function(vparams, body)), nme.apply), args) =>
|
||||
// perform beta-reduction; this helps keep view applications small
|
||||
withNeedLift(true) {
|
||||
mainTransform(new TreeSubstituter(vparams map (.symbol), args).transform(body))
|
||||
mainTransform(new TreeSubstituter(vparams map (_.symbol), args).transform(body))
|
||||
}
|
||||
|
||||
case Apply(Select(Function(vparams, body), nme.apply), args) =>
|
||||
// perform beta-reduction; this helps keep view applications small
|
||||
withNeedLift(true) {
|
||||
mainTransform(new TreeSubstituter(vparams map (.symbol), args).transform(body))
|
||||
mainTransform(new TreeSubstituter(vparams map (_.symbol), args).transform(body))
|
||||
}
|
||||
|
||||
case UnApply(fn, args) =>
|
||||
|
|
|
@ -14,7 +14,7 @@ import scala.tools.nsc.util.{Position,NoPosition}
|
|||
* @author Martin Odersky
|
||||
* @version 1.0
|
||||
*/
|
||||
trait Contexts requires Analyzer {
|
||||
trait Contexts { self: Analyzer =>
|
||||
import global._
|
||||
|
||||
val NoContext = new Context {
|
||||
|
@ -470,7 +470,7 @@ trait Contexts requires Analyzer {
|
|||
|
||||
/** Is name imported explicitly, not via wildcard? */
|
||||
def isExplicitImport(name: Name): boolean =
|
||||
tree.selectors exists (._2.==(name.toTermName))
|
||||
tree.selectors exists (_._2 == name.toTermName)
|
||||
|
||||
/** The symbol with name <code>name</code> imported from import clause
|
||||
* <code>tree</code>.
|
||||
|
|
|
@ -14,7 +14,7 @@ import symtab.Flags._
|
|||
* @author Martin Odersky
|
||||
* @version 1.0
|
||||
*/
|
||||
trait EtaExpansion requires Analyzer {
|
||||
trait EtaExpansion { self: Analyzer =>
|
||||
|
||||
import global._
|
||||
import posAssigner.atPos
|
||||
|
|
|
@ -124,20 +124,6 @@ trait Infer {
|
|||
}
|
||||
}
|
||||
|
||||
/** Do type arguments <code>targs</code> conform to formal parameters
|
||||
* <code>tparams</code>?
|
||||
*
|
||||
* @param tparams ...
|
||||
* @param targs ...
|
||||
* @return ...
|
||||
*/
|
||||
private def isWithinBounds(pre: Type, owner: Symbol, tparams: List[Symbol], targs: List[Type]): boolean = {
|
||||
val bounds = tparams map { tparam =>
|
||||
tparam.info.asSeenFrom(pre, owner).instantiateTypeParams(tparams, targs).bounds
|
||||
}
|
||||
!(List.map2(bounds, targs)((bound, targ) => bound containsType targ) contains false)
|
||||
}
|
||||
|
||||
/** Solve constraint collected in types <code>tvars</code>.
|
||||
*
|
||||
* @param tvars All type variables to be instantiated.
|
||||
|
@ -147,55 +133,10 @@ trait Infer {
|
|||
* @param upper When <code>true</code> search for max solution else min.
|
||||
* @throws NoInstance
|
||||
*/
|
||||
private def solve(tvars: List[TypeVar], tparams: List[Symbol],
|
||||
variances: List[int], upper: boolean): List[Type] = {
|
||||
val config = tvars zip (tparams zip variances)
|
||||
|
||||
def solveOne(tvar: TypeVar, tparam: Symbol, variance: int): unit = {
|
||||
if (tvar.constr.inst == NoType) {
|
||||
val up = if (variance != CONTRAVARIANT) upper else !upper
|
||||
tvar.constr.inst = null
|
||||
val bound: Type = if (up) tparam.info.bounds.hi else tparam.info.bounds.lo
|
||||
// Console.println("solveOne0 "+tvar+" "+config+" "+bound);//DEBUG
|
||||
var cyclic = bound contains tparam
|
||||
for ((tvar2, (tparam2, variance2)) <- config) {
|
||||
if (tparam2 != tparam &&
|
||||
((bound contains tparam2) ||
|
||||
up && (tparam2.info.bounds.lo =:= tparam.tpe) || //@M TODO: might be affected by change to tpe in Symbol
|
||||
!up && (tparam2.info.bounds.hi =:= tparam.tpe))) { //@M TODO: might be affected by change to tpe in Symbol
|
||||
if (tvar2.constr.inst eq null) cyclic = true
|
||||
solveOne(tvar2, tparam2, variance2)
|
||||
}
|
||||
}
|
||||
if (!cyclic) {
|
||||
if (up) {
|
||||
if (bound.symbol != AnyClass) {
|
||||
tvar.constr.hibounds =
|
||||
bound.instantiateTypeParams(tparams, tvars) :: tvar.constr.hibounds
|
||||
}
|
||||
for (tparam2 <- tparams)
|
||||
if (tparam2.info.bounds.lo =:= tparam.tpe) //@M TODO: might be affected by change to tpe in Symbol
|
||||
tvar.constr.hibounds =
|
||||
tparam2.tpe.instantiateTypeParams(tparams, tvars) :: tvar.constr.hibounds
|
||||
} else {
|
||||
if (bound.symbol != AllClass && bound.symbol != tparam) {
|
||||
tvar.constr.lobounds =
|
||||
bound.instantiateTypeParams(tparams, tvars) :: tvar.constr.lobounds
|
||||
}
|
||||
for (tparam2 <- tparams)
|
||||
if (tparam2.info.bounds.hi =:= tparam.tpe) //@M TODO: might be affected by change to tpe in Symbol
|
||||
tvar.constr.lobounds =
|
||||
tparam2.tpe.instantiateTypeParams(tparams, tvars) :: tvar.constr.lobounds
|
||||
}
|
||||
}
|
||||
tvar.constr.inst = NoType // necessary because hibounds/lobounds may contain tvar
|
||||
//Console.println("solving "+tvar+" "+up+" "+(if (up) (tvar.constr.hibounds) else tvar.constr.lobounds))//DEBUG
|
||||
tvar.constr.inst = if (up) glb(tvar.constr.hibounds) else lub(tvar.constr.lobounds)
|
||||
assertNonCyclic(tvar)//debug
|
||||
}
|
||||
}
|
||||
for ((tvar, (tparam, variance)) <- config)
|
||||
solveOne(tvar, tparam, variance)
|
||||
private def solvedTypes(tvars: List[TypeVar], tparams: List[Symbol],
|
||||
variances: List[int], upper: boolean): List[Type] = {
|
||||
solve(tvars, tparams, variances, upper)
|
||||
for (val tvar <- tvars) assert(tvar.constr.inst != tvar, tvar.origin)
|
||||
tvars map instantiate
|
||||
}
|
||||
|
||||
|
@ -445,7 +386,7 @@ trait Infer {
|
|||
val tvars = tparams map freshVar
|
||||
if (isCompatible(restpe.instantiateTypeParams(tparams, tvars), pt)) {
|
||||
try {
|
||||
solve(tvars, tparams, tparams map varianceInType(restpe), false)
|
||||
solvedTypes(tvars, tparams, tparams map varianceInType(restpe), false)
|
||||
} catch {
|
||||
case ex: NoInstance => null
|
||||
}
|
||||
|
@ -550,7 +491,7 @@ trait Infer {
|
|||
}
|
||||
()
|
||||
}
|
||||
val targs = solve(tvars, tparams, tparams map varianceInTypes(formals), false)
|
||||
val targs = solvedTypes(tvars, tparams, tparams map varianceInTypes(formals), false)
|
||||
List.map2(tparams, targs) {(tparam, targ) =>
|
||||
if (targ.symbol == AllClass && (varianceInType(restpe)(tparam) & COVARIANT) == 0) {
|
||||
uninstantiated += tparam
|
||||
|
@ -657,11 +598,11 @@ trait Infer {
|
|||
" do not conform to the expected kinds of the type parameters "+ tparams.mkString("(", ",", ")") + tparams.head.locationString+ "." +
|
||||
kindErrors.toList.mkString("\n", ", ", ""))
|
||||
else if (!isWithinBounds(pre, owner, tparams, targs)) {
|
||||
if (!(targs exists (.isErroneous)) && !(tparams exists (.isErroneous))) {
|
||||
if (!(targs exists (_.isErroneous)) && !(tparams exists (_.isErroneous))) {
|
||||
error(pos,
|
||||
prefix + "type arguments " + targs.mkString("[", ",", "]") +
|
||||
" do not conform to " + tparams.head.owner + "'s type parameter bounds " +
|
||||
(tparams map (.defString)).mkString("[", ",", "]"))
|
||||
(tparams map (_.defString)).mkString("[", ",", "]"))
|
||||
}
|
||||
if (settings.explaintypes.value) {
|
||||
val bounds = tparams map (tp => tp.info.instantiateTypeParams(tparams, targs).bounds)
|
||||
|
@ -816,7 +757,7 @@ trait Infer {
|
|||
case MethodType(formals0, _) =>
|
||||
try {
|
||||
val formals = formalTypes(formals0, args.length)
|
||||
val argtpes = actualTypes(args map (.tpe.deconst), formals.length)
|
||||
val argtpes = actualTypes(args map (_.tpe.deconst), formals.length)
|
||||
val restpe = fn.tpe.resultType(argtpes)
|
||||
val uninstantiated = new ListBuffer[Symbol]
|
||||
val targs = methTypeArgs(undetparams, formals, restpe, argtpes, pt, uninstantiated)
|
||||
|
@ -833,7 +774,7 @@ trait Infer {
|
|||
"no type parameters for " +
|
||||
applyErrorMsg(
|
||||
fn, " exist so that it can be applied to arguments ",
|
||||
args map (.tpe.widen), WildcardType) +
|
||||
args map (_.tpe.widen), WildcardType) +
|
||||
"\n --- because ---\n" + ex.getMessage())
|
||||
List()
|
||||
}
|
||||
|
@ -891,7 +832,7 @@ trait Infer {
|
|||
*/
|
||||
def computeArgs =
|
||||
try {
|
||||
val targs = solve(tvars, undetparams, undetparams map varianceInType(restpe), true)
|
||||
val targs = solvedTypes(tvars, undetparams, undetparams map varianceInType(restpe), true)
|
||||
checkBounds(tree.pos, NoPrefix, NoSymbol, undetparams, targs, "inferred ")
|
||||
new TreeTypeSubstituter(undetparams, targs).traverse(tree)
|
||||
} catch {
|
||||
|
@ -933,7 +874,7 @@ trait Infer {
|
|||
tvar.constr.inst != NoType &&
|
||||
isFullyDefined(tvar.constr.inst) &&
|
||||
(tparam.info.bounds containsType tvar.constr.inst)) {
|
||||
context.nextEnclosing(.tree.isInstanceOf[CaseDef]).pushTypeBounds(tparam)
|
||||
context.nextEnclosing(_.tree.isInstanceOf[CaseDef]).pushTypeBounds(tparam)
|
||||
tparam setInfo tvar.constr.inst
|
||||
tparam resetFlag DEFERRED
|
||||
if (settings.debug.value) log("new alias of " + tparam + " = " + tparam.info)
|
||||
|
@ -947,7 +888,7 @@ trait Infer {
|
|||
if (!(lo <:< hi)) {
|
||||
if (settings.debug.value) log("inconsistent: "+tparam+" "+lo+" "+hi)
|
||||
} else if (!((lo <:< tparam.info.bounds.lo) && (tparam.info.bounds.hi <:< hi))) {
|
||||
context.nextEnclosing(.tree.isInstanceOf[CaseDef]).pushTypeBounds(tparam)
|
||||
context.nextEnclosing(_.tree.isInstanceOf[CaseDef]).pushTypeBounds(tparam)
|
||||
tparam setInfo mkTypeBounds(lo, hi)
|
||||
if (settings.debug.value) log("new bounds of " + tparam + " = " + tparam.info)
|
||||
} else {
|
||||
|
@ -1192,7 +1133,7 @@ trait Infer {
|
|||
inferMethodAlternative(tree, undetparams, argtpes, WildcardType)
|
||||
}
|
||||
} else if (!competing.isEmpty) {
|
||||
if (!(argtpes exists (.isErroneous)) && !pt.isErroneous)
|
||||
if (!(argtpes exists (_.isErroneous)) && !pt.isErroneous)
|
||||
context.ambiguousError(tree.pos, pre, best, competing.head,
|
||||
"argument types " + argtpes.mkString("(", ",", ")") +
|
||||
(if (pt == WildcardType) "" else " and expected result type " + pt))
|
||||
|
@ -1252,7 +1193,7 @@ trait Infer {
|
|||
if (sym0.hasFlag(OVERLOADED)) {
|
||||
val sym = sym0 filter { alt => isWithinBounds(pre, alt.owner, alt.typeParams, argtypes) }
|
||||
if (sym == NoSymbol) {
|
||||
if (!(argtypes exists (.isErroneous))) {
|
||||
if (!(argtypes exists (_.isErroneous))) {
|
||||
error(
|
||||
tree.pos,
|
||||
"type arguments " + argtypes.mkString("[", ",", "]") +
|
||||
|
@ -1264,7 +1205,7 @@ trait Infer {
|
|||
if (sym.hasFlag(OVERLOADED)) {
|
||||
val tparams = new AsSeenFromMap(pre, sym.alternatives.head.owner).mapOver(
|
||||
sym.alternatives.head.typeParams)
|
||||
val bounds = tparams map (.tpe) //@M TODO: might be affected by change to tpe in Symbol
|
||||
val bounds = tparams map (_.tpe) //@M TODO: might be affected by change to tpe in Symbol
|
||||
val tpe =
|
||||
PolyType(tparams,
|
||||
OverloadedType(AntiPolyType(pre, bounds), sym.alternatives))
|
||||
|
|
|
@ -15,7 +15,7 @@ import symtab.Flags._
|
|||
* @author Martin Odersky
|
||||
* @version 1.0
|
||||
*/
|
||||
trait Namers requires Analyzer {
|
||||
trait Namers { self: Analyzer =>
|
||||
import global._
|
||||
import definitions._
|
||||
|
||||
|
@ -209,12 +209,12 @@ trait Namers requires Analyzer {
|
|||
}
|
||||
|
||||
def newTypeSkolems(tparams: List[Symbol]): List[Symbol] = {
|
||||
val tskolems = tparams map (.newTypeSkolem)
|
||||
val tskolems = tparams map (_.newTypeSkolem)
|
||||
val ltp = new LazyType {
|
||||
override def complete(sym: Symbol): unit =
|
||||
sym setInfo sym.deSkolemize.info.substSym(tparams, tskolems) //@M the info of a skolem is the skolemized info of the actual type parameter of the skolem
|
||||
}
|
||||
tskolems foreach (.setInfo(ltp))
|
||||
tskolems foreach (_.setInfo(ltp))
|
||||
tskolems
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ trait Namers requires Analyzer {
|
|||
* (a skolem is a representation of a bound variable when viewed outside its scope)
|
||||
*/
|
||||
def skolemize(tparams: List[AbsTypeDef]): unit = {
|
||||
val tskolems = newTypeSkolems(tparams map (.symbol))
|
||||
val tskolems = newTypeSkolems(tparams map (_.symbol))
|
||||
for ((tparam, tskolem) <- tparams zip tskolems) tparam.symbol = tskolem
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ trait Namers requires Analyzer {
|
|||
/** A class representing a lazy type with known type parameters.
|
||||
*/
|
||||
class LazyPolyType(tparams: List[Tree], restp: Type, owner: Tree, ownerSym: Symbol, ctx: Context) extends LazyType { //@M
|
||||
override val typeParams: List[Symbol]= tparams map (.symbol) //@M
|
||||
override val typeParams: List[Symbol]= tparams map (_.symbol) //@M
|
||||
override def complete(sym: Symbol): unit = {
|
||||
if(ownerSym.isAbstractType) //@M an abstract type's type parameters are entered
|
||||
new Namer(ctx.makeNewScope(owner, ownerSym)).enterSyms(tparams) //@M
|
||||
|
@ -420,7 +420,7 @@ trait Namers requires Analyzer {
|
|||
enterInScope(param.symbol)
|
||||
param.symbol
|
||||
} else param.symbol
|
||||
vparamss.map(.map(enterValueParam))
|
||||
vparamss.map(_.map(enterValueParam))
|
||||
}
|
||||
|
||||
private def templateSig(templ: Template): Type = {
|
||||
|
@ -473,7 +473,7 @@ trait Namers requires Analyzer {
|
|||
if (tpt.isEmpty && meth.name == nme.CONSTRUCTOR) tpt.tpe = context.enclClass.owner.tpe
|
||||
|
||||
if (onlyPresentation)
|
||||
methodArgumentNames(meth) = vparamss.map(.map(.symbol));
|
||||
methodArgumentNames(meth) = vparamss.map(_.map(_.symbol));
|
||||
|
||||
def convertToDeBruijn(vparams: List[Symbol], level: int): TypeMap = new TypeMap {
|
||||
def apply(tp: Type) = {
|
||||
|
@ -534,7 +534,7 @@ trait Namers requires Analyzer {
|
|||
sym != NoSymbol && (site.memberType(sym) matches thisMethodType(resultPt)))
|
||||
|
||||
// fill in result type and parameter types from overridden symbol if there is a unique one.
|
||||
if (meth.owner.isClass && (tpt.isEmpty || vparamss.exists(.exists(.tpt.isEmpty)))) {
|
||||
if (meth.owner.isClass && (tpt.isEmpty || vparamss.exists(_.exists(_.tpt.isEmpty)))) {
|
||||
// try to complete from matching definition in base type
|
||||
for (vparams <- vparamss; vparam <- vparams)
|
||||
if (vparam.tpt.isEmpty) vparam.symbol setInfo WildcardType
|
||||
|
@ -570,7 +570,7 @@ trait Namers requires Analyzer {
|
|||
}
|
||||
// Add a () parameter section if this overrides dome method with () parameters.
|
||||
if (meth.owner.isClass && vparamss.isEmpty && overriddenSymbol.alternatives.exists(
|
||||
.info.isInstanceOf[MethodType])) {
|
||||
_.info.isInstanceOf[MethodType])) {
|
||||
vparamSymss = List(List())
|
||||
}
|
||||
for (vparams <- vparamss; vparam <- vparams if vparam.tpt.isEmpty) {
|
||||
|
@ -580,7 +580,7 @@ trait Namers requires Analyzer {
|
|||
|
||||
thisMethodType(
|
||||
if (tpt.isEmpty) {
|
||||
val pt = resultPt.substSym(tparamSyms, tparams map (.symbol))
|
||||
val pt = resultPt.substSym(tparamSyms, tparams map (_.symbol))
|
||||
tpt.tpe = deconstIfNotFinal(meth, typer.computeType(rhs, pt))
|
||||
tpt.tpe
|
||||
} else typer.typedType(tpt).tpe)
|
||||
|
|
|
@ -425,6 +425,8 @@ abstract class RefChecks extends InfoTransform {
|
|||
validateVariance(result, variance)
|
||||
case PolyType(tparams, result) =>
|
||||
validateVariance(result, variance)
|
||||
case ExistentialType(tparams, result) =>
|
||||
validateVariance(result, variance)
|
||||
case AnnotatedType(attribs, tp) =>
|
||||
validateVariance(tp, variance)
|
||||
}
|
||||
|
@ -678,7 +680,7 @@ abstract class RefChecks extends InfoTransform {
|
|||
unit.deprecationWarning(
|
||||
tree.pos,
|
||||
symbol.toString + " overrides concrete, non-deprecated symbol(s):" +
|
||||
concrOvers.map(.fullNameString).mkString(" ", ", ", ""))
|
||||
concrOvers.map(_.fullNameString).mkString(" ", ", ", ""))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -721,7 +723,7 @@ abstract class RefChecks extends InfoTransform {
|
|||
} traverse tree.tpe
|
||||
|
||||
case TypeApply(fn, args) =>
|
||||
checkBounds(NoPrefix, NoSymbol, fn.tpe.typeParams, args map (.tpe))
|
||||
checkBounds(NoPrefix, NoSymbol, fn.tpe.typeParams, args map (_.tpe))
|
||||
if (sym.isSourceMethod && sym.hasFlag(CASE)) result = toConstructor(tree.pos, tree.tpe)
|
||||
|
||||
case Apply(
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
|
|||
private var accDefs: List[(Symbol, ListBuffer[Tree])] = List()
|
||||
|
||||
private def accDefBuf(clazz: Symbol) =
|
||||
accDefs.dropWhile(._1.!=(clazz)).head._2
|
||||
accDefs.dropWhile(_._1 != clazz).head._2
|
||||
|
||||
private def transformArgs(args: List[Tree], formals: List[Type]) = {
|
||||
if (!formals.isEmpty && formals.last.symbol == definitions.ByNameParamClass)
|
||||
|
@ -106,7 +106,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
|
|||
if (tree.isTerm && mix == nme.EMPTY.toTypeName &&
|
||||
(clazz.isTrait || clazz != currentOwner.enclClass || !validCurrentOwner)) {
|
||||
val supername = nme.superName(sym.name)
|
||||
var superAcc = clazz.info.decl(supername).suchThat(.alias.==(sym))
|
||||
var superAcc = clazz.info.decl(supername).suchThat(_.alias == sym)
|
||||
if (superAcc == NoSymbol) {
|
||||
if (settings.debug.value) log("add super acc " + sym + sym.locationString + " to `" + clazz);//debug
|
||||
superAcc =
|
||||
|
|
|
@ -26,7 +26,7 @@ import scala.collection.mutable.ListBuffer
|
|||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
trait SyntheticMethods requires Analyzer {
|
||||
trait SyntheticMethods { self: Analyzer =>
|
||||
import global._ // the global environment
|
||||
import definitions._ // standard classes and methods
|
||||
import typer.{typed} // methods to type trees
|
||||
|
@ -80,7 +80,7 @@ trait SyntheticMethods requires Analyzer {
|
|||
}
|
||||
|
||||
def productElementMethod(accs: List[Symbol]): Tree = {
|
||||
//val retTpe = lub(accs map (.tpe.resultType))
|
||||
//val retTpe = lub(accs map (_.tpe.resultType))
|
||||
val method = syntheticMethod(nme.productElement, FINAL, MethodType(List(IntClass.tpe), AnyClass.tpe/*retTpe*/))
|
||||
typed(DefDef(method, vparamss => Match(Ident(vparamss.head.head), {
|
||||
(for ((sym,i) <- accs.zipWithIndex) yield {
|
||||
|
|
|
@ -22,7 +22,7 @@ import util.HashSet
|
|||
* @author Martin Odersky
|
||||
* @version 1.0
|
||||
*/
|
||||
trait Typers requires Analyzer {
|
||||
trait Typers { self: Analyzer =>
|
||||
import global._
|
||||
import definitions._
|
||||
import posAssigner.atPos
|
||||
|
@ -284,9 +284,9 @@ trait Typers requires Analyzer {
|
|||
|
||||
def checkParamsConvertible(pos: Position, tpe: Type): unit = tpe match {
|
||||
case MethodType(formals, restpe) =>
|
||||
if (formals.exists(.symbol.==(ByNameParamClass)) && formals.length != 1)
|
||||
if (formals.exists(_.symbol == ByNameParamClass) && formals.length != 1)
|
||||
error(pos, "methods with `=>'-parameter can be converted to function values only if they take no other parameters")
|
||||
if (formals exists (.symbol.==(RepeatedParamClass)))
|
||||
if (formals exists (_.symbol == RepeatedParamClass))
|
||||
error(pos, "methods with `*'-parameters cannot be converted to function values");
|
||||
if (restpe.isDependent)
|
||||
error(pos, "method with dependent type "+tpe+" cannot be converted to function value");
|
||||
|
@ -306,7 +306,7 @@ trait Typers requires Analyzer {
|
|||
object checkNoEscaping extends TypeMap {
|
||||
private var owner: Symbol = _
|
||||
private var scope: Scope = _
|
||||
private var badSymbol: Symbol = _
|
||||
private var hiddenSymbols: List[Symbol] = _
|
||||
|
||||
/** Check that type <code>tree</code> does not refer to private
|
||||
* components unless itself is wrapped in something private
|
||||
|
@ -333,68 +333,60 @@ trait Typers requires Analyzer {
|
|||
def check[T <: Tree](owner: Symbol, scope: Scope, pt: Type, tree: T): T = {
|
||||
this.owner = owner
|
||||
this.scope = scope
|
||||
badSymbol = NoSymbol
|
||||
hiddenSymbols = List()
|
||||
apply(tree.tpe)
|
||||
if (badSymbol == NoSymbol) tree
|
||||
else if (badSymbol.isErroneous) setError(tree)
|
||||
else if (isFullyDefined(pt)) tree setType pt
|
||||
else if (tree.tpe.symbol.isAnonymousClass)
|
||||
if (hiddenSymbols.isEmpty) tree
|
||||
else if (hiddenSymbols exists (_.isErroneous)) setError(tree)
|
||||
else if (isFullyDefined(pt)) tree setType pt //todo: eliminate
|
||||
else if (tree.tpe.symbol.isAnonymousClass) // todo: eliminate
|
||||
check(owner, scope, pt, tree setType anonymousClassRefinement(tree.tpe.symbol))
|
||||
else {
|
||||
val tp1 = try {
|
||||
heal(tree.tpe)
|
||||
} catch {
|
||||
case ex: MalformedType =>
|
||||
tree.tpe
|
||||
// revert to `tree.tpe', because the healing widening operation would introduce
|
||||
// a malformed type
|
||||
}
|
||||
if (tp1 eq tree.tpe) {
|
||||
error(tree.pos,
|
||||
(if (badSymbol hasFlag PRIVATE) "private " else "") + badSymbol +
|
||||
" escapes its defining scope as part of type "+tree.tpe)
|
||||
setError(tree)
|
||||
} else
|
||||
check(owner, scope, pt, tree setType tp1)
|
||||
else if (owner == NoSymbol) { // locals
|
||||
val (tparams, tp1) = existentialTransform(hiddenSymbols.reverse, tree.tpe)
|
||||
// Console.println("original type: "+tree.tpe)
|
||||
// Console.println("exist params : "+tparams)
|
||||
// Console.println("replaced type: "+tp1)
|
||||
tree setType existentialAbstraction(tparams, tp1)
|
||||
// Console.println("abstracted type: "+tree.tpe)
|
||||
// tree
|
||||
} else { // privates
|
||||
val badSymbol = hiddenSymbols.head
|
||||
error(tree.pos,
|
||||
(if (badSymbol hasFlag PRIVATE) "private " else "") + badSymbol +
|
||||
" escapes its defining scope as part of type "+tree.tpe)
|
||||
setError(tree)
|
||||
}
|
||||
}
|
||||
|
||||
object heal extends TypeMap {
|
||||
def apply(tp: Type): Type = tp match {
|
||||
case SingleType(pre, sym) =>
|
||||
if ((variance == 1) && (pre contains badSymbol)) {
|
||||
val tp1 = tp.widen
|
||||
if (tp1 contains badSymbol) tp else tp1
|
||||
} else tp
|
||||
case _ =>
|
||||
mapOver(tp)
|
||||
}
|
||||
}
|
||||
def addHidden(sym: Symbol) =
|
||||
if (!(hiddenSymbols contains sym)) hiddenSymbols = sym :: hiddenSymbols
|
||||
|
||||
override def apply(t: Type): Type = {
|
||||
def checkNoEscape(sym: Symbol): unit = {
|
||||
if (sym.hasFlag(PRIVATE)) {
|
||||
var o = owner
|
||||
var leaking = true
|
||||
while (o != NoSymbol && o != sym.owner &&
|
||||
!o.isLocal && !o.hasFlag(PRIVATE) &&
|
||||
!o.privateWithin.ownerChain.contains(sym.owner))
|
||||
o = o.owner
|
||||
if (o == sym.owner) badSymbol = sym
|
||||
if (o == sym.owner) addHidden(sym)
|
||||
} else if (sym.owner.isTerm && !sym.isTypeParameterOrSkolem) {
|
||||
var e = scope.lookupEntry(sym.name)
|
||||
while ((e ne null) && e.owner == scope && badSymbol == NoSymbol) {
|
||||
if (e.sym == sym) badSymbol = e.sym
|
||||
e = scope.lookupNextEntry(e)
|
||||
var found = false
|
||||
while (!found && (e ne null) && e.owner == scope) {
|
||||
if (e.sym == sym) {
|
||||
found = true
|
||||
addHidden(sym)
|
||||
} else {
|
||||
e = scope.lookupNextEntry(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (badSymbol == NoSymbol)
|
||||
t match {
|
||||
case TypeRef(_, sym, _) => checkNoEscape(sym)
|
||||
case SingleType(_, sym) => checkNoEscape(sym)
|
||||
case _ =>
|
||||
}
|
||||
t match {
|
||||
case TypeRef(_, sym, _) => checkNoEscape(sym)
|
||||
case SingleType(_, sym) => checkNoEscape(sym)
|
||||
case _ =>
|
||||
}
|
||||
mapOver(t)
|
||||
}
|
||||
}
|
||||
|
@ -643,7 +635,7 @@ trait Typers requires Analyzer {
|
|||
case _ => TypeTree(tree.tpe) setOriginal(tree)
|
||||
}
|
||||
} else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode)) { // (5)
|
||||
val constr = tree.symbol.filter(.isCaseFactory)
|
||||
val constr = tree.symbol.filter(_.isCaseFactory)
|
||||
if (constr != NoSymbol) {
|
||||
val clazz = constr.tpe.finalResultType.symbol
|
||||
assert(clazz hasFlag CASE, tree)
|
||||
|
@ -803,12 +795,12 @@ trait Typers requires Analyzer {
|
|||
val supertparams = if (supertpt.hasSymbol) supertpt.symbol.typeParams else List()
|
||||
var supertpe = supertpt.tpe
|
||||
if (!supertparams.isEmpty)
|
||||
supertpe = PolyType(supertparams, appliedType(supertpe, supertparams map (.tpe)))
|
||||
supertpe = PolyType(supertparams, appliedType(supertpe, supertparams map (_.tpe)))
|
||||
|
||||
// A method to replace a super reference by a New in a supercall
|
||||
def transformSuperCall(scall: Tree): Tree = (scall: @unchecked) match {
|
||||
case Apply(fn, args) =>
|
||||
copy.Apply(scall, transformSuperCall(fn), args map (.duplicate))
|
||||
copy.Apply(scall, transformSuperCall(fn), args map (_.duplicate))
|
||||
case Select(Super(_, _), nme.CONSTRUCTOR) =>
|
||||
copy.Select(
|
||||
scall,
|
||||
|
@ -819,7 +811,7 @@ trait Typers requires Analyzer {
|
|||
treeInfo.firstConstructor(templ.body) match {
|
||||
case constr @ DefDef(_, _, _, vparamss, _, cbody @ Block(cstats, cunit)) =>
|
||||
// Convert constructor body to block in environment and typecheck it
|
||||
val cstats1: List[Tree] = cstats map (.duplicate)
|
||||
val cstats1: List[Tree] = cstats map (_.duplicate)
|
||||
val scall = if (cstats.isEmpty) EmptyTree else cstats.last
|
||||
val cbody1 = scall match {
|
||||
case Apply(_, _) =>
|
||||
|
@ -834,7 +826,7 @@ trait Typers requires Analyzer {
|
|||
val cbody2 =
|
||||
newTyper(makeNewScope(outercontext, constr, outercontext.owner))
|
||||
.typePrimaryConstrBody(
|
||||
cbody1, supertparams, clazz.unsafeTypeParams, vparamss map (.map(.duplicate)))
|
||||
cbody1, supertparams, clazz.unsafeTypeParams, vparamss map (_.map(_.duplicate)))
|
||||
|
||||
scall match {
|
||||
case Apply(_, _) =>
|
||||
|
@ -927,7 +919,7 @@ trait Typers requires Analyzer {
|
|||
if (classinfo.expansiveRefs(tparam) contains tparam) {
|
||||
error(tparam.pos, "class graph is not finitary because type parameter "+tparam.name+" is expansively recursive")
|
||||
val newinfo = ClassInfoType(
|
||||
classinfo.parents map (.instantiateTypeParams(List(tparam), List(AnyRefClass.tpe))),
|
||||
classinfo.parents map (_.instantiateTypeParams(List(tparam), List(AnyRefClass.tpe))),
|
||||
classinfo.decls,
|
||||
clazz)
|
||||
clazz.setInfo {
|
||||
|
@ -1117,7 +1109,7 @@ trait Typers requires Analyzer {
|
|||
List.map2(superParamAccessors, superArgs) { (superAcc, superArg) =>
|
||||
superArg match {
|
||||
case Ident(name) =>
|
||||
if (vparamss.exists(.exists(vp => vp.symbol == superArg.symbol))) {
|
||||
if (vparamss.exists(_.exists(_.symbol == superArg.symbol))) {
|
||||
var alias = superAcc.initialize.alias
|
||||
if (alias == NoSymbol)
|
||||
alias = superAcc.getter(superAcc.owner)
|
||||
|
@ -1125,7 +1117,7 @@ trait Typers requires Analyzer {
|
|||
superClazz.info.nonPrivateMember(alias.name) != alias)
|
||||
alias = NoSymbol
|
||||
if (alias != NoSymbol) {
|
||||
var ownAcc = clazz.info.decl(name).suchThat(.hasFlag(PARAMACCESSOR))
|
||||
var ownAcc = clazz.info.decl(name).suchThat(_.hasFlag(PARAMACCESSOR))
|
||||
if ((ownAcc hasFlag ACCESSOR) && !(ownAcc hasFlag DEFERRED))
|
||||
ownAcc = ownAcc.accessed
|
||||
if (!ownAcc.isVariable && !alias.accessed.isVariable) {
|
||||
|
@ -1320,7 +1312,7 @@ trait Typers requires Analyzer {
|
|||
&& // see bug901 for a reason why next conditions are neeed
|
||||
(pt.normalize.typeArgs.length - 1 == fun.vparams.length
|
||||
||
|
||||
fun.vparams.exists(.tpt.isEmpty)))
|
||||
fun.vparams.exists(_.tpt.isEmpty)))
|
||||
(pt.symbol, pt.normalize.typeArgs.init, pt.normalize.typeArgs.last)
|
||||
else
|
||||
(FunctionClass(fun.vparams.length), fun.vparams map (x => NoType), WildcardType)
|
||||
|
@ -1349,7 +1341,7 @@ trait Typers requires Analyzer {
|
|||
checkNoEscaping.locals(context.scope, WildcardType, vparam.tpt); ()
|
||||
}
|
||||
val body = checkNoEscaping.locals(context.scope, respt, typed(fun.body, respt))
|
||||
val formals = vparamSyms map (.tpe)
|
||||
val formals = vparamSyms map (_.tpe)
|
||||
val restpe = body.tpe.deconst
|
||||
val funtpe = typeRef(clazz.tpe.prefix, clazz, formals ::: List(restpe))
|
||||
val fun1 = copy.Function(fun, vparams, checkNoEscaping.locals(context.scope, restpe, body))
|
||||
|
@ -1493,13 +1485,13 @@ trait Typers requires Analyzer {
|
|||
context.undetparams = List()
|
||||
val args1 = typedArgs(args, argMode(fun, mode))
|
||||
context.undetparams = undetparams
|
||||
inferMethodAlternative(fun, context.undetparams, args1 map (.tpe.deconst), pt)
|
||||
inferMethodAlternative(fun, context.undetparams, args1 map (_.tpe.deconst), pt)
|
||||
doTypedApply(tree, adapt(fun, funMode(mode), WildcardType), args1, mode, pt)
|
||||
case mt @ MethodType(formals0, _) =>
|
||||
val formals = formalTypes(formals0, args.length)
|
||||
var args1 = actualArgs(tree.pos, args, formals.length)
|
||||
if (args1.length != args.length) {
|
||||
silent(.doTypedApply(tree, fun, args1, mode, pt)) match {
|
||||
silent(_.doTypedApply(tree, fun, args1, mode, pt)) match {
|
||||
case t: Tree => t
|
||||
case ex => errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun))
|
||||
}
|
||||
|
@ -1558,9 +1550,9 @@ trait Typers requires Analyzer {
|
|||
arg1
|
||||
}
|
||||
val args2 = List.map2(args1, formals)(typedArgToPoly)
|
||||
if (args2 exists (.tpe.isError)) setError(tree)
|
||||
if (args2 exists (_.tpe.isError)) setError(tree)
|
||||
else {
|
||||
if (settings.debug.value) log("infer method inst "+fun+", tparams = "+tparams+", args = "+args2.map(.tpe)+", pt = "+pt+", lobounds = "+tparams.map(.tpe.bounds.lo)+", parambounds = "+tparams.map(.info));//debug
|
||||
if (settings.debug.value) log("infer method inst "+fun+", tparams = "+tparams+", args = "+args2.map(_.tpe)+", pt = "+pt+", lobounds = "+tparams.map(_.tpe.bounds.lo)+", parambounds = "+tparams.map(_.info));//debug
|
||||
val undetparams = inferMethodInstance(fun, tparams, args2, pt)
|
||||
val result = doTypedApply(tree, fun, args2, mode, pt)
|
||||
context.undetparams = undetparams
|
||||
|
@ -1668,7 +1660,7 @@ trait Typers requires Analyzer {
|
|||
val attrScope = annType.decls
|
||||
.filter(sym => sym.isMethod && !sym.isConstructor && sym.hasFlag(JAVA))
|
||||
val names = new collection.mutable.HashSet[Symbol]
|
||||
names ++= attrScope.elements.filter(.isMethod)
|
||||
names ++= attrScope.elements.filter(_.isMethod)
|
||||
if (args.length == 1) {
|
||||
names.retain(sym => sym.name != nme.value)
|
||||
}
|
||||
|
@ -1702,6 +1694,38 @@ trait Typers requires Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
/** Given a set `rawSyms' of term- and type-symbols, and a type `tp'.
|
||||
* produce a set of fresh type parameters and a type so that it can be
|
||||
* abstracted to an existential type.
|
||||
* Every type symbol `T' in `rawSyms' is mapped to a clone.
|
||||
* Every term symbol `x' of type `T' in `rawSyms' is mapped to a type parameter
|
||||
*
|
||||
* type x.type <: T with <singleton>
|
||||
*
|
||||
* The name of the type parameter is `x.type', to produce nice diagnostics.
|
||||
* The <singleton> parent ensures that the type parameter is still seen as a stable type.
|
||||
* The new symbols are substituted for the old ones in all type parameter infos
|
||||
* and in the returned type itself.
|
||||
*/
|
||||
protected def existentialTransform(rawSyms: List[Symbol], tp: Type) = {
|
||||
val typeParams = rawSyms map { sym =>
|
||||
if (sym.isType) sym.cloneSymbol
|
||||
else sym.owner.newAbstractType(sym.pos, newTermName(sym.name+".Type"))//todo: change to .type
|
||||
.setInfo(mkTypeBounds(AllClass.tpe, sym.tpe))
|
||||
}
|
||||
val typeParamTypes = typeParams map (_.tpe)
|
||||
for (tparam <- typeParams) tparam.setInfo(tparam.info.subst(rawSyms, typeParamTypes))
|
||||
(typeParams, tp.subst(rawSyms, typeParamTypes))
|
||||
}
|
||||
|
||||
protected def typedExistentialTypeTree(tree: ExistentialTypeTree): Tree = {
|
||||
namer.enterSyms(tree.whereClauses)
|
||||
val whereClauses1 = typedStats(tree.whereClauses, NoSymbol)
|
||||
val tpt1 = typedType(tree.tpt)
|
||||
val (typeParams, tpe) = existentialTransform(tree.whereClauses map (_.symbol), tpt1.tpe)
|
||||
copy.ExistentialTypeTree(tree, tpt1, whereClauses1).setType(ExistentialType(typeParams, tpe))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tree ...
|
||||
* @param mode ...
|
||||
|
@ -1854,7 +1878,7 @@ trait Typers requires Analyzer {
|
|||
context.undetparams = cloneSymbols(tpt1.symbol.typeParams)
|
||||
tpt1 = TypeTree()
|
||||
.setOriginal(tpt1) /* .setPos(tpt1.pos) */
|
||||
.setType(appliedType(tpt1.tpe, context.undetparams map (.tpe)))
|
||||
.setType(appliedType(tpt1.tpe, context.undetparams map (_.tpe)))
|
||||
}
|
||||
if (tpt1.tpe.symbol hasFlag ABSTRACT)
|
||||
error(tree.pos, tpt1.tpe.symbol + " is abstract; cannot be instantiated")
|
||||
|
@ -1915,7 +1939,7 @@ trait Typers requires Analyzer {
|
|||
|
||||
def typedTypeApply(fun: Tree, args: List[Tree]): Tree = fun.tpe match {
|
||||
case OverloadedType(pre, alts) =>
|
||||
inferPolyAlternatives(fun, args map (.tpe))
|
||||
inferPolyAlternatives(fun, args map (_.tpe))
|
||||
val tparams = fun.symbol.typeParams //@M TODO: fun.symbol.info.typeParams ? (as in typedAppliedTypeTree)
|
||||
assert(args.length == tparams.length) //@M: in case TypeApply we can't check the kind-arities
|
||||
// of the type arguments as we don't know which alternative to choose... here we do
|
||||
|
@ -1926,7 +1950,7 @@ trait Typers requires Analyzer {
|
|||
typedTypeApply(fun, args1)
|
||||
case PolyType(tparams, restpe) if (tparams.length != 0) =>
|
||||
if (tparams.length == args.length) {
|
||||
val targs = args map (.tpe)
|
||||
val targs = args map (_.tpe)
|
||||
checkBounds(tree.pos, NoPrefix, NoSymbol, tparams, targs, "")
|
||||
if (fun.symbol == Predef_classOf) {
|
||||
if (!targs.head.symbol.isClass || targs.head.symbol.isRefinementClass)
|
||||
|
@ -1972,7 +1996,7 @@ trait Typers requires Analyzer {
|
|||
* @return ...
|
||||
*/
|
||||
def tryTypedApply(fun: Tree, args: List[Tree]): Tree =
|
||||
silent(.doTypedApply(tree, fun, args, mode, pt)) match {
|
||||
silent(_.doTypedApply(tree, fun, args, mode, pt)) match {
|
||||
case t: Tree =>
|
||||
t
|
||||
case ex: TypeError =>
|
||||
|
@ -2013,7 +2037,7 @@ trait Typers requires Analyzer {
|
|||
typed1(tree, mode & ~PATTERNmode | EXPRmode, pt)
|
||||
} else {
|
||||
val funpt = if ((mode & PATTERNmode) != 0) pt else WildcardType
|
||||
silent(.typed(fun, funMode(mode), funpt)) match {
|
||||
silent(_.typed(fun, funMode(mode), funpt)) match {
|
||||
case fun1: Tree =>
|
||||
val fun2 = if (stableApplication) stabilizeFun(fun1, mode, pt) else fun1
|
||||
if (util.Statistics.enabled) appcnt = appcnt + 1
|
||||
|
@ -2087,7 +2111,7 @@ trait Typers requires Analyzer {
|
|||
mkAssign(qual)
|
||||
}
|
||||
if (settings.debug.value) log("retry assign: "+tree1)
|
||||
silent(.typed1(tree1, mode, pt)) match {
|
||||
silent(_.typed1(tree1, mode, pt)) match {
|
||||
case t: Tree =>
|
||||
t
|
||||
case _ =>
|
||||
|
@ -2114,7 +2138,7 @@ trait Typers requires Analyzer {
|
|||
val ps = clazz.info.parents filter (p => p.symbol.name == mix)
|
||||
if (ps.isEmpty) {
|
||||
if (settings.debug.value)
|
||||
Console.println(clazz.info.parents map (.symbol.name))//debug
|
||||
Console.println(clazz.info.parents map (_.symbol.name))//debug
|
||||
error(tree.pos, mix+" does not name a parent class of "+clazz)
|
||||
ErrorType
|
||||
} else if (ps.tail.isEmpty) {
|
||||
|
@ -2360,10 +2384,10 @@ trait Typers requires Analyzer {
|
|||
|
||||
def typedCompoundTypeTree(templ: Template) = {
|
||||
val parents1 = List.mapConserve(templ.parents)(typedType)
|
||||
if (parents1 exists (.tpe.isError)) tree setType ErrorType
|
||||
if (parents1 exists (_.tpe.isError)) tree setType ErrorType
|
||||
else {
|
||||
val decls = newDecls(tree.asInstanceOf[CompoundTypeTree])
|
||||
val self = refinedType(parents1 map (.tpe), context.enclClass.owner, decls)
|
||||
val self = refinedType(parents1 map (_.tpe), context.enclClass.owner, decls)
|
||||
newTyper(context.make(templ, self.symbol, decls)).typedRefinement(templ.body)
|
||||
tree setType self
|
||||
}
|
||||
|
@ -2381,7 +2405,7 @@ trait Typers requires Analyzer {
|
|||
else map2Conserve(args, tparams) {
|
||||
(arg, tparam) => typedHigherKindedType(arg, parameterizedType(tparam.typeParams, AnyClass.tpe)) //@M! the polytype denotes the expected kind
|
||||
}
|
||||
val argtypes = args1 map (.tpe)
|
||||
val argtypes = args1 map (_.tpe)
|
||||
val owntype = if (tpt1.symbol.isClass || tpt1.symbol.isTypeMember) // @M! added the latter condition
|
||||
appliedType(tpt1.tpe, argtypes)
|
||||
else tpt1.tpe.instantiateTypeParams(tparams, argtypes)
|
||||
|
@ -2403,7 +2427,7 @@ trait Typers requires Analyzer {
|
|||
errorTree(tree, "wrong number of type arguments for "+tpt1.tpe+", should be "+tparams.length)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// begin typed1
|
||||
val sym: Symbol = tree.symbol
|
||||
if (sym ne null) sym.initialize
|
||||
|
@ -2491,7 +2515,7 @@ trait Typers requires Analyzer {
|
|||
} else {
|
||||
val selector1 = checkDead(typed(selector))
|
||||
val cases1 = typedCases(tree, cases, selector1.tpe.widen, pt)
|
||||
copy.Match(tree, selector1, cases1) setType ptOrLub(cases1 map (.tpe))
|
||||
copy.Match(tree, selector1, cases1) setType ptOrLub(cases1 map (_.tpe))
|
||||
}
|
||||
|
||||
case Return(expr) =>
|
||||
|
@ -2503,7 +2527,7 @@ trait Typers requires Analyzer {
|
|||
val finalizer1 = if (finalizer.isEmpty) finalizer
|
||||
else typed(finalizer, UnitClass.tpe)
|
||||
copy.Try(tree, block1, catches1, finalizer1)
|
||||
.setType(ptOrLub(block1.tpe :: (catches1 map (.tpe))))
|
||||
.setType(ptOrLub(block1.tpe :: (catches1 map (_.tpe))))
|
||||
|
||||
case Throw(expr) =>
|
||||
val expr1 = typed(expr, ThrowableClass.tpe)
|
||||
|
@ -2627,6 +2651,9 @@ trait Typers requires Analyzer {
|
|||
case WildcardTypeTree(lo, hi) =>
|
||||
tree setType mkTypeBounds(typedType(lo).tpe, typedType(hi).tpe)
|
||||
|
||||
case etpt @ ExistentialTypeTree(_, _) =>
|
||||
newTyper(makeNewScope(context, tree, context.owner)).typedExistentialTypeTree(etpt)
|
||||
|
||||
case TypeTree() =>
|
||||
// we should get here only when something before failed
|
||||
// and we try again (@see tryTypedApply). In that case we can assign
|
||||
|
@ -2719,19 +2746,19 @@ trait Typers requires Analyzer {
|
|||
|
||||
/** Types a (fully parameterized) type tree */
|
||||
def typedType(tree: Tree): Tree =
|
||||
withNoGlobalVariance{ typed(tree, TYPEmode, WildcardType) }
|
||||
typed(tree, TYPEmode, WildcardType)
|
||||
|
||||
/** Types a higher-kinded type tree -- pt denotes the expected kind*/
|
||||
def typedHigherKindedType(tree: Tree, pt: Type): Tree =
|
||||
if(pt.typeParams.isEmpty) typedType(tree) // kind is known and it's *
|
||||
else withNoGlobalVariance{ typed(tree, HKmode, pt) }
|
||||
else typed(tree, HKmode, pt)
|
||||
|
||||
def typedHigherKindedType(tree: Tree): Tree =
|
||||
withNoGlobalVariance{ typed(tree, HKmode, WildcardType) }
|
||||
typed(tree, HKmode, WildcardType)
|
||||
|
||||
/** Types a type constructor tree used in a new or supertype */
|
||||
def typedTypeConstructor(tree: Tree): Tree = {
|
||||
val result = withNoGlobalVariance{ typed(tree, TYPEmode | FUNmode, WildcardType) }
|
||||
val result = typed(tree, TYPEmode | FUNmode, WildcardType)
|
||||
if (!phase.erasedTypes && result.tpe.isInstanceOf[TypeRef] && !result.tpe.prefix.isStable)
|
||||
error(tree.pos, result.tpe.prefix+" is not a legal prefix for a constructor")
|
||||
result setType(result.tpe) // @M: normalization is done during erasure
|
||||
|
@ -2766,7 +2793,7 @@ trait Typers requires Analyzer {
|
|||
|
||||
private def containsError(tp: Type): boolean = tp match {
|
||||
case PolyType(tparams, restpe) => containsError(restpe)
|
||||
case MethodType(formals, restpe) => (formals exists (.isError)) || containsError(restpe)
|
||||
case MethodType(formals, restpe) => (formals exists (_.isError)) || containsError(restpe)
|
||||
case _ => tp.isError
|
||||
}
|
||||
|
||||
|
@ -2918,7 +2945,7 @@ trait Typers requires Analyzer {
|
|||
|
||||
def implicitsOfClass(tp: Type): List[ImplicitInfo] = tp match {
|
||||
case TypeRef(pre, clazz, _) =>
|
||||
clazz.initialize.linkedClassOfClass.info.members.toList.filter(.hasFlag(IMPLICIT)) map
|
||||
clazz.initialize.linkedClassOfClass.info.members.toList.filter(_.hasFlag(IMPLICIT)) map
|
||||
(sym => new ImplicitInfo(sym.name, pre.memberType(clazz.linkedModuleOfClass), sym))
|
||||
case _ =>
|
||||
List()
|
||||
|
|
|
@ -79,6 +79,8 @@ trait Variances {
|
|||
flip(varianceInTypes(formals)(tparam)) & varianceInType(restpe)(tparam)
|
||||
case PolyType(tparams, restpe) =>
|
||||
flip(varianceInSyms(tparams)(tparam)) & varianceInType(restpe)(tparam)
|
||||
case ExistentialType(tparams, restpe) =>
|
||||
varianceInSyms(tparams)(tparam) & varianceInType(restpe)(tparam)
|
||||
case AnnotatedType(attribs, tp) =>
|
||||
varianceInType(tp)(tparam)
|
||||
}
|
||||
|
|
|
@ -711,6 +711,10 @@ sealed abstract class List[+A] extends Seq[A] {
|
|||
|
||||
/** Returns all the elements of this list that satisfy the
|
||||
* predicate <code>p</code>. The order of the elements is preserved.
|
||||
* It is guarenteed that the receiver list itself is returned iff all its
|
||||
* elements satisfy the predicate `p'. Hence the following equality is valid:
|
||||
*
|
||||
* (xs filter p) eq xs == xs forall p
|
||||
*
|
||||
* @param p the predicate used to filter the list.
|
||||
* @return the elements of this list satisfying <code>p</code>.
|
||||
|
|
|
@ -268,7 +268,7 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
|
|||
* @return <code>true</code> iff there is an element of this sequence
|
||||
* which is equal (w.r.t. <code>==</code>) to <code>elem</code>.
|
||||
*/
|
||||
def contains(elem: Any): Boolean = exists (.==(elem))
|
||||
def contains(elem: Any): Boolean = exists (_ == elem)
|
||||
|
||||
/** Returns a subsequence starting from index <code>from</code>
|
||||
* consisting of <code>len</code> elements.
|
||||
|
|
|
@ -48,7 +48,7 @@ final case class Symbol(name: String) {
|
|||
* @return the unique reference to this symbol.
|
||||
*/
|
||||
def intern: Symbol = internedSymbols.synchronized {
|
||||
internedSymbols.get(this).map(.get).getOrElse(None) match {
|
||||
internedSymbols.get(this).map(_.get).getOrElse(None) match {
|
||||
case Some(sym) => sym
|
||||
case _ =>
|
||||
internedSymbols(this) = new ref.WeakReference(this); this
|
||||
|
|
|
@ -113,7 +113,7 @@ trait Map[A, +B] extends PartialFunction[A, B] with Collection[(A, B)] {
|
|||
def keySet: Set[A] = new Set[A] {
|
||||
def size = Map.this.size
|
||||
def contains(key : A) = Map.this.contains(key)
|
||||
def elements = Map.this.elements.map(._1)
|
||||
def elements = Map.this.elements.map(_._1)
|
||||
}
|
||||
|
||||
/** Creates an iterator for a contained values.
|
||||
|
|
|
@ -32,7 +32,7 @@ trait SortedMap[K,+E] extends Map[K,E] with Sorted[K,Tuple2[K,E]] {
|
|||
protected class DefaultKeySet extends SortedSet[K] {
|
||||
def size = SortedMap.this.size
|
||||
def contains(key : K) = SortedMap.this.contains(key)
|
||||
def elements = SortedMap.this.elements.map(._1)
|
||||
def elements = SortedMap.this.elements.map(_._1)
|
||||
def compare(k0 : K, k1 : K) = SortedMap.this.compare(k0, k1);
|
||||
override def rangeImpl(from : Option[K], until : Option[K]) : SortedSet[K] = {
|
||||
val map = SortedMap.this.rangeImpl(from,until);
|
||||
|
|
|
@ -83,9 +83,9 @@ class TreeSet[A <% Ordered[A]](val size: int, t: RedBlack[A]#Tree[Unit])
|
|||
*
|
||||
* @return the new iterator
|
||||
*/
|
||||
def elements: Iterator[A] = tree.elements.elements map (._1)
|
||||
def elements: Iterator[A] = tree.elements.elements map (_._1)
|
||||
|
||||
def elementsSlow = tree.elementsSlow map (._1)
|
||||
def elementsSlow = tree.elementsSlow map (_._1)
|
||||
|
||||
override def foreach(f : A => Unit) : Unit =
|
||||
tree.visit[Unit](())((unit0,y,unit1) => Tuple2(true, f(y)))
|
||||
|
|
|
@ -22,7 +22,7 @@ trait Map[K,E] extends MutableIterable[Tuple2[K,E]] with scala.collection.mutabl
|
|||
/** The values of this map as a projection, which means
|
||||
removals from the returned collection will remove the element from this map.
|
||||
@returns a projection of this map's elements. */
|
||||
def valueSet : MutableIterable.Projection[E] = projection.map(._2);
|
||||
def valueSet : MutableIterable.Projection[E] = projection.map(_._2);
|
||||
def put(key : K, elem : E) : Option[E];
|
||||
def putAll(that : Iterable[Tuple2[K,E]]) : Unit =
|
||||
that.foreach(p => put(p._1, p._2));
|
||||
|
@ -41,7 +41,7 @@ trait Map[K,E] extends MutableIterable[Tuple2[K,E]] with scala.collection.mutabl
|
|||
case Some(e) if e == pair._2 => true;
|
||||
case _ => false;
|
||||
}
|
||||
override def get(key : K) = elements.find(p => p._1 == key).map(._2);
|
||||
override def get(key : K) = elements.find(p => p._1 == key).map(_._2);
|
||||
override def update(key : K, e : E) : Unit = put(key,e);
|
||||
override def +(pair : Tuple2[K,E]) : this.type = {
|
||||
put(pair._1,pair._2); this;
|
||||
|
@ -80,7 +80,7 @@ trait Map[K,E] extends MutableIterable[Tuple2[K,E]] with scala.collection.mutabl
|
|||
protected class KeySet extends Set[K] {
|
||||
override def size = Map.this.size;
|
||||
override def add(k : K) = Map.this.put(k, default(k)) == None;
|
||||
override def elements = Map.this.elements.map(._1);
|
||||
override def elements = Map.this.elements.map(_._1);
|
||||
override def has(k : K) = Map.this.contains(k);
|
||||
}
|
||||
override def filterKeys(p : K => Boolean) : Map.Projection[K,E] = new Filter(p);
|
||||
|
|
|
@ -29,11 +29,11 @@ private[jcl] object Tests {
|
|||
rset + "bad";
|
||||
Console.println(rset);
|
||||
Console.println(set);
|
||||
val fset : SortedSet[String] = rset.projection.filter(.endsWith("d"));
|
||||
val fset : SortedSet[String] = rset.projection.filter(_.endsWith("d"));
|
||||
Console.println(fset);
|
||||
fset += "cd";
|
||||
Console.println(set);
|
||||
//set.projection.map(.length).retain(x => x == 3);
|
||||
//set.projection.map(_.length).retain(x => x == 3);
|
||||
Console.println(set);
|
||||
Console.println(rset);
|
||||
Console.println(fset);
|
||||
|
|
|
@ -21,9 +21,8 @@ package scala.collection.mutable
|
|||
* @version 1.0, 08/07/2003
|
||||
*/
|
||||
abstract class DoubleLinkedList[A, This >: Null <: DoubleLinkedList[A, This]]
|
||||
requires This
|
||||
extends SingleLinkedList[A, This]
|
||||
{
|
||||
{ self: This =>
|
||||
|
||||
var prev: This
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ package scala.collection.mutable
|
|||
* @author Matthias Zenger
|
||||
* @version 1.0, 08/07/2003
|
||||
*/
|
||||
trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This
|
||||
trait ObservableBuffer[A, This <: ObservableBuffer[A, This]]
|
||||
extends Buffer[A]
|
||||
with Publisher[Message[(Location, A)]
|
||||
with Undoable, This]
|
||||
{
|
||||
{ self: This =>
|
||||
|
||||
abstract override def +(element: A): Buffer[A] = {
|
||||
super.+(element)
|
||||
|
|
|
@ -21,11 +21,11 @@ package scala.collection.mutable
|
|||
* @author Martin Odersky
|
||||
* @version 2.0, 31/12/2006
|
||||
*/
|
||||
trait ObservableMap[A, B, This <: ObservableMap[A, B, This]] requires This
|
||||
trait ObservableMap[A, B, This <: ObservableMap[A, B, This]]
|
||||
extends Map[A, B]
|
||||
with Publisher[Message[(A, B)]
|
||||
with Undoable, This]
|
||||
{
|
||||
{ self: This =>
|
||||
|
||||
abstract override def update(key: A, value: B): Unit = get(key) match {
|
||||
case None =>
|
||||
|
|
|
@ -20,11 +20,11 @@ package scala.collection.mutable
|
|||
* @author Matthias Zenger
|
||||
* @version 1.0, 08/07/2003
|
||||
*/
|
||||
trait ObservableSet[A, This <: ObservableSet[A, This]] requires This
|
||||
trait ObservableSet[A, This <: ObservableSet[A, This]]
|
||||
extends Set[A]
|
||||
with Publisher[Message[A]
|
||||
with Undoable, This]
|
||||
{
|
||||
{ self: This =>
|
||||
|
||||
abstract override def +=(elem: A): Unit = if (!contains(elem)) {
|
||||
super.+=(elem)
|
||||
|
|
|
@ -22,7 +22,7 @@ package scala.collection.mutable
|
|||
* @author Matthias Zenger
|
||||
* @version 1.0, 08/07/2003
|
||||
*/
|
||||
trait Publisher[A, This <: Publisher[A, This]] requires This {
|
||||
trait Publisher[A, This <: Publisher[A, This]] { self: This =>
|
||||
private val filters = new HashMap[Subscriber[A, This],
|
||||
scala.collection.mutable.Set[A => Boolean]]
|
||||
with MultiMap[Subscriber[A, This], A => Boolean]
|
||||
|
|
|
@ -20,9 +20,8 @@ package scala.collection.mutable
|
|||
* @version 1.0, 08/07/2003
|
||||
*/
|
||||
abstract class SingleLinkedList[A, This >: Null <: SingleLinkedList[A, This]]
|
||||
requires This
|
||||
extends AnyRef with Seq[A]
|
||||
{
|
||||
{ self: This =>
|
||||
|
||||
var elem: A
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ object BytePickle {
|
|||
share(wrap((a:Array[byte]) => UTF8Codec.decode(a, 0, a.length), (s:String) => UTF8Codec.encode(s), bytearray));
|
||||
|
||||
def bytearray: SPU[Array[byte]] = {
|
||||
wrap((l:List[byte]) => l.toArray, .toList, list(byte))
|
||||
wrap((l:List[byte]) => l.toArray, (_.toList), list(byte))
|
||||
}
|
||||
|
||||
def bool: SPU[boolean] = {
|
||||
|
|
|
@ -19,7 +19,7 @@ trait Reference[+T <: AnyRef] extends Function0[T] {
|
|||
def apply(): T
|
||||
/** return <code>Some</code> underlying if it hasn't been collected, otherwise <code>None</code> */
|
||||
def get : Option[T]
|
||||
override def toString = get.map(.toString).getOrElse("<deleted>")
|
||||
override def toString = get.map(_.toString).getOrElse("<deleted>")
|
||||
def clear(): Unit
|
||||
def enqueue(): Boolean
|
||||
def isEnqueued(): Boolean
|
||||
|
|
|
@ -15,7 +15,7 @@ import compat.StringBuilder
|
|||
import scala.io.Source;
|
||||
import java.net.URL;
|
||||
|
||||
trait ExternalSources requires (ExternalSources with MarkupParser with MarkupHandler) {
|
||||
trait ExternalSources { self: ExternalSources with MarkupParser with MarkupHandler =>
|
||||
|
||||
private def externalSourceFromURL(url:URL): Source = {
|
||||
import java.io.{BufferedReader, InputStreamReader};
|
||||
|
|
|
@ -28,7 +28,7 @@ import scala.xml.dtd._
|
|||
* @author Burak Emir
|
||||
* @version 1.0
|
||||
*/
|
||||
trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef with TokenTests {
|
||||
trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with MarkupHandler =>
|
||||
|
||||
val input: Source
|
||||
|
||||
|
@ -407,7 +407,7 @@ trait MarkupParser requires (MarkupParser with MarkupHandler) extends AnyRef wit
|
|||
* see [66]
|
||||
*/
|
||||
def xCharRef(ch: () => Char, nextch: () => Unit): String = {
|
||||
Utility.parseCharRef(ch, nextch, &reportSyntaxError)
|
||||
Utility.parseCharRef(ch, nextch, reportSyntaxError _)
|
||||
/*
|
||||
val hex = (ch() == 'x') && { nextch(); true };
|
||||
val base = if (hex) 16 else 10;
|
||||
|
|
|
@ -84,7 +84,7 @@ package p {
|
|||
|
||||
Console.println("meth3 = " + meth3.getClass);
|
||||
|
||||
val inc = &meth2(1);
|
||||
val inc = meth2(1)_;
|
||||
Console.println("100 = " + inc("10"));
|
||||
|
||||
getA.x;
|
||||
|
@ -111,7 +111,7 @@ package p {
|
|||
Console.println("meth1(1) = " + meth1(1));
|
||||
Console.println("meth2(1)(1) = " + meth2(1)("1"));
|
||||
|
||||
val inc = &meth2(1);
|
||||
val inc = meth2(1)_;
|
||||
Console.println("100 = " + inc("10"));
|
||||
|
||||
getA.x;
|
||||
|
|
|
@ -7,7 +7,7 @@ abstract class A
|
|||
protected val data: List[A]
|
||||
}
|
||||
|
||||
trait B[T <: B[T]] requires T extends A {}
|
||||
trait B[T <: B[T]] extends A { self: T => }
|
||||
|
||||
abstract class C extends A
|
||||
{
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
bug1024.scala:2: error: type _ escapes its defining scope as part of type (List[_], Int)
|
||||
val (a: List[_], b) = (List(1 ,2 ,3 ), 4)
|
||||
^
|
||||
one error found
|
|
@ -1,3 +0,0 @@
|
|||
object Test {
|
||||
val (a: List[_], b) = (List(1 ,2 ,3 ), 4)
|
||||
}
|
|
@ -5,6 +5,8 @@ class C {
|
|||
def get:Foo = new Foo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
object Test {
|
||||
def main(args:Array[String]) = {
|
||||
val c = new C().get;
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
bug648.scala:7: error: value newAcc escapes its defining scope as part of type newAcc.type
|
||||
List[Symbol]() map { sym =>
|
||||
^
|
||||
one error found
|
|
@ -1,14 +0,0 @@
|
|||
import scala.tools.nsc.transform.Transform
|
||||
|
||||
abstract class Detach extends Transform {
|
||||
import global._
|
||||
class DetachTransformer extends Transformer {
|
||||
def foo: Scope = newScope(
|
||||
List[Symbol]() map { sym =>
|
||||
val newAcc = sym.cloneSymbol
|
||||
// def setFlag(mask: long): this.type
|
||||
newAcc.setFlag(0)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
bug752.scala:6: error: type mismatch;
|
||||
found : (String) => Unit
|
||||
required: (Int) => Unit
|
||||
f(&g)
|
||||
^
|
||||
f(g _)
|
||||
^
|
||||
one error found
|
||||
|
|
|
@ -3,6 +3,6 @@ object Test
|
|||
def f(x : Int => Unit) : Unit = ()
|
||||
def g(x : String) : Unit = ()
|
||||
def main(argv : Array[String]) = {
|
||||
f(&g)
|
||||
f(g _)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ object Main extends Application {
|
|||
Console.println("outer: " + Global.this);
|
||||
}
|
||||
}
|
||||
trait Contexts requires Analyzer {
|
||||
trait Contexts { self: Analyzer =>
|
||||
val xxx : global.Template = {
|
||||
assert(globalInit0 != null);
|
||||
globalInit0.Template(10, 20);
|
||||
|
|
|
@ -11,6 +11,6 @@ object Test extends Application {
|
|||
if (a != null) f(a) else null;
|
||||
|
||||
val bob : Bob = null;
|
||||
val bar = ifn(bob)(.bar);
|
||||
val bar = ifn(bob)(_.bar);
|
||||
assert(bar == null);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ trait Test {
|
|||
def ifn[A,B](a : A)(f : A => B): B =
|
||||
if (a != null) f(a) else null
|
||||
val bob : Bob = null;
|
||||
val bar = ifn(bob)(.bar);
|
||||
val bar = ifn(bob)(_.bar);
|
||||
assert(bar == null);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class A {}
|
||||
|
||||
trait B[T <: B[T]] requires T {}
|
||||
trait B[T <: B[T]] { self: T => }
|
||||
|
||||
abstract class C extends A with B[C]
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue