1. added take, drop, takeWhile, dropWhile to Arrays.
2. some new tests. 3. split Type.symbol to typeSymbol/termSymbol 4. some fixes to lub opertation git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@12285 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
0dc5bc0283
commit
843f5bd405
|
@ -648,7 +648,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
|
|||
}
|
||||
}
|
||||
val sym = getSym(name, module)
|
||||
inform("" + sym.name + ":" +(if (module) sym.tpe.symbol.info else sym.info))
|
||||
inform("" + sym.name + ":" +(if (module) sym.tpe.typeSymbol.info else sym.info))
|
||||
}
|
||||
|
||||
/** Returns the file with the given suffix for the given class. */
|
||||
|
|
|
@ -88,7 +88,8 @@ abstract class NodePrinters {
|
|||
}
|
||||
buf.append(", tpe=" + tree.tpe)
|
||||
if (tree.tpe != null) {
|
||||
val sym = tree.tpe.symbol
|
||||
var sym = tree.tpe.termSymbol
|
||||
if (sym == NoSymbol) sym = tree.tpe.typeSymbol
|
||||
buf.append(", tpe.sym=" + sym)
|
||||
if (sym != NoSymbol) {
|
||||
buf.append(", tpe.sym.owner=" + sym.owner)
|
||||
|
@ -208,7 +209,7 @@ abstract class NodePrinters {
|
|||
printcln("Super(\"" + qual + "\", \"" + mix + "\")" + nodeinfo2(tree))
|
||||
case Template(parents, self, body) =>
|
||||
println("Template(" + nodeinfo(tree))
|
||||
println(" " + parents.map(p => p.tpe.symbol) + ", // parents")
|
||||
println(" " + parents.map(p => p.tpe.typeSymbol) + ", // parents")
|
||||
if (body.isEmpty)
|
||||
println(" List() // no body")
|
||||
else {
|
||||
|
|
|
@ -213,7 +213,7 @@ abstract class TreeGen {
|
|||
DefDef(accessor, vparamss =>
|
||||
mkCached(mvar,
|
||||
New(TypeTree(mvar.tpe),
|
||||
List(for (pt <- mvar.tpe.symbol.primaryConstructor.info.paramTypes)
|
||||
List(for (pt <- mvar.tpe.typeSymbol.primaryConstructor.info.paramTypes)
|
||||
yield This(accessor.owner.enclClass)))))
|
||||
|
||||
// def m: T;
|
||||
|
|
|
@ -215,7 +215,7 @@ abstract class TreeInfo {
|
|||
|
||||
private def isSimpleThrowable(tp: Type): boolean = tp match {
|
||||
case TypeRef(pre, sym, args) =>
|
||||
(pre == NoPrefix || pre.widen.symbol.isStatic) &&
|
||||
(pre == NoPrefix || pre.widen.typeSymbol.isStatic) &&
|
||||
(sym isNonBottomSubClass definitions.ThrowableClass)
|
||||
case _ =>
|
||||
false
|
||||
|
|
|
@ -303,8 +303,8 @@ abstract class TreePrinters {
|
|||
print(
|
||||
if (tree.tpe eq null)
|
||||
"<type ?>"
|
||||
else if ((tree.tpe.symbol ne null) && tree.tpe.symbol.isAnonymousClass)
|
||||
tree.tpe.symbol.toString()
|
||||
else if ((tree.tpe.typeSymbol ne null) && tree.tpe.typeSymbol.isAnonymousClass)
|
||||
tree.tpe.typeSymbol.toString()
|
||||
else
|
||||
tree.tpe.toString()
|
||||
)
|
||||
|
|
|
@ -465,7 +465,7 @@ abstract class Inliners extends SubComponent {
|
|||
log("shouldInline: score decreased to " + score + " because small " + caller + " would become large")
|
||||
}
|
||||
|
||||
if (callee.symbol.tpe.paramTypes.exists(t => definitions.FunctionClass.contains(t.symbol))) {
|
||||
if (callee.symbol.tpe.paramTypes.exists(t => definitions.FunctionClass.contains(t.typeSymbol))) {
|
||||
if (settings.debug.value)
|
||||
log("increased score to: " + score)
|
||||
score = score + 2
|
||||
|
|
|
@ -59,15 +59,15 @@ trait ParallelMatching {
|
|||
|
||||
// true if pattern type is direct subtype of scrutinee (can't use just <:< cause have to take variance into account)
|
||||
def directSubtype(ptpe:Type) =
|
||||
(ptpe.parents.exists { x => ((x.symbol eq scrutinee.tpe.symbol) && (x <:< scrutinee.tpe))});
|
||||
(ptpe.parents.exists { x => ((x.typeSymbol eq scrutinee.tpe.typeSymbol) && (x <:< scrutinee.tpe))});
|
||||
|
||||
// true if each pattern type is case and direct subtype of scrutinee
|
||||
def isFlatCases(col:List[Tree]): Boolean = (col eq Nil) || {
|
||||
strip2(col.head) match {
|
||||
case a @ Apply(fn,_) =>
|
||||
((a.tpe.symbol.flags & symtab.Flags.CASE) != 0) && directSubtype( a.tpe ) && isFlatCases(col.tail)
|
||||
((a.tpe.typeSymbol.flags & symtab.Flags.CASE) != 0) && directSubtype( a.tpe ) && isFlatCases(col.tail)
|
||||
case t @ Typed(_,tpt) =>
|
||||
( (tpt.tpe.symbol.flags & symtab.Flags.CASE) != 0) && directSubtype( t.tpe ) && isFlatCases(col.tail)
|
||||
( (tpt.tpe.typeSymbol.flags & symtab.Flags.CASE) != 0) && directSubtype( t.tpe ) && isFlatCases(col.tail)
|
||||
case Ident(nme.WILDCARD) =>
|
||||
isFlatCases(col.tail) // treat col.tail specially?
|
||||
case i @ Ident(n) => // n ne nme.WILDCARD
|
||||
|
@ -205,7 +205,7 @@ trait ParallelMatching {
|
|||
if(isDefaultPattern(p))
|
||||
insertDefault(i,strip1(xs.head))
|
||||
else
|
||||
insertTagIndexPair(p.tpe.symbol.tag, i)
|
||||
insertTagIndexPair(p.tpe.typeSymbol.tag, i)
|
||||
i = i + 1
|
||||
xs = xs.tail
|
||||
}
|
||||
|
@ -399,10 +399,10 @@ trait ParallelMatching {
|
|||
var subsumed: List[(Int,List[Tree])] = Nil // row index and subpatterns
|
||||
var remaining: List[(Int,Tree)] = Nil // row index and pattern
|
||||
|
||||
val isExhaustive = !scrutinee.tpe.symbol.hasFlag(symtab.Flags.SEALED) || {
|
||||
val isExhaustive = !scrutinee.tpe.typeSymbol.hasFlag(symtab.Flags.SEALED) || {
|
||||
//DEBUG("check exha for column "+column)
|
||||
val tpes = column.map {x => /*Console.println("--x:"+x+":"+x.tpe); */ x.tpe.symbol}
|
||||
scrutinee.tpe.symbol.children.forall { sym => tpes.contains(sym) }
|
||||
val tpes = column.map {x => /*Console.println("--x:"+x+":"+x.tpe); */ x.tpe.typeSymbol}
|
||||
scrutinee.tpe.typeSymbol.children.forall { sym => tpes.contains(sym) }
|
||||
}
|
||||
|
||||
private val patternType = column.head match {
|
||||
|
@ -411,8 +411,8 @@ trait ParallelMatching {
|
|||
//case p@Apply(_,_) if !p.tpe.symbol.hasFlag(symtab.Flags.CASE) => ConstantType(new NamedConstant(p))
|
||||
case _ => column.head.tpe
|
||||
}
|
||||
private val isCaseHead = patternType.symbol.hasFlag(symtab.Flags.CASE)
|
||||
private val dummies = if(!isCaseHead) Nil else patternType.symbol.caseFieldAccessors.map { x => EmptyTree }
|
||||
private val isCaseHead = patternType.typeSymbol.hasFlag(symtab.Flags.CASE)
|
||||
private val dummies = if(!isCaseHead) Nil else patternType.typeSymbol.caseFieldAccessors.map { x => EmptyTree }
|
||||
|
||||
//Console.println("isCaseHead = "+isCaseHead)
|
||||
//Console.println("dummies = "+dummies)
|
||||
|
@ -423,7 +423,7 @@ trait ParallelMatching {
|
|||
pat match {
|
||||
case Bind(_,p) =>
|
||||
subpatterns(p)
|
||||
case app @ Apply(fn, pats) if app.tpe.symbol.hasFlag(symtab.Flags.CASE) && (fn.symbol eq null)=>
|
||||
case app @ Apply(fn, pats) if app.tpe.typeSymbol.hasFlag(symtab.Flags.CASE) && (fn.symbol eq null)=>
|
||||
pats
|
||||
case Apply(fn,xs) => assert((xs.isEmpty) && (fn.symbol ne null)); dummies // named constant
|
||||
case _: UnApply =>
|
||||
|
@ -518,7 +518,7 @@ trait ParallelMatching {
|
|||
val nmatrix = {
|
||||
//Console.println("casted:"+casted)
|
||||
//Console.println("casted.case:"+casted.tpe.symbol.hasFlag(symtab.Flags.CASE))
|
||||
var ntemps = if(casted.tpe.symbol.hasFlag(symtab.Flags.CASE)) casted.caseFieldAccessors map {
|
||||
var ntemps = if(casted.tpe.typeSymbol.hasFlag(symtab.Flags.CASE)) casted.caseFieldAccessors map {
|
||||
meth =>
|
||||
val ctemp = newVar(scrutinee.pos, casted.tpe.memberType(meth).resultType)
|
||||
if(scrutinee.hasFlag(symtab.Flags.CAPTURED))
|
||||
|
@ -663,7 +663,7 @@ trait ParallelMatching {
|
|||
{
|
||||
val pat = mc.column(mc.tagIndexPairs.find(tag));
|
||||
val ptpe = pat.tpe
|
||||
if(mc.scrutinee.tpe.symbol.hasFlag(symtab.Flags.SEALED) && strip2(pat).isInstanceOf[Apply]) {
|
||||
if(mc.scrutinee.tpe.typeSymbol.hasFlag(symtab.Flags.SEALED) && strip2(pat).isInstanceOf[Apply]) {
|
||||
//cast
|
||||
val vtmp = newVar(pat.pos, ptpe)
|
||||
squeezedBlock(
|
||||
|
@ -677,7 +677,7 @@ trait ParallelMatching {
|
|||
renamingBind(defaultV, mc.scrutinee, ndefault) // each v in defaultV gets bound to scrutinee
|
||||
|
||||
// make first case a default case.
|
||||
if(mc.scrutinee.tpe.symbol.hasFlag(symtab.Flags.SEALED) && defaultV.isEmpty) {
|
||||
if(mc.scrutinee.tpe.typeSymbol.hasFlag(symtab.Flags.SEALED) && defaultV.isEmpty) {
|
||||
ndefault = genBody(Nil, cases.head.body)
|
||||
cases = cases.tail
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ trait ParallelMatching {
|
|||
//Console.println("getTransition"+(uacall,vdefs,srep,frep))
|
||||
val succ = repToTree(srep, handleOuter)
|
||||
val fail = if(frep.isEmpty) failTree else repToTree(frep.get, handleOuter)
|
||||
val cond = if(uacall.symbol.tpe.symbol eq definitions.BooleanClass)
|
||||
val cond = if(uacall.symbol.tpe.typeSymbol eq definitions.BooleanClass)
|
||||
typed{ Ident(uacall.symbol) }
|
||||
else
|
||||
emptynessCheck(uacall.symbol)
|
||||
|
|
|
@ -259,7 +259,7 @@ trait PatternNodes { self: transform.ExplicitOuter =>
|
|||
else
|
||||
sb
|
||||
case ConstrPat(casted) =>
|
||||
val s = ("-- " + patNode.tpe.symbol.name +
|
||||
val s = ("-- " + patNode.tpe.typeSymbol.name +
|
||||
"(" + patNode.tpe + ", " + casted + ") -> ")
|
||||
val nindent = newIndent(s)
|
||||
sb.append(nindent + s).append('\n')
|
||||
|
@ -267,7 +267,7 @@ trait PatternNodes { self: transform.ExplicitOuter =>
|
|||
cont
|
||||
|
||||
case SequencePat( casted, plen ) =>
|
||||
val s = ("-- " + patNode.tpe.symbol.name + "(" +
|
||||
val s = ("-- " + patNode.tpe.typeSymbol.name + "(" +
|
||||
patNode.tpe +
|
||||
", " + casted + ", " + plen + ") -> ")
|
||||
val nindent = newIndent(s)
|
||||
|
@ -276,7 +276,7 @@ trait PatternNodes { self: transform.ExplicitOuter =>
|
|||
cont
|
||||
|
||||
case RightIgnoringSequencePat( casted, castedRest, plen ) =>
|
||||
val s = ("-- ri " + patNode.tpe.symbol.name + "(" +
|
||||
val s = ("-- ri " + patNode.tpe.typeSymbol.name + "(" +
|
||||
patNode.tpe +
|
||||
", " + casted + ", " + plen + ") -> ")
|
||||
val nindent = newIndent(s)
|
||||
|
@ -383,17 +383,17 @@ trait PatternNodes { self: transform.ExplicitOuter =>
|
|||
//Console.println("optimize1("+selType+","+alternatives1+")")
|
||||
var res = true
|
||||
var coveredCases: SymSet = emptySymbolSet
|
||||
var remainingCases = checkExCoverage(selType.symbol)
|
||||
var remainingCases = checkExCoverage(selType.typeSymbol)
|
||||
var cases = 0;
|
||||
|
||||
def traverse(alts:PatternNode) {
|
||||
//Console.println("traverse, alts="+alts)
|
||||
alts match {
|
||||
case ConstrPat(_) =>
|
||||
//Console.print("ConstPat! of"+alts.tpe.symbol)
|
||||
if (alts.tpe.symbol.hasFlag(Flags.CASE)) {
|
||||
coveredCases = coveredCases + alts.tpe.symbol
|
||||
remainingCases = remainingCases - alts.tpe.symbol
|
||||
//Console.print("ConstPat! of"+alts.tpe.typeSymbol)
|
||||
if (alts.tpe.typeSymbol.hasFlag(Flags.CASE)) {
|
||||
coveredCases = coveredCases + alts.tpe.typeSymbol
|
||||
remainingCases = remainingCases - alts.tpe.typeSymbol
|
||||
cases = cases + 1
|
||||
} else {
|
||||
val covered = remainingCases.filter { x =>
|
||||
|
@ -410,11 +410,11 @@ trait PatternNodes { self: transform.ExplicitOuter =>
|
|||
}
|
||||
|
||||
// Nil is also a "constructor pattern" somehow
|
||||
case VariablePat(tree) if (tree.tpe.symbol.hasFlag(Flags.MODULE)) => // Nil
|
||||
coveredCases = coveredCases + tree.tpe.symbol
|
||||
remainingCases = remainingCases - tree.tpe.symbol
|
||||
case VariablePat(tree) if (tree.tpe.typeSymbol.hasFlag(Flags.MODULE)) => // Nil
|
||||
coveredCases = coveredCases + tree.tpe.typeSymbol
|
||||
remainingCases = remainingCases - tree.tpe.typeSymbol
|
||||
cases = cases + 1
|
||||
res = res && tree.tpe.symbol.hasFlag(Flags.CASE)
|
||||
res = res && tree.tpe.typeSymbol.hasFlag(Flags.CASE)
|
||||
case DefaultPat() =>
|
||||
if(andIsUnguardedBody(alts) || alts.and.isInstanceOf[Header]) {
|
||||
coveredCases = emptySymbolSet
|
||||
|
|
|
@ -92,7 +92,7 @@ trait TransMatcher { self: transform.ExplicitOuter =>
|
|||
// Console.print("isSeqApply? "+tree.toString());
|
||||
// val res =
|
||||
tree match {
|
||||
case Apply(_, List(ArrayValue(_,_))) => (tree.tpe.symbol.flags & Flags.CASE) == 0
|
||||
case Apply(_, List(ArrayValue(_,_))) => (tree.tpe.typeSymbol.flags & Flags.CASE) == 0
|
||||
case _ => false;
|
||||
}
|
||||
//Console.println(res);
|
||||
|
@ -247,7 +247,7 @@ trait TransMatcher { self: transform.ExplicitOuter =>
|
|||
pat
|
||||
|
||||
case This(_) => // Sean's feature request #1134, compiled incorrectly
|
||||
val stpe = mkThisType(pat.tpe.symbol)
|
||||
val stpe = mkThisType(pat.tpe.typeSymbol)
|
||||
Typed(Ident(nme.WILDCARD) setType stpe, TypeTree(stpe))
|
||||
|
||||
//case _ =>
|
||||
|
|
|
@ -294,7 +294,7 @@ class SemanticTokens(val compiler: Global) {
|
|||
def buildT( tree : Tree, tpe : Type) : Unit = if (tree.pos != NoPosition) tpe match {
|
||||
case tpe0 : TypeRef => tree match {
|
||||
case apt : AppliedTypeTree =>
|
||||
buildUse(tpe.symbol, apt.tpt.pos.offset.get(-1), tpe0);
|
||||
buildUse(tpe.typeSymbol, apt.tpt.pos.offset.get(-1), tpe0);
|
||||
//Console.err.println("APT: " + treex + " vs. " + treex.original);
|
||||
//Console.err.println("APT: " + treex.pos + " vs. " + treex.original.pos + " " + unit.source.dbg(treex.original.pos));
|
||||
//Console.err.println("APT: " + apt.tpt + " sym0=" + apt.tpt.symbol + " sym1=" + tpe0.sym + " apt.args=" + apt.args + " tpe0.args=" + tpe0.args);
|
||||
|
@ -306,7 +306,7 @@ class SemanticTokens(val compiler: Global) {
|
|||
if (false) Console.err.println("BUILD_SELECT: " + select + " @ " + tpe0 + " SYM=" + select.symbol + " " + (select.pos).dbgString);
|
||||
try {
|
||||
// build(select);
|
||||
buildUse(tpe0.symbol, selectPos(select), tpe0);
|
||||
buildUse(tpe0.typeSymbol, selectPos(select), tpe0);
|
||||
//Console.err.println("QUALIFIER: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString);
|
||||
buildT(select.qualifier, tpe0.prefix);
|
||||
} catch {
|
||||
|
@ -318,18 +318,18 @@ class SemanticTokens(val compiler: Global) {
|
|||
if (tpt.symbol ne null) {
|
||||
Console.err.println("SYM0 " + tpt.symbol + " " + (tpt.pos).dbgString);
|
||||
buildUse(tpt.symbol, tpt.pos.offset.get(-1), tpe0);
|
||||
} else if (tpe0.symbol ne null) {
|
||||
} else if (tpe0.typeSymbol ne null) {
|
||||
//Console.err.println("TYPE_SYM1 " + tpe0.symbol + " " + unit.source.dbg(tpt.pos));
|
||||
buildUse(tpe0.symbol, tpt.pos.offset.get(-1), tpe0);
|
||||
buildUse(tpe0.typeSymbol, tpt.pos.offset.get(-1), tpe0);
|
||||
} else {
|
||||
Console.err.println("UNKNOWN TPT0: " + (tpt.pos).dbgString + " tpt=" + tpt + " " + tpt.symbol + " tpe0="+ tpe0 + " " + tpe0.symbol + " tpe0.args=" + tpe0.args);
|
||||
Console.err.println("UNKNOWN TPT0: " + (tpt.pos).dbgString + " tpt=" + tpt + " " + tpt.symbol + " tpe0="+ tpe0 + " " + tpe0.typeSymbol + " tpe0.args=" + tpe0.args);
|
||||
}
|
||||
case sft : SelectFromTypeTree =>
|
||||
build(sft.qualifier); // XXX: broken
|
||||
if (false) Console.err.println("SFTT: " + sft + " sym=" + sft.symbol + " selector=" + sft.selector + " qual=" + sft.qualifier + " qual.sym=" +
|
||||
sft.qualifier.symbol +
|
||||
" qual.pos=" + (sft.qualifier.pos).dbgString + " symbol=" + sft.symbol + " type=" + tpe0 +
|
||||
" type.sym=" + tpe0.symbol);
|
||||
" type.sym=" + tpe0.typeSymbol);
|
||||
case _ => Console.err.println("UNKNOWN TPT2: " + tree + " vs. " + tpe0 + " " + tree.getClass() + " " + (tree.pos).dbgString);
|
||||
}
|
||||
case tpe0 : MethodType => tree match {
|
||||
|
@ -368,7 +368,7 @@ class SemanticTokens(val compiler: Global) {
|
|||
case tpe0 : SingleType => tree match {
|
||||
case ident : Ident => buildUse(tpe0.sym, ident.pos.offset.get(-1), tpe0);
|
||||
case select : Select =>
|
||||
buildUse(tpe0.symbol, selectPos(select), tpe0);
|
||||
buildUse(tpe0.termSymbol, selectPos(select), tpe0);
|
||||
//Console.err.println("QUALIFIER-0: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString);
|
||||
buildT(select.qualifier, tpe0.prefix);
|
||||
|
||||
|
|
|
@ -166,8 +166,8 @@ trait Constants {
|
|||
* @return ...
|
||||
*/
|
||||
def convertTo(pt: Type): Constant = {
|
||||
val target = pt.symbol
|
||||
if (target == tpe.symbol)
|
||||
val target = pt.typeSymbol
|
||||
if (target == tpe.typeSymbol)
|
||||
this
|
||||
else if (target == ByteClass && ByteTag <= tag && tag <= IntTag &&
|
||||
-128 <= intValue && intValue <= 127)
|
||||
|
|
|
@ -32,7 +32,7 @@ trait Definitions {
|
|||
|
||||
lazy val JavaLangPackage: Symbol = getModule(if (forMSIL) "System" else "java.lang")
|
||||
lazy val ScalaPackage: Symbol = getModule("scala")
|
||||
lazy val ScalaPackageClass: Symbol = ScalaPackage.tpe.symbol
|
||||
lazy val ScalaPackageClass: Symbol = ScalaPackage.tpe.typeSymbol
|
||||
|
||||
var AnyClass: Symbol = _
|
||||
var AnyValClass: Symbol = _
|
||||
|
@ -216,7 +216,7 @@ trait Definitions {
|
|||
/** returns type list for return type of the extraction */
|
||||
def unapplyTypeList(ufn: Symbol, ufntpe: Type) = {
|
||||
assert(ufn.isMethod)
|
||||
//Console.println("utl "+ufntpe+" "+ufntpe.symbol)
|
||||
//Console.println("utl "+ufntpe+" "+ufntpe.typeSymbol)
|
||||
ufn.name match {
|
||||
case nme.unapply => unapplyTypeListFromReturnType(ufntpe)
|
||||
case nme.unapplySeq => unapplyTypeListFromReturnTypeSeq(ufntpe)
|
||||
|
@ -234,7 +234,7 @@ trait Definitions {
|
|||
val B = BooleanClass
|
||||
val O = OptionClass
|
||||
val S = SomeClass
|
||||
tp.symbol match { // unapplySeqResultToMethodSig
|
||||
tp.typeSymbol match { // unapplySeqResultToMethodSig
|
||||
case B => Nil
|
||||
case O | S =>
|
||||
val prod = tp.typeArgs.head
|
||||
|
@ -242,7 +242,7 @@ trait Definitions {
|
|||
case Some(all @ (x1::x2::xs)) => all // n >= 2
|
||||
case _ => prod::Nil // special n == 0 || n == 1
|
||||
}
|
||||
case _ => throw new IllegalArgumentException(tp.symbol + " in not in {boolean, option, some}")
|
||||
case _ => throw new IllegalArgumentException(tp.typeSymbol + " in not in {boolean, option, some}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ trait Definitions {
|
|||
*/
|
||||
def unapplyTypeListFromReturnTypeSeq(tp1: Type): List[Type] = {
|
||||
val tp = unapplyUnwrap(tp1)
|
||||
val O = OptionClass; val S = SomeClass; tp.symbol match {
|
||||
val O = OptionClass; val S = SomeClass; tp.typeSymbol match {
|
||||
case O | S =>
|
||||
val ts = unapplyTypeListFromReturnType(tp1)
|
||||
val last1 = ts.last.baseType(SeqClass) match {
|
||||
|
@ -261,7 +261,7 @@ trait Definitions {
|
|||
case _ => throw new IllegalArgumentException("last not seq")
|
||||
}
|
||||
ts.init ::: List(last1)
|
||||
case _ => throw new IllegalArgumentException(tp.symbol + " in not in {option, some}")
|
||||
case _ => throw new IllegalArgumentException(tp.typeSymbol + " in not in {option, some}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ trait Definitions {
|
|||
|
||||
def isUnbox(m: Symbol) = m.name == nme.unbox && {
|
||||
m.tpe match {
|
||||
case MethodType(_, restpe) => (unboxMethod get restpe.symbol) match {
|
||||
case MethodType(_, restpe) => (unboxMethod get restpe.typeSymbol) match {
|
||||
case Some(`m`) => true
|
||||
case _ => false
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ trait Definitions {
|
|||
/** Test whether a method symbol is that of a boxing method. */
|
||||
def isBox(m: Symbol) = (boxMethod.values contains m) && {
|
||||
m.tpe match {
|
||||
case MethodType(List(argtpe), _) => (boxMethod get argtpe.symbol) match {
|
||||
case MethodType(List(argtpe), _) => (boxMethod get argtpe.typeSymbol) match {
|
||||
case Some(`m`) => true
|
||||
case _ => false
|
||||
}
|
||||
|
@ -719,13 +719,13 @@ trait Definitions {
|
|||
if (sym.owner.isPackageClass) sym.fullNameString('.')
|
||||
else flatNameString(sym.owner, separator) + "$" + sym.simpleName;
|
||||
def signature1(etp: Type): String = {
|
||||
if (etp.symbol == ArrayClass) "[" + signature1(erasure(etp.normalize.typeArgs.head))
|
||||
else if (isValueClass(etp.symbol)) abbrvTag(etp.symbol).toString()
|
||||
else "L" + flatNameString(etp.symbol, '/') + ";"
|
||||
if (etp.typeSymbol == ArrayClass) "[" + signature1(erasure(etp.normalize.typeArgs.head))
|
||||
else if (isValueClass(etp.typeSymbol)) abbrvTag(etp.typeSymbol).toString()
|
||||
else "L" + flatNameString(etp.typeSymbol, '/') + ";"
|
||||
}
|
||||
val etp = erasure(tp)
|
||||
if (etp.symbol == ArrayClass) signature1(etp)
|
||||
else flatNameString(etp.symbol, '.')
|
||||
if (etp.typeSymbol == ArrayClass) signature1(etp)
|
||||
else flatNameString(etp.typeSymbol, '.')
|
||||
}
|
||||
|
||||
private var isInitialized = false
|
||||
|
|
|
@ -225,7 +225,7 @@ trait Symbols {
|
|||
final def isScalaPackageClass = isPackageClass && name == nme.scala_.toTypeName // not printed as a prefix
|
||||
|
||||
def isDeprecated =
|
||||
attributes exists (attr => attr.atp.symbol == DeprecatedAttr)
|
||||
attributes exists (attr => attr.atp.typeSymbol == DeprecatedAttr)
|
||||
|
||||
/** Does this symbol denote a wrapper object of the interpreter or its class? */
|
||||
final def isInterpreterWrapper =
|
||||
|
@ -406,14 +406,25 @@ trait Symbols {
|
|||
final def hasFlag(mask: Long): Boolean = (flags & mask) != 0
|
||||
final def resetFlags { rawflags = rawflags & TopLevelCreationFlags }
|
||||
|
||||
/** The class up to which this symbol is accessible,
|
||||
* or NoSymbol if it is public or not a class member
|
||||
/** The class or term up to which this symbol is accessible,
|
||||
* or RootClass if it is public
|
||||
*/
|
||||
final def accessBoundary(base: Symbol): Symbol = {
|
||||
if (hasFlag(PRIVATE)) owner
|
||||
def accessBoundary(base: Symbol): Symbol = {
|
||||
if (hasFlag(PRIVATE) || owner.isTerm) owner
|
||||
else if (privateWithin != NoSymbol && !phase.erasedTypes) privateWithin
|
||||
else if (hasFlag(PROTECTED)) base
|
||||
else NoSymbol
|
||||
else RootClass
|
||||
}
|
||||
|
||||
def isLessAccessibleThan(other: Symbol): Boolean = {
|
||||
val tb = this.accessBoundary(owner)
|
||||
val ob1 = other.accessBoundary(owner)
|
||||
val ob2 = ob1.linkedClassOfClass
|
||||
var o = tb
|
||||
while (o != NoSymbol && o != ob1 && o != ob2) {
|
||||
o = o.owner
|
||||
}
|
||||
o != NoSymbol && o != tb
|
||||
}
|
||||
|
||||
// Info and Type -------------------------------------------------------------------
|
||||
|
@ -586,7 +597,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.typeSymbol.isNonBottomSubClass(clazz))
|
||||
|
||||
/** Reset symbol to initial state
|
||||
*/
|
||||
|
@ -747,7 +758,7 @@ trait Symbols {
|
|||
def outerSource: Symbol = NoSymbol
|
||||
|
||||
/** The superclass of this class */
|
||||
def superClass: Symbol = if (info.parents.isEmpty) NoSymbol else info.parents.head.symbol
|
||||
def superClass: Symbol = if (info.parents.isEmpty) NoSymbol else info.parents.head.typeSymbol
|
||||
|
||||
/** The directly or indirectly inherited mixins of this class
|
||||
* except for mixin classes inherited by the superclass. Mixin classes appear
|
||||
|
@ -808,7 +819,7 @@ trait Symbols {
|
|||
val result =
|
||||
if (phase.next.erasedTypes) {
|
||||
assert(!tpe.parents.isEmpty, this)
|
||||
tpe.parents.last.symbol
|
||||
tpe.parents.last.typeSymbol
|
||||
} else {
|
||||
owner.info.decl(nme.interfaceName(name))
|
||||
}
|
||||
|
@ -1068,8 +1079,8 @@ trait Symbols {
|
|||
typeParamsString + {
|
||||
tp.resultType match {
|
||||
case TypeBounds(lo, hi) =>
|
||||
(if (lo.symbol == AllClass) "" else " >: " + lo) +
|
||||
(if (hi.symbol == AnyClass) "" else " <: " + hi)
|
||||
(if (lo.typeSymbol == AllClass) "" else " >: " + lo) +
|
||||
(if (hi.typeSymbol == AnyClass) "" else " <: " + hi)
|
||||
case rtp =>
|
||||
"<: " + rtp
|
||||
}
|
||||
|
@ -1405,11 +1416,10 @@ trait Symbols {
|
|||
override def reset(completer: Type) {}
|
||||
override def info: Type = NoType
|
||||
override def rawInfo: Type = NoType
|
||||
override def accessBoundary(base: Symbol): Symbol = RootClass
|
||||
def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error()
|
||||
}
|
||||
|
||||
|
||||
|
||||
def cloneSymbols(syms: List[Symbol]): List[Symbol] = {
|
||||
val syms1 = syms map (_.cloneSymbol)
|
||||
for (sym1 <- syms1) sym1.setInfo(sym1.info.substSym(syms, syms1))
|
||||
|
|
|
@ -103,7 +103,9 @@ trait Types {
|
|||
override def isError = tp.isError
|
||||
override def isErroneous = tp.isErroneous
|
||||
override def isStable: Boolean = tp.isStable
|
||||
override def symbol = tp.symbol
|
||||
override def termSymbol = tp.termSymbol
|
||||
override def typeSymbol = tp.typeSymbol
|
||||
@deprecated override def symbol = tp.symbol
|
||||
override def singleDeref = maybeRewrap(tp.singleDeref)
|
||||
override def widen = maybeRewrap(tp.widen)
|
||||
override def deconst = maybeRewrap(tp.deconst)
|
||||
|
@ -163,10 +165,17 @@ trait Types {
|
|||
IsDependentTraverser.result
|
||||
}
|
||||
|
||||
/** The symbol associated with the type
|
||||
@deprecated def symbol: Symbol = NoSymbol
|
||||
|
||||
/** The term symbol associated with the type
|
||||
* Note that the symbol of the normalized type is returned (@see normalize)
|
||||
*/
|
||||
def symbol: Symbol = NoSymbol
|
||||
def termSymbol: Symbol = NoSymbol
|
||||
|
||||
/** The type symbol associated with the type
|
||||
* Note that the symbol of the normalized type is returned (@see normalize)
|
||||
*/
|
||||
def typeSymbol: Symbol = NoSymbol
|
||||
|
||||
/** The base type underlying a singleton type,
|
||||
* identity on all other types */
|
||||
|
@ -183,7 +192,7 @@ trait Types {
|
|||
|
||||
/** The type of `this' of a class type or reference type
|
||||
*/
|
||||
def typeOfThis: Type = symbol.typeOfThis
|
||||
def typeOfThis: Type = typeSymbol.typeOfThis
|
||||
|
||||
/** Map to a this type which is a subtype of this type.
|
||||
*/
|
||||
|
@ -249,7 +258,7 @@ trait Types {
|
|||
def normalize = this // @MAT
|
||||
|
||||
/** Is this type produced as a repair for an error? */
|
||||
def isError: Boolean = symbol.isError
|
||||
def isError: Boolean = typeSymbol.isError || termSymbol.isError
|
||||
|
||||
/** Is this type produced as a repair for an error? */
|
||||
def isErroneous: Boolean = {
|
||||
|
@ -318,7 +327,7 @@ trait Types {
|
|||
* Proceed analogously for thistypes referring to outer classes.
|
||||
*/
|
||||
def asSeenFrom(pre: Type, clazz: Symbol): Type =
|
||||
if (!isTrivial && (!phase.erasedTypes || pre.symbol == ArrayClass)) {
|
||||
if (!isTrivial && (!phase.erasedTypes || pre.typeSymbol == ArrayClass)) {
|
||||
val m = new AsSeenFromMap(pre, clazz)
|
||||
val tp = m apply this
|
||||
existentialAbstraction(m.capturedParams, tp)
|
||||
|
@ -479,7 +488,7 @@ trait Types {
|
|||
var hi = cl.length - 1
|
||||
while (lo <= hi) {
|
||||
val mid = (lo + hi) / 2
|
||||
val clsym = cl(mid).symbol
|
||||
val clsym = cl(mid).typeSymbol
|
||||
if (sym == clsym) return mid
|
||||
else if (sym isLess clsym) hi = mid - 1
|
||||
else if (clsym isLess sym) lo = mid + 1
|
||||
|
@ -550,7 +559,7 @@ trait Types {
|
|||
*/
|
||||
//TODO: use narrow only for modules? (correct? efficiency gain?)
|
||||
def findMember(name: Name, excludedFlags: Int, requiredFlags: Long, stableOnly: Boolean): Symbol = {
|
||||
if (inIDE) trackTypeIDE(symbol)
|
||||
if (inIDE) trackTypeIDE(typeSymbol)
|
||||
if (util.Statistics.enabled) findMemberCount = findMemberCount + 1
|
||||
val startTime = if (util.Statistics.enabled) currentTime else 0l
|
||||
|
||||
|
@ -625,7 +634,7 @@ trait Types {
|
|||
member
|
||||
} else {
|
||||
if (util.Statistics.enabled) multMemberCount = multMemberCount + 1;
|
||||
//val pre = if (this.symbol.isClass) this.symbol.thisType else this;
|
||||
//val pre = if (this.typeSymbol.isClass) this.typeSymbol.thisType else this;
|
||||
baseClasses.head.newOverloaded(this, members.toList)
|
||||
}
|
||||
}
|
||||
|
@ -678,6 +687,10 @@ trait Types {
|
|||
abstract class SingletonType extends SubType {
|
||||
override def singleDeref: Type
|
||||
def supertype: Type = singleDeref
|
||||
override def isNotNull = singleDeref.isNotNull
|
||||
override def isError = singleDeref.isError
|
||||
override def isErroneous = singleDeref.isErroneous
|
||||
override def typeSymbol = singleDeref.typeSymbol
|
||||
override def isStable: Boolean = true
|
||||
override def widen: Type = singleDeref.widen
|
||||
override def closure: Array[Type] = {
|
||||
|
@ -739,7 +752,8 @@ trait Types {
|
|||
//assert(sym.isClass && !sym.isModuleClass || sym.isRoot, sym)
|
||||
override def isTrivial: Boolean = sym.isPackageClass
|
||||
override def isNotNull = true
|
||||
override def symbol = sym
|
||||
override def typeSymbol = sym
|
||||
@deprecated override def symbol = sym
|
||||
override def singleDeref: Type = sym.typeOfThis
|
||||
override def prefixString =
|
||||
if (settings.debug.value) sym.nameString + ".this."
|
||||
|
@ -781,11 +795,16 @@ trait Types {
|
|||
}
|
||||
singleDerefCache
|
||||
}
|
||||
override def bounds = {
|
||||
val bs = singleDeref.bounds
|
||||
if (bs.lo eq bs.hi) super.bounds
|
||||
else bs
|
||||
}
|
||||
|
||||
override def narrow: Type = {
|
||||
if (phase.erasedTypes) this
|
||||
else {
|
||||
val thissym = refinedType(List(this), sym.owner, EmptyScope).symbol
|
||||
val thissym = refinedType(List(this), sym.owner, EmptyScope).typeSymbol
|
||||
if (sym.owner != NoSymbol) {
|
||||
//Console.println("narrowing module " + sym + thissym.owner);
|
||||
thissym.typeOfThis = this
|
||||
|
@ -794,7 +813,8 @@ trait Types {
|
|||
}
|
||||
}
|
||||
|
||||
override def symbol = sym
|
||||
override def termSymbol = sym
|
||||
@deprecated override def symbol = sym
|
||||
override def prefix: Type = pre
|
||||
override def prefixString: String =
|
||||
if ((sym.isEmptyPackage || sym.isInterpreterWrapper || sym.isPredefModule || sym.isScalaPackage) && !settings.debug.value) ""
|
||||
|
@ -804,7 +824,8 @@ trait Types {
|
|||
case class SuperType(thistpe: Type, supertp: Type) extends SingletonType {
|
||||
override val isTrivial: Boolean = thistpe.isTrivial && supertp.isTrivial
|
||||
override def isNotNull = true;
|
||||
override def symbol = thistpe.symbol
|
||||
override def typeSymbol = thistpe.typeSymbol
|
||||
@deprecated override def symbol = thistpe.symbol
|
||||
override def singleDeref = supertp
|
||||
override def prefix: Type = supertp.prefix
|
||||
override def prefixString =
|
||||
|
@ -840,9 +861,9 @@ trait Types {
|
|||
try {
|
||||
if (util.Statistics.enabled)
|
||||
compoundClosureCount = compoundClosureCount + 1
|
||||
//Console.println("computing closure of " + symbol.tpe + " " + parents)//DEBUG
|
||||
//Console.println("computing closure of " + typeSymbol.tpe + " " + parents)//DEBUG
|
||||
val buf = new ListBuffer[Type]
|
||||
buf += symbol.tpe
|
||||
buf += typeSymbol.tpe
|
||||
var clSize = 1
|
||||
val nparents = parents.length
|
||||
if (nparents != 0) {
|
||||
|
@ -862,18 +883,18 @@ trait Types {
|
|||
}
|
||||
var minSym: Symbol = NoSymbol
|
||||
while (minSym != AnyClass) {
|
||||
minSym = nextBaseType(0).symbol
|
||||
minSym = nextBaseType(0).typeSymbol
|
||||
i = 1
|
||||
while (i < nparents) {
|
||||
if (nextBaseType(i).symbol isLess minSym)
|
||||
minSym = nextBaseType(i).symbol
|
||||
if (nextBaseType(i).typeSymbol isLess minSym)
|
||||
minSym = nextBaseType(i).typeSymbol
|
||||
i += 1
|
||||
}
|
||||
var minTypes: List[Type] = List()
|
||||
i = 0
|
||||
while (i < nparents) {
|
||||
val tp = nextBaseType(i)
|
||||
if (tp.symbol == minSym) {
|
||||
if (tp.typeSymbol == minSym) {
|
||||
if (!(minTypes exists (tp =:=))) minTypes = tp :: minTypes;
|
||||
index(i) = index(i) + 1
|
||||
}
|
||||
|
@ -885,7 +906,7 @@ trait Types {
|
|||
}
|
||||
closureCache = new Array[Type](clSize)
|
||||
buf.copyToArray(closureCache, 0)
|
||||
//Console.println("closureCache of " + symbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
|
||||
//Console.println("closureCache of " + typeSymbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
|
||||
var j = 0
|
||||
while (j < clSize) {
|
||||
closureCache(j) match {
|
||||
|
@ -901,7 +922,7 @@ trait Types {
|
|||
}
|
||||
j = j + 1
|
||||
}
|
||||
//Console.println("closure of " + symbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
|
||||
//Console.println("closure of " + typeSymbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
|
||||
closureCache
|
||||
} catch {
|
||||
case ex: MalformedClosure =>
|
||||
|
@ -914,24 +935,24 @@ trait Types {
|
|||
closurePeriod = currentPeriod
|
||||
if (!isValidForBaseClasses(period)) {
|
||||
closureCache = null
|
||||
closureCache = memo[Array[Type], Type](computeClosure, modifyClosure(symbol.tpe))
|
||||
closureCache = memo[Array[Type], Type](computeClosure, modifyClosure(typeSymbol.tpe))
|
||||
closureDepthCache = maxDepth(closureCache)
|
||||
}
|
||||
//Console.println("closure(" + symbol + ") = " + List.fromArray(closureCache));//DEBUG
|
||||
//Console.println("closure(" + typeSymbol + ") = " + List.fromArray(closureCache));//DEBUG
|
||||
}
|
||||
if (closureCache eq null)
|
||||
throw new TypeError("illegal cyclic reference involving " + symbol)
|
||||
throw new TypeError("illegal cyclic reference involving " + typeSymbol)
|
||||
closureCache
|
||||
}
|
||||
|
||||
override def closureDepth: Int = { closure; closureDepthCache }
|
||||
|
||||
override def baseClasses: List[Symbol] = {
|
||||
if (inIDE) trackTypeIDE(symbol)
|
||||
if (inIDE) trackTypeIDE(typeSymbol)
|
||||
def computeBaseClasses: List[Symbol] =
|
||||
if (parents.isEmpty) List(symbol)
|
||||
if (parents.isEmpty) List(typeSymbol)
|
||||
else {
|
||||
//Console.println("computing base classes of " + symbol + " at phase " + phase);//DEBUG
|
||||
//Console.println("computing base classes of " + typeSymbol + " at phase " + phase);//DEBUG
|
||||
// optimized, since this seems to be performance critical
|
||||
val superclazz = parents.head
|
||||
var mixins = parents.tail
|
||||
|
@ -952,18 +973,18 @@ trait Types {
|
|||
bcs = addMixinBaseClasses(mixins.head.baseClasses)
|
||||
mixins = mixins.tail
|
||||
}
|
||||
symbol :: bcs
|
||||
typeSymbol :: bcs
|
||||
}
|
||||
val period = baseClassesPeriod
|
||||
if (period != currentPeriod) {
|
||||
baseClassesPeriod = currentPeriod
|
||||
if (!isValidForBaseClasses(period)) {
|
||||
baseClassesCache = null
|
||||
baseClassesCache = memo[List[Symbol], Symbol](computeBaseClasses, x => symbol :: x.baseClasses.tail)
|
||||
baseClassesCache = memo[List[Symbol], Symbol](computeBaseClasses, x => typeSymbol :: x.baseClasses.tail)
|
||||
}
|
||||
}
|
||||
if (baseClassesCache eq null)
|
||||
throw new TypeError("illegal cyclic reference involving " + symbol)
|
||||
throw new TypeError("illegal cyclic reference involving " + typeSymbol)
|
||||
baseClassesCache
|
||||
}
|
||||
|
||||
|
@ -976,20 +997,20 @@ trait Types {
|
|||
}
|
||||
|
||||
override def baseType(sym: Symbol): Type = {
|
||||
if (inIDE) { trackTypeIDE(sym); trackTypeIDE(symbol); }
|
||||
if (inIDE) { trackTypeIDE(sym); trackTypeIDE(typeSymbol); }
|
||||
val index = closurePos(sym)
|
||||
if (index >= 0) closure(index) else NoType
|
||||
}
|
||||
|
||||
override def narrow: Type = {
|
||||
if (inIDE) trackTypeIDE(symbol)
|
||||
symbol.thisType
|
||||
if (inIDE) trackTypeIDE(typeSymbol)
|
||||
typeSymbol.thisType
|
||||
}
|
||||
|
||||
override def isNotNull: Boolean = parents exists (_.isNotNull)
|
||||
|
||||
// override def isNullable: Boolean =
|
||||
// parents forall (p => p.isNullable && !p.symbol.isAbstractType);
|
||||
// parents forall (p => p.isNullable && !p.typeSymbol.isAbstractType);
|
||||
|
||||
override def toString: String =
|
||||
parents.mkString("", " with ", "") +
|
||||
|
@ -1010,8 +1031,10 @@ trait Types {
|
|||
case class ClassInfoType(
|
||||
override val parents: List[Type],
|
||||
override val decls: Scope,
|
||||
override val symbol: Symbol) extends CompoundType
|
||||
override val typeSymbol: Symbol) extends CompoundType
|
||||
{
|
||||
@deprecated override def symbol = typeSymbol
|
||||
|
||||
/** refs indices */
|
||||
private final val NonExpansive = 0
|
||||
private final val Expansive = 1
|
||||
|
@ -1085,7 +1108,7 @@ trait Types {
|
|||
*/
|
||||
private def computeRefs() {
|
||||
refs = Array(Map(), Map())
|
||||
for (tparam <- symbol.typeParams) {
|
||||
for (tparam <- typeSymbol.typeParams) {
|
||||
val enterRefs = new TypeMap {
|
||||
def apply(tp: Type): Type = {
|
||||
tp match {
|
||||
|
@ -1093,7 +1116,7 @@ trait Types {
|
|||
for ((tparam1, arg) <- sym.info.typeParams zip args)
|
||||
if (arg contains tparam) {
|
||||
addRef(NonExpansive, tparam, tparam1)
|
||||
if (arg.symbol != tparam) addRef(Expansive, tparam, tparam1)
|
||||
if (arg.typeSymbol != tparam) addRef(Expansive, tparam, tparam1)
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
|
@ -1149,13 +1172,11 @@ trait Types {
|
|||
* @param value ...
|
||||
*/
|
||||
case class ConstantType(value: Constant) extends SingletonType {
|
||||
assert(value.tpe.symbol != UnitClass)
|
||||
assert(value.tpe.typeSymbol != UnitClass)
|
||||
override def isTrivial: Boolean = true
|
||||
override def isNotNull = value.value != null
|
||||
override def symbol: Symbol = value.tpe.symbol
|
||||
override def singleDeref: Type =
|
||||
if (value.value.isInstanceOf[String]) value.tpe
|
||||
else value.tpe
|
||||
@deprecated override def symbol: Symbol = value.tpe.symbol
|
||||
override def singleDeref: Type = value.tpe
|
||||
override def deconst: Type = value.tpe
|
||||
override def toString: String =
|
||||
value.tpe.toString + "(" + value.escapedStringValue + ")"
|
||||
|
@ -1186,7 +1207,7 @@ trait Types {
|
|||
|
||||
override def isStable: Boolean = {
|
||||
sym == SingletonClass ||
|
||||
sym.isAbstractType && (sym.info.bounds.hi.symbol isSubClass SingletonClass)
|
||||
sym.isAbstractType && (sym.info.bounds.hi.typeSymbol isSubClass SingletonClass)
|
||||
}
|
||||
|
||||
override val isTrivial: Boolean =
|
||||
|
@ -1218,14 +1239,17 @@ trait Types {
|
|||
cl1
|
||||
}
|
||||
|
||||
override def symbol = if (sym.isAliasType) normalize.symbol else sym
|
||||
/* @MAT
|
||||
whenever you see `tp.symbol.isXXXX' and then act on tp based on that predicate, you're on thin ice,
|
||||
as `symbol' (and `prefix') automatically normalize, but the other inspectors don't.
|
||||
In other words, even if `tp.normalize.sym.isXXX' is true, `tp.sym.isXXX' may be false (if sym were a public method to access the non-normalized symbol)...
|
||||
override def typeSymbol = if (sym.isAliasType) normalize.typeSymbol else sym
|
||||
override def termSymbol = if (sym.isAliasType) normalize.termSymbol else super.termSymbol
|
||||
@deprecated override def symbol = if (sym.isAliasType) normalize.symbol else sym
|
||||
|
||||
In retrospect, I think `tp.symbol.isXXX' or (worse) `tp.symbol==XXX' should be replaced by `val tp = tp0.asXXX'.
|
||||
A type's symbol should never be inspected directly.
|
||||
/* @MAT
|
||||
whenever you see `tp.typeSymbol.isXXXX' and then act on tp based on that predicate, you're on thin ice,
|
||||
as `typeSymbol' (and `prefix') automatically normalize, but the other inspectors don't.
|
||||
In other words, even if `tp.normalize.sym.isXXX' is true, `tp.sym.isXXX' may be false (if sym were a public method to access the non-normalized typeSymbol)...
|
||||
|
||||
In retrospect, I think `tp.typeSymbol.isXXX' or (worse) `tp.typeSymbol==XXX' should be replaced by `val tp = tp0.asXXX'.
|
||||
A type's typeSymbol should never be inspected directly.
|
||||
*/
|
||||
|
||||
override def bounds: TypeBounds =
|
||||
|
@ -1256,7 +1280,7 @@ A type's symbol should never be inspected directly.
|
|||
|
||||
override def typeParams: List[Symbol] =
|
||||
if (args.isEmpty) sym.unsafeTypeParams else List()
|
||||
// @MAT was symbol.unsafeTypeParams, but symbol normalizes now
|
||||
// @MAT was typeSymbol.unsafeTypeParams, but typeSymbol normalizes now
|
||||
|
||||
override def instantiateTypeParams(formals: List[Symbol], actuals: List[Type]): Type =
|
||||
if (isHigherKinded) {
|
||||
|
@ -1297,7 +1321,7 @@ A type's symbol should never be inspected directly.
|
|||
override def decls: Scope = {
|
||||
sym.info match {
|
||||
case TypeRef(_, sym1, _) =>
|
||||
assert(sym1 != sym, this) // @MAT was != symbol
|
||||
assert(sym1 != sym, this) // @MAT was != typeSymbol
|
||||
case _ =>
|
||||
}
|
||||
thisInfo.decls
|
||||
|
@ -1377,7 +1401,7 @@ A type's symbol should never be inspected directly.
|
|||
override val isTrivial: Boolean =
|
||||
paramTypes.forall(_.isTrivial) && resultType.isTrivial
|
||||
|
||||
//assert(paramTypes forall (pt => !pt.symbol.isImplClass))//DEBUG
|
||||
//assert(paramTypes forall (pt => !pt.typeSymbol.isImplClass))//DEBUG
|
||||
override def paramSectionCount: Int = resultType.paramSectionCount + 1
|
||||
|
||||
override def resultType(actuals: List[Type]) =
|
||||
|
@ -1421,7 +1445,9 @@ A type's symbol should never be inspected directly.
|
|||
override def paramTypes: List[Type] = resultType.paramTypes
|
||||
override def parents: List[Type] = resultType.parents
|
||||
override def decls: Scope = resultType.decls
|
||||
override def symbol: Symbol = resultType.symbol
|
||||
override def termSymbol: Symbol = resultType.termSymbol
|
||||
override def typeSymbol: Symbol = resultType.typeSymbol
|
||||
@deprecated override def symbol: Symbol = resultType.symbol
|
||||
override def prefix: Type = resultType.prefix
|
||||
override def closure: Array[Type] = resultType.closure
|
||||
override def closureDepth: Int = resultType.closureDepth
|
||||
|
@ -1488,7 +1514,7 @@ A type's symbol should never be inspected directly.
|
|||
|
||||
private def tparamToString(tparam: Symbol) = {
|
||||
val tname = tparam.name.toString
|
||||
if ((tname endsWith ".type") && (tparam.info.bounds.hi.symbol isSubClass SingletonClass) &&
|
||||
if ((tname endsWith ".type") && (tparam.info.bounds.hi.typeSymbol isSubClass SingletonClass) &&
|
||||
!settings.debug.value)
|
||||
"val "+tname.substring(0, tname.length - 5)+": "+dropSingletonType(tparam.info.bounds.hi)
|
||||
else tparam.defString
|
||||
|
@ -1527,7 +1553,8 @@ A type's symbol should never be inspected directly.
|
|||
*/
|
||||
case class TypeVar(origin: Type, constr: TypeConstraint) extends Type {
|
||||
//constr.self = this //DEBUG
|
||||
override def symbol = origin.symbol
|
||||
override def typeSymbol = origin.typeSymbol
|
||||
@deprecated override def symbol = origin.symbol
|
||||
override def toString: String =
|
||||
if (constr.inst eq null) "<null " + origin + ">"
|
||||
else if (constr.inst eq NoType) "?*" + origin
|
||||
|
@ -1540,6 +1567,9 @@ A type's symbol should never be inspected directly.
|
|||
* core compiler does take care to propagate attributes and to save them
|
||||
* in the symbol tables of object files. */
|
||||
case class AnnotatedType(attributes: List[AnnotationInfo], tp: Type) extends TypeProxy {
|
||||
|
||||
override protected def rewrap(tp: Type) = AnnotatedType(attributes, tp)
|
||||
|
||||
override def toString: String = {
|
||||
val attString =
|
||||
if (attributes.isEmpty)
|
||||
|
@ -1558,7 +1588,7 @@ A type's symbol should never be inspected directly.
|
|||
/** Remove any attributes from this type */
|
||||
override def withoutAttributes = tp.withoutAttributes
|
||||
|
||||
/** Martin to Lex: I don't understand what the following 2 method do? */
|
||||
/** Martin to Lex: I don't understand what the following 2 methods do? */
|
||||
override def bounds: TypeBounds = {
|
||||
val oftp = tp.bounds
|
||||
oftp match {
|
||||
|
@ -1590,7 +1620,7 @@ A type's symbol should never be inspected directly.
|
|||
*/
|
||||
private def rebind(pre: Type, sym: Symbol): Symbol = {
|
||||
val owner = sym.owner
|
||||
if (owner.isClass && owner != pre.symbol && !sym.isFinal && !sym.isClass) {
|
||||
if (owner.isClass && owner != pre.typeSymbol && !sym.isFinal && !sym.isClass) {
|
||||
//Console.println("rebind "+pre+" "+sym)//DEBUG
|
||||
val rebind = pre.nonPrivateMember(sym.name).suchThat(sym => sym.isType || sym.isStable)
|
||||
if (rebind == NoSymbol) sym else rebind
|
||||
|
@ -1639,7 +1669,10 @@ A type's symbol should never be inspected directly.
|
|||
unique(new TypeBounds(lo, hi) with UniqueType)
|
||||
|
||||
def refinementOfClass(clazz: Symbol, parents: List[Type], decls: Scope) =
|
||||
new RefinedType(parents, decls) { override def symbol: Symbol = clazz }
|
||||
new RefinedType(parents, decls) {
|
||||
override def typeSymbol: Symbol = clazz
|
||||
@deprecated override def symbol: Symbol = clazz
|
||||
}
|
||||
|
||||
/** the canonical creator for a refined type with a given scope */
|
||||
def refinedType(parents: List[Type], owner: Symbol, decls: Scope): Type = {
|
||||
|
@ -1665,14 +1698,14 @@ A type's symbol should never be inspected directly.
|
|||
def copyRefinedType(original: RefinedType, parents: List[Type], decls: Scope) =
|
||||
if ((parents eq original.parents) && (decls eq original.decls)) original
|
||||
else {
|
||||
val result = refinedType(parents, original.symbol.owner)
|
||||
val result = refinedType(parents, original.typeSymbol.owner)
|
||||
val syms1 = decls.toList
|
||||
for (sym <- syms1)
|
||||
result.decls.enter(sym.cloneSymbol(result.symbol))
|
||||
result.decls.enter(sym.cloneSymbol(result.typeSymbol))
|
||||
val syms2 = result.decls.toList
|
||||
val resultThis = result.symbol.thisType
|
||||
val resultThis = result.typeSymbol.thisType
|
||||
for (sym <- syms2)
|
||||
sym.setInfo(sym.info.substSym(syms1, syms2).substThis(original.symbol, resultThis))
|
||||
sym.setInfo(sym.info.substSym(syms1, syms2).substThis(original.typeSymbol, resultThis))
|
||||
result
|
||||
}
|
||||
|
||||
|
@ -1702,7 +1735,7 @@ A type's symbol should never be inspected directly.
|
|||
if (sym1.isAbstractType) sym1 = rebind(pre1, sym1)
|
||||
typeRef(pre1, sym1, args)
|
||||
} else if (checkMalformedSwitch && !pre.isStable && !pre.isError &&
|
||||
(sym1.isAbstractType /* || !pre.widen.symbol.isStableClass*/)) {
|
||||
(sym1.isAbstractType /* || !pre.widen.typeSymbol.isStableClass*/)) {
|
||||
throw new MalformedType(pre, sym1.nameString)
|
||||
} else if (sym1.isClass && pre.isInstanceOf[CompoundType]) {
|
||||
// sharpen prefix so that it is maximal and still contains the class.
|
||||
|
@ -1739,13 +1772,13 @@ A type's symbol should never be inspected directly.
|
|||
/*
|
||||
def merge(tps: List[Type]): List[Type] = tps match {
|
||||
case tp :: tps1 =>
|
||||
val tps1a = tps1 filter (_.symbol.==(tp.symbol))
|
||||
val tps1b = tps1 filter (_.symbol.!=(tp.symbol))
|
||||
val tps1a = tps1 filter (_.typeSymbol.==(tp.typeSymbol))
|
||||
val tps1b = tps1 filter (_.typeSymbol.!=(tp.typeSymbol))
|
||||
mergePrefixAndArgs(tps1a, -1) match {
|
||||
case Some(tp1) => tp1 :: merge(tps1b)
|
||||
case None => throw new MalformedType(
|
||||
"malformed type: "+refinedType(tps, owner)+" has repeated parent class "+
|
||||
tp.symbol+" with incompatible prefixes or type arguments")
|
||||
tp.typeSymbol+" with incompatible prefixes or type arguments")
|
||||
}
|
||||
case _ => tps
|
||||
}
|
||||
|
@ -1840,7 +1873,7 @@ A type's symbol should never be inspected directly.
|
|||
case TypeRef(_, sym, _) if (sym == SingletonClass) =>
|
||||
AnyClass.tpe
|
||||
case tp1 @ RefinedType(parents, decls) =>
|
||||
var parents1 = parents filter (_.symbol != SingletonClass)
|
||||
var parents1 = parents filter (_.typeSymbol != SingletonClass)
|
||||
if (parents1.isEmpty) parents1 = List(AnyClass.tpe)
|
||||
if (parents1.tail.isEmpty && decls.isEmpty) mapOver(parents1.head)
|
||||
else mapOver(copyRefinedType(tp1, parents1, decls))
|
||||
|
@ -1967,7 +2000,7 @@ A type's symbol should never be inspected directly.
|
|||
val parents1 = List.mapConserve(parents)(this)
|
||||
val decls1 = mapOver(decls)
|
||||
//if ((parents1 eq parents) && (decls1 eq decls)) tp
|
||||
//else refinementOfClass(tp.symbol, parents1, decls1)
|
||||
//else refinementOfClass(tp.typeSymbol, parents1, decls1)
|
||||
copyRefinedType(rtp, parents1, decls1)
|
||||
/*
|
||||
case ClassInfoType(parents, decls, clazz) =>
|
||||
|
@ -2084,7 +2117,7 @@ A type's symbol should never be inspected directly.
|
|||
def toPrefix(pre: Type, clazz: Symbol): Type =
|
||||
if ((pre eq NoType) || (pre eq NoPrefix) || !clazz.isClass) tp
|
||||
else if ((sym isNonBottomSubClass clazz) &&
|
||||
(pre.widen.symbol isNonBottomSubClass sym))
|
||||
(pre.widen.typeSymbol isNonBottomSubClass sym))
|
||||
pre match {
|
||||
case SuperType(thistp, _) => thistp
|
||||
case _ => pre
|
||||
|
@ -2114,7 +2147,7 @@ A type's symbol should never be inspected directly.
|
|||
else if (sym eq ps.head) // @M! don't just replace the whole thing, might be followed by type application
|
||||
appliedType(as.head, List.mapConserve(args)(this)) // @M: was as.head
|
||||
else instParam(ps.tail, as.tail);
|
||||
if (symclazz == clazz && (pre.widen.symbol isNonBottomSubClass symclazz))
|
||||
if (symclazz == clazz && (pre.widen.typeSymbol isNonBottomSubClass symclazz))
|
||||
pre.baseType(symclazz) match {
|
||||
case TypeRef(_, basesym, baseargs) =>
|
||||
//Console.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs+", pre = "+pre+", symclazz = "+symclazz);//DEBUG
|
||||
|
@ -2457,7 +2490,7 @@ A type's symbol should never be inspected directly.
|
|||
case RefinedType(parents, decls) =>
|
||||
val parents1 = List.mapConserve(parents)(this)
|
||||
if (parents1 eq parents) tp
|
||||
else refinedType(parents1, tp.symbol.owner, decls)
|
||||
else refinedType(parents1, tp.typeSymbol.owner, decls)
|
||||
case SuperType(_, _) => mapOver(tp)
|
||||
case TypeBounds(_, _) => mapOver(tp)
|
||||
case MethodType(_, _) => mapOver(tp)
|
||||
|
@ -2556,9 +2589,9 @@ A type's symbol should never be inspected directly.
|
|||
case (_, WildcardType) => true
|
||||
|
||||
case (NoType, _) => false
|
||||
case (NoPrefix, _) => tp2.symbol.isPackageClass
|
||||
case (NoPrefix, _) => tp2.typeSymbol.isPackageClass
|
||||
case (_, NoType) => false
|
||||
case (_, NoPrefix) => tp1.symbol.isPackageClass
|
||||
case (_, NoPrefix) => tp1.typeSymbol.isPackageClass
|
||||
|
||||
case (ThisType(sym1), ThisType(sym2))
|
||||
if (sym1 == sym2) =>
|
||||
|
@ -2592,7 +2625,7 @@ A type's symbol should never be inspected directly.
|
|||
sym1 != NoSymbol &&
|
||||
sym1.info =:= sym2.info.substThis(sym2.owner, sym1.owner.thisType)
|
||||
}
|
||||
//Console.println("is same? " + tp1 + " " + tp2 + " " + tp1.symbol.owner + " " + tp2.symbol.owner)//DEBUG
|
||||
//Console.println("is same? " + tp1 + " " + tp2 + " " + tp1.typeSymbol.owner + " " + tp2.typeSymbol.owner)//DEBUG
|
||||
isSameTypes(parents1, parents2) && isSubScope(ref1, ref2) && isSubScope(ref2, ref1)
|
||||
case (MethodType(pts1, res1), MethodType(pts2, res2)) =>
|
||||
(pts1.length == pts2.length &&
|
||||
|
@ -2687,9 +2720,9 @@ A type's symbol should never be inspected directly.
|
|||
case (_, WildcardType) => true
|
||||
|
||||
case (NoType, _) => false
|
||||
case (NoPrefix, _) => tp2.symbol.isPackageClass
|
||||
case (NoPrefix, _) => tp2.typeSymbol.isPackageClass
|
||||
case (_, NoType) => false
|
||||
case (_, NoPrefix) => tp1.symbol.isPackageClass
|
||||
case (_, NoPrefix) => tp1.typeSymbol.isPackageClass
|
||||
|
||||
case (ThisType(_), ThisType(_)) => tp1 =:= tp2
|
||||
case (ThisType(_), SingleType(_, _)) => tp1 =:= tp2
|
||||
|
@ -2726,7 +2759,7 @@ A type's symbol should never be inspected directly.
|
|||
||
|
||||
// Console.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " (sym2 isSubClass ObjectClass))
|
||||
sym1 == AllRefClass &&
|
||||
sym2.isClass && (sym2 isNonBottomSubClass ObjectClass) && (!(tp2.normalize.symbol isNonBottomSubClass NotNullClass)))
|
||||
sym2.isClass && (sym2 isNonBottomSubClass ObjectClass) && (!(tp2.normalize.typeSymbol isNonBottomSubClass NotNullClass)))
|
||||
case (MethodType(pts1, res1), MethodType(pts2, res2)) =>
|
||||
(pts1.length == pts2.length &&
|
||||
matchingParams(pts1, pts2, tp2.isInstanceOf[JavaMethodType]) &&
|
||||
|
@ -2754,9 +2787,9 @@ A type's symbol should never be inspected directly.
|
|||
case (_, AnnotatedType(_,atp2)) =>
|
||||
tp1 <:< atp2
|
||||
case (_, _) if (tp1.isHigherKinded || tp2.isHigherKinded) =>
|
||||
(tp1.symbol == AllClass
|
||||
(tp1.typeSymbol == AllClass
|
||||
||
|
||||
tp2.symbol == AnyClass // @M Any and Nothing are super-type resp. subtype of every well-kinded type
|
||||
tp2.typeSymbol == AnyClass // @M Any and Nothing are super-type resp. subtype of every well-kinded type
|
||||
|| // @M! normalize reduces higher-kinded case to PolyType's
|
||||
(tp1.isHigherKinded && tp2.isHigherKinded) && isSubType0(tp1.normalize, tp2.normalize))
|
||||
case (_, TypeRef(pre2, sym2, args2))
|
||||
|
@ -2768,9 +2801,9 @@ A type's symbol should never be inspected directly.
|
|||
if (sym2 == SingletonClass && tp1.isStable) =>
|
||||
true
|
||||
case (_, RefinedType(parents2, ref2)) =>
|
||||
(parents2 forall (tp2 => tp1 <:< tp2 || tp2.symbol == NotNullClass && tp1.isNotNull)) &&
|
||||
(parents2 forall (tp2 => tp1 <:< tp2 || tp2.typeSymbol == NotNullClass && tp1.isNotNull)) &&
|
||||
(ref2.toList forall tp1.specializes) &&
|
||||
(!parents2.exists(_.symbol.isAbstractType) || tp1.symbol != AllRefClass)
|
||||
(!parents2.exists(_.typeSymbol.isAbstractType) || tp1.typeSymbol != AllRefClass)
|
||||
case (_, ExistentialType(tparams2, res2)) =>
|
||||
val tvars = tparams2 map (tparam => new TypeVar(tparam.tpe, new TypeConstraint))
|
||||
val ires2 = res2.instantiateTypeParams(tparams2, tvars)
|
||||
|
@ -2826,8 +2859,8 @@ A type's symbol should never be inspected directly.
|
|||
* refinement type, otherwise we might return false negatives.
|
||||
*/
|
||||
def specializesSym(tp: Type, sym: Symbol): Boolean =
|
||||
tp.symbol == AllClass ||
|
||||
tp.symbol == AllRefClass && (sym.owner isSubClass ObjectClass) ||
|
||||
tp.typeSymbol == AllClass ||
|
||||
tp.typeSymbol == AllRefClass && (sym.owner isSubClass ObjectClass) ||
|
||||
(tp.nonPrivateMember(sym.name).alternatives exists
|
||||
(alt => sym == alt || specializesSym(tp.narrow, alt, sym.owner.thisType, sym)))
|
||||
|
||||
|
@ -2836,11 +2869,11 @@ A type's symbol should never be inspected directly.
|
|||
*/
|
||||
private def specializesSym(tp1: Type, sym1: Symbol, tp2: Type, sym2: Symbol): Boolean = {
|
||||
val info1 = tp1.memberInfo(sym1)
|
||||
val info2 = tp2.memberInfo(sym2).substThis(tp2.symbol, tp1)
|
||||
val info2 = tp2.memberInfo(sym2).substThis(tp2.typeSymbol, tp1)
|
||||
//System.out.println("specializes "+tp1+"."+sym1+":"+info1+sym1.locationString+" AND "+tp2+"."+sym2+":"+info2)//DEBUG
|
||||
sym2.isTerm && (info1 <:< info2) ||
|
||||
sym2.isAbstractType && info2.bounds.containsType(tp1.memberType(sym1)) ||
|
||||
sym2.isAliasType && tp2.memberType(sym2).substThis(tp2.symbol, tp1) =:= tp1.memberType(sym1) //@MAT ok
|
||||
sym2.isAliasType && tp2.memberType(sym2).substThis(tp2.typeSymbol, tp1) =:= tp1.memberType(sym1) //@MAT ok
|
||||
}
|
||||
|
||||
/** A function implementing `tp1' matches `tp2' */
|
||||
|
@ -2872,7 +2905,7 @@ A type's symbol should never be inspected directly.
|
|||
private def matchingParams(tps1: List[Type], tps2: List[Type], tps2isJava: Boolean): Boolean = (
|
||||
tps1.length == tps2.length &&
|
||||
List.forall2(tps1, tps2)((tp1, tp2) =>
|
||||
(tp1 =:= tp2) || tps2isJava & tp1.symbol == ObjectClass && tp2.symbol == AnyClass)
|
||||
(tp1 =:= tp2) || tps2isJava & tp1.typeSymbol == ObjectClass && tp2.typeSymbol == AnyClass)
|
||||
);
|
||||
|
||||
/** Prepend type `tp' to closure `cl'.
|
||||
|
@ -2939,7 +2972,7 @@ A type's symbol should never be inspected directly.
|
|||
}
|
||||
if (!cyclic) {
|
||||
if (up) {
|
||||
if (bound.symbol != AnyClass) {
|
||||
if (bound.typeSymbol != AnyClass) {
|
||||
tvar.constr.hibounds =
|
||||
bound.instantiateTypeParams(tparams, tvars) :: tvar.constr.hibounds
|
||||
}
|
||||
|
@ -2948,7 +2981,7 @@ A type's symbol should never be inspected directly.
|
|||
tvar.constr.hibounds =
|
||||
tparam2.tpe.instantiateTypeParams(tparams, tvars) :: tvar.constr.hibounds
|
||||
} else {
|
||||
if (bound.symbol != AllClass && bound.symbol != tparam) {
|
||||
if (bound.typeSymbol != AllClass && bound.typeSymbol != tparam) {
|
||||
tvar.constr.lobounds =
|
||||
bound.instantiateTypeParams(tparams, tvars) :: tvar.constr.lobounds
|
||||
}
|
||||
|
@ -2959,8 +2992,8 @@ A type's symbol should never be inspected directly.
|
|||
}
|
||||
}
|
||||
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)
|
||||
//Console.println("solving "+tvar+" "+up+" "+(if (up) (tvar.constr.hibounds) else tvar.constr.lobounds)+((if (up) (tvar.constr.hibounds) else tvar.constr.lobounds) map (_.widen))+" = "+tvar.constr.inst)//DEBUG"
|
||||
}
|
||||
}
|
||||
for ((tvar, (tparam, variance)) <- config)
|
||||
|
@ -2997,10 +3030,10 @@ A type's symbol should never be inspected directly.
|
|||
else {
|
||||
val ts0 = tss1 map (_.head)
|
||||
val sym = minSym(ts0)
|
||||
val ts1 = elimSuper(ts0 filter (_.symbol == sym))
|
||||
val ts1 = elimSuper(ts0 filter (_.typeSymbol == sym))
|
||||
mergePrefixAndArgs(ts1, -1, depth) match {
|
||||
case Some(tp0) =>
|
||||
tp0 :: glbList(tss1 map (ts => if (ts.head.symbol == sym) ts.tail else ts), depth)
|
||||
tp0 :: glbList(tss1 map (ts => if (ts.head.typeSymbol == sym) ts.tail else ts), depth)
|
||||
case None =>
|
||||
throw new MalformedClosure(ts1)
|
||||
}
|
||||
|
@ -3032,10 +3065,10 @@ A type's symbol should never be inspected directly.
|
|||
else {
|
||||
val ts0 = tss map (_.head)
|
||||
val sym = minSym(ts0)
|
||||
if (ts0 forall (t => t.symbol == sym))
|
||||
if (ts0 forall (t => t.typeSymbol == sym))
|
||||
mergePrefixAndArgs(elimSub(ts0), 1, depth).toList ::: lubList(tss map (_.tail), depth)
|
||||
else
|
||||
lubList(tss map (ts => if (ts.head.symbol == sym) ts.tail else ts), depth)
|
||||
lubList(tss map (ts => if (ts.head.typeSymbol == sym) ts.tail else ts), depth)
|
||||
}
|
||||
|
||||
/** The least sorted upwards closed upper bound of a non-empty list
|
||||
|
@ -3058,8 +3091,8 @@ A type's symbol should never be inspected directly.
|
|||
|
||||
/** The minimal symbol (wrt Symbol.isLess) of a list of types */
|
||||
private def minSym(tps: List[Type]): Symbol =
|
||||
(tps.head.symbol /: tps.tail) {
|
||||
(sym1, tp2) => if (tp2.symbol isLess sym1) tp2.symbol else sym1
|
||||
(tps.head.typeSymbol /: tps.tail) {
|
||||
(sym1, tp2) => if (tp2.typeSymbol isLess sym1) tp2.typeSymbol else sym1
|
||||
}
|
||||
|
||||
/** A minimal type list which has a given array of types as its closure */
|
||||
|
@ -3067,7 +3100,7 @@ A type's symbol should never be inspected directly.
|
|||
case List() => List()
|
||||
case first :: rest =>
|
||||
first :: spanningTypes(
|
||||
rest filter (t => !first.symbol.isSubClass(t.symbol)))
|
||||
rest filter (t => !first.typeSymbol.isSubClass(t.typeSymbol)))
|
||||
}
|
||||
|
||||
/** Eliminate from list of types all elements which are a supertype
|
||||
|
@ -3075,7 +3108,7 @@ A type's symbol should never be inspected directly.
|
|||
private def elimSuper(ts: List[Type]): List[Type] = ts match {
|
||||
case List() => List()
|
||||
case t :: ts1 =>
|
||||
val rest = ts1 filter (t1 => !(t <:< t1));
|
||||
val rest = elimSuper(ts1 filter (t1 => !(t <:< t1)))
|
||||
if (rest exists (t1 => t1 <:< t)) rest else t :: rest
|
||||
}
|
||||
|
||||
|
@ -3113,11 +3146,7 @@ A type's symbol should never be inspected directly.
|
|||
|
||||
/** The least upper bound wrt <:< of a list of types */
|
||||
def lub(ts: List[Type], depth: Int): Type = {
|
||||
def lub0(ts0: List[Type]): Type = {
|
||||
//if (elimSub(ts0 map (_.deconst)) != elimSub(ts0))
|
||||
// println("DIFF for lub of "+ts+", with deconst = "+elimSub(ts0 map (_.deconst))+", without = "+elimSub(ts0))
|
||||
|
||||
elimSub(ts0/* map (_.deconst) */) match {
|
||||
def lub0(ts0: List[Type]): Type = elimSub(ts0) match {
|
||||
case List() => AllClass.tpe
|
||||
case List(t) => t
|
||||
case ts @ PolyType(tparams, _) :: _ =>
|
||||
|
@ -3141,22 +3170,22 @@ A type's symbol should never be inspected directly.
|
|||
if (phase.erasedTypes || depth == 0) lubBase
|
||||
else {
|
||||
val lubRefined = refinedType(lubParents, lubOwner)
|
||||
val lubThisType = lubRefined.symbol.thisType
|
||||
val lubThisType = lubRefined.typeSymbol.thisType
|
||||
val narrowts = ts map (_.narrow)
|
||||
def lubsym(proto: Symbol): Symbol = {
|
||||
val prototp = lubThisType.memberInfo(proto)
|
||||
val syms = narrowts map (t =>
|
||||
t.nonPrivateMember(proto.name).suchThat(sym =>
|
||||
sym.tpe matches prototp.substThis(lubThisType.symbol, t)))
|
||||
sym.tpe matches prototp.substThis(lubThisType.typeSymbol, t)))
|
||||
if (syms contains NoSymbol) NoSymbol
|
||||
else {
|
||||
val symtypes =
|
||||
(List.map2(narrowts, syms)
|
||||
((t, sym) => t.memberInfo(sym).substThis(t.symbol, lubThisType)));
|
||||
((t, sym) => t.memberInfo(sym).substThis(t.typeSymbol, lubThisType)));
|
||||
if (proto.isTerm)
|
||||
proto.cloneSymbol(lubRefined.symbol).setInfo(lub(symtypes, depth-1))
|
||||
proto.cloneSymbol(lubRefined.typeSymbol).setInfo(lub(symtypes, depth-1))
|
||||
else if (symtypes.tail forall (symtypes.head =:=))
|
||||
proto.cloneSymbol(lubRefined.symbol).setInfo(symtypes.head)
|
||||
proto.cloneSymbol(lubRefined.typeSymbol).setInfo(symtypes.head)
|
||||
else {
|
||||
def lubBounds(bnds: List[TypeBounds]): TypeBounds =
|
||||
mkTypeBounds(glb(bnds map (_.lo), depth-1), lub(bnds map (_.hi), depth-1))
|
||||
|
@ -3186,7 +3215,7 @@ A type's symbol should never be inspected directly.
|
|||
if (lubRefined.decls.isEmpty) lubBase else lubRefined
|
||||
}
|
||||
existentialAbstraction(tparams, lubType)
|
||||
}}
|
||||
}
|
||||
// if (settings.debug.value) {
|
||||
// log(indent + "lub of " + ts + " at depth "+depth)//debug
|
||||
// indent = indent + " "
|
||||
|
@ -3203,7 +3232,7 @@ A type's symbol should never be inspected directly.
|
|||
|
||||
/** The greatest lower bound wrt <:< of a list of types */
|
||||
private def glb(ts: List[Type], depth: Int): Type = {
|
||||
def glb0(ts0: List[Type]): Type = elimSuper(ts0 map (_.deconst)) match {
|
||||
def glb0(ts0: List[Type]): Type = elimSuper(ts0 map (_.deconst)) match {// todo: deconst needed?
|
||||
case List() => AnyClass.tpe
|
||||
case List(t) => t
|
||||
case ts @ PolyType(tparams, _) :: _ =>
|
||||
|
@ -3229,7 +3258,7 @@ A type's symbol should never be inspected directly.
|
|||
if (phase.erasedTypes || depth == 0) glbBase
|
||||
else {
|
||||
val glbRefined = refinedType(ts1, glbOwner)
|
||||
val glbThisType = glbRefined.symbol.thisType
|
||||
val glbThisType = glbRefined.typeSymbol.thisType
|
||||
def glbsym(proto: Symbol): Symbol = {
|
||||
val prototp = glbThisType.memberInfo(proto)
|
||||
val syms = for {
|
||||
|
@ -3239,7 +3268,7 @@ A type's symbol should never be inspected directly.
|
|||
} yield alt
|
||||
val symtypes = syms map glbThisType.memberInfo
|
||||
assert(!symtypes.isEmpty)
|
||||
proto.cloneSymbol(glbRefined.symbol).setInfo(
|
||||
proto.cloneSymbol(glbRefined.typeSymbol).setInfo(
|
||||
if (proto.isTerm) glb(symtypes, depth-1)
|
||||
else {
|
||||
def isTypeBound(tp: Type) = tp match {
|
||||
|
|
|
@ -207,17 +207,17 @@ abstract class ClassfileParser {
|
|||
//assert(name.endsWith("$"), "Not a module class: " + name)
|
||||
f = definitions.getModule(name.subName(0, name.length - 1))
|
||||
} else {
|
||||
val owner = if (static) ownerTpe.symbol.linkedClassOfClass else ownerTpe.symbol
|
||||
val owner = if (static) ownerTpe.typeSymbol.linkedClassOfClass else ownerTpe.typeSymbol
|
||||
// println("\t" + owner.info.member(name).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)
|
||||
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);
|
||||
assert(ownerTpe.typeSymbol.isImplClass, "Not an implementation class: " + owner + " couldn't find " + name + ": " + tpe + " inside: \n" + ownerTpe.members);
|
||||
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)
|
||||
// println("Looking for: " + name + ": " + tpe + " inside: " + ownerTpe.typeSymbol + "\n\tand found: " + ownerTpe.members)
|
||||
}
|
||||
}
|
||||
assert(f != NoSymbol, "could not find " + name + ": " + tpe + "inside: \n" + ownerTpe.members)
|
||||
|
@ -237,7 +237,7 @@ abstract class ClassfileParser {
|
|||
if (name == nme.CONSTRUCTOR)
|
||||
tpe match {
|
||||
case MethodType(formals, restpe) =>
|
||||
assert(restpe.symbol == definitions.UnitClass)
|
||||
assert(restpe.typeSymbol == definitions.UnitClass)
|
||||
tpe = MethodType(formals, ownerTpe)
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ abstract class ClassfileParser {
|
|||
var index = 0
|
||||
val end = name.length
|
||||
def objToAny(tp: Type): Type =
|
||||
if (!global.phase.erasedTypes && tp.symbol == definitions.ObjectClass) definitions.AnyClass.tpe
|
||||
if (!global.phase.erasedTypes && tp.typeSymbol == definitions.ObjectClass) definitions.AnyClass.tpe
|
||||
else tp
|
||||
def paramsigs2types: List[Type] =
|
||||
if (name(index) == ')') { index += 1; List() }
|
||||
|
@ -469,7 +469,7 @@ abstract class ClassfileParser {
|
|||
if (name == nme.CONSTRUCTOR)
|
||||
info match {
|
||||
case MethodType(formals, restpe) =>
|
||||
assert(restpe.symbol == definitions.UnitClass)
|
||||
assert(restpe.typeSymbol == definitions.UnitClass)
|
||||
info = MethodType(formals, clazz.tpe)
|
||||
}
|
||||
val sym = getOwner(jflags)
|
||||
|
@ -495,7 +495,7 @@ abstract class ClassfileParser {
|
|||
val end = sig.length
|
||||
val newTParams = new ListBuffer[Symbol]()
|
||||
def objToAny(tp: Type): Type =
|
||||
if (tp.symbol == definitions.ObjectClass) definitions.AnyClass.tpe
|
||||
if (tp.typeSymbol == definitions.ObjectClass) definitions.AnyClass.tpe
|
||||
else tp
|
||||
def subName(isDelimiter: Char => Boolean): Name = {
|
||||
val start = index
|
||||
|
@ -610,7 +610,7 @@ abstract class ClassfileParser {
|
|||
|
||||
def parseAttributes(sym: Symbol, symtype: Type) {
|
||||
def convertTo(c: Constant, pt: Type): Constant = {
|
||||
if (pt.symbol == definitions.BooleanClass && c.tag == IntTag)
|
||||
if (pt.typeSymbol == definitions.BooleanClass && c.tag == IntTag)
|
||||
Constant(c.value != 0)
|
||||
else
|
||||
c convertTo pt
|
||||
|
@ -693,7 +693,7 @@ abstract class ClassfileParser {
|
|||
case ENUM_TAG =>
|
||||
val t = pool.getType(index)
|
||||
val n = pool.getName(in.nextChar)
|
||||
val s = t.symbol.linkedModuleOfClass.info.decls.lookup(n)
|
||||
val s = t.typeSymbol.linkedModuleOfClass.info.decls.lookup(n)
|
||||
//assert (s != NoSymbol, "while processing " + in.file + ": " + t + "." + n + ": " + t.decls)
|
||||
assert(s != NoSymbol, t) // avoid string concatenation!
|
||||
Constant(s)
|
||||
|
|
|
@ -106,7 +106,7 @@ abstract class ICodeReader extends ClassfileParser {
|
|||
if (name == nme.CONSTRUCTOR)
|
||||
tpe match {
|
||||
case MethodType(formals, restpe) =>
|
||||
assert(restpe.symbol == definitions.UnitClass)
|
||||
assert(restpe.typeSymbol == definitions.UnitClass)
|
||||
tpe = MethodType(formals, getOwner(jflags).tpe)
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ abstract class Pickler extends SubComponent {
|
|||
putChildren(sym, children.sort((x, y) => x isLess y))
|
||||
}
|
||||
for (attr <- sym.attributes.reverse) {
|
||||
if (attr.atp.symbol isNonBottomSubClass definitions.StaticAnnotationClass)
|
||||
if (attr.atp.typeSymbol isNonBottomSubClass definitions.StaticAnnotationClass)
|
||||
putAnnotation(sym, attr)
|
||||
}
|
||||
} else if (sym != NoSymbol) {
|
||||
|
@ -153,7 +153,7 @@ abstract class Pickler extends SubComponent {
|
|||
case TypeBounds(lo, hi) =>
|
||||
putType(lo); putType(hi)
|
||||
case RefinedType(parents, decls) =>
|
||||
putSymbol(tp.symbol); putTypes(parents); putSymbols(decls.toList)
|
||||
putSymbol(tp.typeSymbol); putTypes(parents); putSymbols(decls.toList)
|
||||
case ClassInfoType(parents, decls, clazz) =>
|
||||
putSymbol(clazz); putTypes(parents); putSymbols(decls.toList)
|
||||
case MethodType(formals, restpe) =>
|
||||
|
@ -387,7 +387,7 @@ abstract class Pickler extends SubComponent {
|
|||
case TypeBounds(lo, hi) =>
|
||||
writeRef(lo); writeRef(hi); TYPEBOUNDStpe
|
||||
case tp @ RefinedType(parents, decls) =>
|
||||
writeRef(tp.symbol); writeRefs(parents); REFINEDtpe
|
||||
writeRef(tp.typeSymbol); writeRefs(parents); REFINEDtpe
|
||||
case ClassInfoType(parents, decls, clazz) =>
|
||||
writeRef(clazz); writeRefs(parents); CLASSINFOtpe
|
||||
case MethodType(formals, restpe) =>
|
||||
|
|
|
@ -189,7 +189,7 @@ abstract class UnPickler {
|
|||
else owner.newClass(pos, name)
|
||||
if (readIndex != end) sym.typeOfThis = new LazyTypeRef(readNat())
|
||||
case MODULEsym =>
|
||||
val clazz = at(inforef, readType).symbol
|
||||
val clazz = at(inforef, readType).typeSymbol
|
||||
sym =
|
||||
if (name == moduleRoot.name && owner == moduleRoot.owner) moduleRoot
|
||||
else {
|
||||
|
@ -245,7 +245,10 @@ abstract class UnPickler {
|
|||
val dcls = symScope(clazz)
|
||||
new RefinedType(ps, dcls) { override def symbol = clazz }
|
||||
*/
|
||||
new RefinedType(until(end, readTypeRef), symScope(clazz)) { override def symbol = clazz }
|
||||
new RefinedType(until(end, readTypeRef), symScope(clazz)) {
|
||||
@deprecated override def symbol = clazz
|
||||
override def typeSymbol = clazz
|
||||
}
|
||||
case CLASSINFOtpe =>
|
||||
val clazz = readSymbolRef()
|
||||
ClassInfoType(until(end, readTypeRef), symScope(clazz), clazz)
|
||||
|
|
|
@ -193,7 +193,7 @@ abstract class AddInterfaces extends InfoTransform {
|
|||
val parents1 =
|
||||
if (parents.isEmpty) List()
|
||||
else {
|
||||
assert(!parents.head.symbol.isTrait, clazz)
|
||||
assert(!parents.head.typeSymbol.isTrait, clazz)
|
||||
if (clazz.isTrait) erasedTypeRef(ObjectClass) :: parents.tail
|
||||
else parents
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ abstract class CleanUp extends Transform {
|
|||
* a dynamic call will box them as a side-effect. */
|
||||
def fixResult(resType: Type)(tree: Tree): Tree =
|
||||
thisTyper.typed {
|
||||
if (resType.symbol == UnitClass)
|
||||
if (resType.typeSymbol == UnitClass)
|
||||
Block (
|
||||
List(tree),
|
||||
gen.mkAttributedRef(BoxedUnit_UNIT)
|
||||
|
@ -157,7 +157,7 @@ abstract class CleanUp extends Transform {
|
|||
If(
|
||||
Apply(Select(Literal(Constant(null)), Any_==), List(gen.mkAttributedRef(sym))),
|
||||
Literal(Constant(null)),
|
||||
if (resType.symbol == ArrayClass)
|
||||
if (resType.typeSymbol == ArrayClass)
|
||||
Apply(
|
||||
Select(
|
||||
gen.mkAttributedRef(ScalaRunTimeModule),
|
||||
|
@ -181,7 +181,7 @@ abstract class CleanUp extends Transform {
|
|||
def fixParams(params: List[Tree], paramTypes: List[Type]): List[Tree] =
|
||||
(params zip paramTypes) map { case (param, paramType) =>
|
||||
thisTyper.typed {
|
||||
if (paramType.symbol == ArrayClass) {
|
||||
if (paramType.typeSymbol == ArrayClass) {
|
||||
val sym = currentOwner.newValue(tree.pos, newTermName(unit.fresh.newName)) setInfo ObjectClass.tpe
|
||||
val arrayType = {
|
||||
assert(paramType.typeArgs.length == 1)
|
||||
|
@ -244,7 +244,7 @@ abstract class CleanUp extends Transform {
|
|||
case MethodType(paramTypes, resType) =>
|
||||
assert(params.length == paramTypes.length)
|
||||
atPos(tree.pos)(thisTyper.typed {
|
||||
fixResult(if (isValueClass(resType.symbol)) boxedClass(resType.symbol).tpe else resType) {
|
||||
fixResult(if (isValueClass(resType.typeSymbol)) boxedClass(resType.typeSymbol).tpe else resType) {
|
||||
Apply(
|
||||
Select(
|
||||
Apply(
|
||||
|
@ -309,8 +309,8 @@ abstract class CleanUp extends Transform {
|
|||
val tpe = c.typeValue
|
||||
atPos(tree.pos) {
|
||||
localTyper.typed {
|
||||
if (isValueClass(tpe.symbol) && !forCLDC)
|
||||
Select(gen.mkAttributedRef(javaBoxClassModule(tpe.symbol)), "TYPE")
|
||||
if (isValueClass(tpe.typeSymbol) && !forCLDC)
|
||||
Select(gen.mkAttributedRef(javaBoxClassModule(tpe.typeSymbol)), "TYPE")
|
||||
else if (settings.target.value != "jvm-1.5")
|
||||
Apply(
|
||||
gen.mkAttributedRef(classConstantMethod(tree.pos, signature(tpe))),
|
||||
|
|
|
@ -86,7 +86,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
case MethodType(formals, restpe) =>
|
||||
MethodType(
|
||||
formals map apply,
|
||||
if (restpe.symbol == UnitClass) erasedTypeRef(UnitClass) else apply(restpe))
|
||||
if (restpe.typeSymbol == UnitClass) erasedTypeRef(UnitClass) else apply(restpe))
|
||||
case RefinedType(parents, decls) =>
|
||||
if (parents.isEmpty) erasedTypeRef(ObjectClass)
|
||||
else apply(parents.head)
|
||||
|
@ -114,7 +114,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.typeSymbol == ObjectClass) tp :: tps1.filter(_.typeSymbol != ObjectClass)
|
||||
else tp :: removeDoubleObject(tps1)
|
||||
}
|
||||
|
||||
|
@ -192,17 +192,17 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
case _ =>
|
||||
typed {
|
||||
atPos(tree.pos) {
|
||||
val sym = tree.tpe.symbol;
|
||||
val sym = tree.tpe.typeSymbol;
|
||||
if (sym == UnitClass) {
|
||||
if (treeInfo.isPureExpr(tree)) gen.mkAttributedRef(BoxedUnit_UNIT)
|
||||
else Block(List(tree), gen.mkAttributedRef(BoxedUnit_UNIT))
|
||||
} else if (sym == ArrayClass) {
|
||||
val elemClass = tree.tpe.typeArgs.head.symbol;
|
||||
val elemClass = tree.tpe.typeArgs.head.typeSymbol;
|
||||
val boxedClass = if (isValueClass(elemClass)) boxedArrayClass(elemClass)
|
||||
else BoxedObjectArrayClass;
|
||||
Apply(Select(New(TypeTree(boxedClass.tpe)), nme.CONSTRUCTOR), List(tree))
|
||||
} else {
|
||||
Apply(gen.mkAttributedRef(boxMethod(tree.tpe.symbol)), List(tree)).
|
||||
Apply(gen.mkAttributedRef(boxMethod(tree.tpe.typeSymbol)), List(tree)).
|
||||
setPos(tree.pos) setType ObjectClass.tpe
|
||||
}
|
||||
}
|
||||
|
@ -235,17 +235,17 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
case _ =>
|
||||
typed {
|
||||
atPos(tree.pos) {
|
||||
if (pt.symbol == UnitClass) {
|
||||
if (pt.typeSymbol == UnitClass) {
|
||||
if (treeInfo.isPureExpr(tree)) Literal(())
|
||||
else Block(List(tree), Literal(()))
|
||||
}
|
||||
else if (pt.symbol == ArrayClass) {
|
||||
else if (pt.typeSymbol == ArrayClass) {
|
||||
val tree1 = adaptToType(tree, BoxedArrayClass.tpe)
|
||||
gen.mkRuntimeCall(nme.arrayValue, List(tree1, Literal(pt.typeArgs.head)))
|
||||
}
|
||||
else {
|
||||
atPos(tree.pos) {
|
||||
Apply(gen.mkAttributedRef(unboxMethod(pt.symbol)), List(tree)) setType pt
|
||||
Apply(gen.mkAttributedRef(unboxMethod(pt.typeSymbol)), List(tree)) setType pt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,8 +274,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
private def cast(tree: Tree, pt: Type): Tree = {
|
||||
assert(pt eq pt.normalize)
|
||||
|
||||
if (tree.tpe.symbol == ObjectClass) {
|
||||
if (pt.symbol == ArrayClass)
|
||||
if (tree.tpe.typeSymbol == ObjectClass) {
|
||||
if (pt.typeSymbol == ArrayClass)
|
||||
typed {
|
||||
atPos(tree.pos) {
|
||||
gen.evalOnce(tree, context.owner, context.unit) { x =>
|
||||
|
@ -292,7 +292,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (pt.symbol isNonBottomSubClass BoxedArrayClass)
|
||||
else if (pt.typeSymbol isNonBottomSubClass BoxedArrayClass)
|
||||
typed {
|
||||
atPos(tree.pos) {
|
||||
gen.evalOnce(tree, context.owner, context.unit) { x =>
|
||||
|
@ -309,7 +309,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (isSeqClass(pt.symbol))
|
||||
else if (isSeqClass(pt.typeSymbol))
|
||||
typed {
|
||||
atPos(tree.pos) {
|
||||
gen.evalOnce(tree, context.owner, context.unit) { x =>
|
||||
|
@ -354,14 +354,14 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
log("adapting " + tree + ":" + tree.tpe + " : " + tree.tpe.parents + " to " + pt)//debug
|
||||
if (tree.tpe <:< pt)
|
||||
tree
|
||||
else if (isUnboxedClass(tree.tpe.symbol) && !isUnboxedClass(pt.symbol))
|
||||
else if (isUnboxedClass(tree.tpe.typeSymbol) && !isUnboxedClass(pt.typeSymbol))
|
||||
adaptToType(box(tree), pt)
|
||||
else if (tree.tpe.isInstanceOf[MethodType] && tree.tpe.paramTypes.isEmpty) {
|
||||
if (!tree.symbol.isStable) assert(false, "adapt "+tree+":"+tree.tpe+" to "+pt)
|
||||
adaptToType(Apply(tree, List()) setPos tree.pos setType tree.tpe.resultType, pt)
|
||||
} else if (pt <:< tree.tpe)
|
||||
cast(tree, pt)
|
||||
else if (isUnboxedClass(pt.symbol) && !isUnboxedClass(tree.tpe.symbol))
|
||||
else if (isUnboxedClass(pt.typeSymbol) && !isUnboxedClass(tree.tpe.typeSymbol))
|
||||
adaptToType(unbox(tree, pt), pt)
|
||||
else
|
||||
cast(tree, pt)
|
||||
|
@ -426,7 +426,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
private def adaptMember(tree: Tree): Tree = {
|
||||
//Console.println("adaptMember: " + tree);
|
||||
tree match {
|
||||
case Apply(Select(New(tpt), name), args) if (tpt.tpe.symbol == BoxedArrayClass) =>
|
||||
case Apply(Select(New(tpt), name), args) if (tpt.tpe.typeSymbol == BoxedArrayClass) =>
|
||||
assert(name == nme.CONSTRUCTOR);
|
||||
atPos(tree.pos) {
|
||||
Typed(Apply(Select(New(TypeTree(BoxedAnyArrayClass.tpe)), name), args), tpt)
|
||||
|
@ -434,8 +434,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List())
|
||||
if ((tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased)) =>
|
||||
val qual1 = typedQualifier(qual)
|
||||
val qualClass = qual1.tpe.symbol
|
||||
val targClass = targ.tpe.symbol
|
||||
val qualClass = qual1.tpe.typeSymbol
|
||||
val targClass = targ.tpe.typeSymbol
|
||||
if (isNumericValueClass(qualClass) && isNumericValueClass(targClass))
|
||||
// convert numeric type casts
|
||||
atPos(tree.pos)(Apply(Select(qual1, "to" + targClass.name), List()))
|
||||
|
@ -457,20 +457,20 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
adaptMember(atPos(tree.pos)(Select(qual, getMember(ObjectClass, name))))
|
||||
else {
|
||||
var qual1 = typedQualifier(qual);
|
||||
if ((isValueType(qual1.tpe.symbol) && !isUnboxedValueMember(tree.symbol)) ||
|
||||
(qual1.tpe.symbol == ArrayClass && !isUnboxedArrayMember(tree.symbol)))
|
||||
if ((isValueType(qual1.tpe.typeSymbol) && !isUnboxedValueMember(tree.symbol)) ||
|
||||
(qual1.tpe.typeSymbol == ArrayClass && !isUnboxedArrayMember(tree.symbol)))
|
||||
qual1 = box(qual1);
|
||||
else if (!isValueType(qual1.tpe.symbol) && isUnboxedValueMember(tree.symbol))
|
||||
else if (!isValueType(qual1.tpe.typeSymbol) && isUnboxedValueMember(tree.symbol))
|
||||
qual1 = unbox(qual1, tree.symbol.owner.tpe)
|
||||
else if (tree.symbol.owner == ArrayClass && qual1.tpe.symbol == ObjectClass)
|
||||
else if (tree.symbol.owner == ArrayClass && qual1.tpe.typeSymbol == ObjectClass)
|
||||
qual1 = cast(qual1, BoxedArrayClass.tpe)
|
||||
|
||||
if (isUnboxedClass(tree.symbol.owner) && !isUnboxedClass(qual1.tpe.symbol))
|
||||
if (isUnboxedClass(tree.symbol.owner) && !isUnboxedClass(qual1.tpe.typeSymbol))
|
||||
tree.symbol = NoSymbol
|
||||
else if (qual1.tpe.isInstanceOf[MethodType] && qual1.tpe.paramTypes.isEmpty) {
|
||||
assert(qual1.symbol.isStable, qual1.symbol);
|
||||
qual1 = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType;
|
||||
} else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.symbol isSubClass tree.symbol.owner)))
|
||||
} else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.typeSymbol isSubClass tree.symbol.owner)))
|
||||
qual1 = cast(qual1, tree.symbol.owner.tpe);
|
||||
copy.Select(tree, qual1, name)
|
||||
}
|
||||
|
@ -764,11 +764,11 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
// leave all other type tests/type casts, remove all other type applications
|
||||
fun
|
||||
case Apply(fn, args) =>
|
||||
def isGenericArray(tpe: Type): boolean = erasure(tpe).symbol == BoxedArrayClass
|
||||
def isGenericArray(tpe: Type): boolean = erasure(tpe).typeSymbol == BoxedArrayClass
|
||||
if (fn.hasSymbol &&
|
||||
fn.symbol.name == nme.arraycopy &&
|
||||
fn.symbol.owner.name == nme.System.toTypeName &&
|
||||
fn.symbol.owner.owner == JavaLangPackage.tpe.symbol &&
|
||||
fn.symbol.owner.owner == JavaLangPackage.tpe.typeSymbol &&
|
||||
args.length == 5 &&
|
||||
(isGenericArray(args(0).tpe) || isGenericArray(args(2).tpe)))
|
||||
unit.warning(tree.pos,
|
||||
|
@ -805,7 +805,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
|
|||
}
|
||||
}
|
||||
case _ =>
|
||||
if (isSeqClass(targ.tpe.symbol)) {
|
||||
if (isSeqClass(targ.tpe.typeSymbol)) {
|
||||
atPos(tree.pos) {
|
||||
gen.evalOnce(qual, currentOwner, unit) { q =>
|
||||
gen.mkOr(
|
||||
|
|
|
@ -40,9 +40,9 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter
|
|||
/** Does given <code>clazz</code> define an outer field? */
|
||||
def hasOuterField(clazz: Symbol) = {
|
||||
def hasSameOuter(parent: Type) =
|
||||
parent.symbol.isClass &&
|
||||
parent.typeSymbol.isClass &&
|
||||
clazz.owner.isClass &&
|
||||
clazz.owner == parent.symbol.owner &&
|
||||
clazz.owner == parent.typeSymbol.owner &&
|
||||
parent.prefix =:= clazz.owner.thisType
|
||||
isInner(clazz) && !clazz.isTrait &&
|
||||
(clazz.info.parents.isEmpty || !hasSameOuter(clazz.info.parents.head))
|
||||
|
@ -167,7 +167,7 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter
|
|||
* The result is typed but not positioned.
|
||||
*/
|
||||
private def outerSelect(base: Tree): Tree =
|
||||
localTyper.typed(Apply(Select(base, outerAccessor(base.tpe.symbol)), List()))
|
||||
localTyper.typed(Apply(Select(base, outerAccessor(base.tpe.typeSymbol)), List()))
|
||||
|
||||
/** The path
|
||||
* <blockquote><pre>`base'.$outer$$C1 ... .$outer$$Cn</pre></blockquote>
|
||||
|
@ -367,7 +367,7 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter
|
|||
case Select(qual, name) =>
|
||||
if (currentClass != sym.owner/* && currentClass != sym.moduleClass*/) // (3)
|
||||
sym.makeNotPrivate(sym.owner)
|
||||
val qsym = qual.tpe.widen.symbol
|
||||
val qsym = qual.tpe.widen.typeSymbol
|
||||
if ((sym hasFlag PROTECTED) && //(4)
|
||||
(qsym.isTrait || !(qual.isInstanceOf[Super] || (qsym isSubClass currentClass))))
|
||||
sym setFlag notPROTECTED
|
||||
|
@ -413,7 +413,7 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter
|
|||
|
||||
var checkExhaustive = true
|
||||
def isUnsealedAnnotation(tpe: Type) = tpe match {
|
||||
case AnnotatedType(List(AnnotationInfo(atp, _, _)), _) if atp.symbol == UncheckedClass =>
|
||||
case AnnotatedType(List(AnnotationInfo(atp, _, _)), _) if atp.typeSymbol == UncheckedClass =>
|
||||
true
|
||||
case _ =>
|
||||
false
|
||||
|
|
|
@ -33,7 +33,7 @@ abstract class Flatten extends InfoTransform {
|
|||
|
||||
private val flattened = new TypeMap {
|
||||
def apply(tp: Type): Type = tp match {
|
||||
case TypeRef(pre, sym, args) if (pre.symbol.isClass && !pre.symbol.isPackageClass) =>
|
||||
case TypeRef(pre, sym, args) if (pre.typeSymbol.isClass && !pre.typeSymbol.isPackageClass) =>
|
||||
assert(args.isEmpty)
|
||||
typeRef(sym.toplevelClass.owner.thisType, sym, args)
|
||||
case ClassInfoType(parents, decls, clazz) =>
|
||||
|
|
|
@ -152,7 +152,7 @@ abstract class LambdaLift extends InfoTransform {
|
|||
if (settings.debug.value) log("" + sym + " is free in " + owner);
|
||||
if (sym.isVariable && !(sym hasFlag CAPTURED)) {
|
||||
sym setFlag CAPTURED
|
||||
val symClass = sym.tpe.symbol;
|
||||
val symClass = sym.tpe.typeSymbol;
|
||||
atPhase(phase.next) {
|
||||
sym updateInfo (
|
||||
if (isValueClass(symClass)) refClass(symClass).tpe else ObjectRefClass.tpe)
|
||||
|
@ -385,7 +385,7 @@ abstract class LambdaLift extends InfoTransform {
|
|||
atPos(tree.pos) {
|
||||
val tp = tree.tpe
|
||||
val elemTree = typed { Select(tree1 setType sym.tpe, nme.elem) }
|
||||
if (elemTree.tpe.symbol != tp.symbol) gen.mkAttributedCast(elemTree, tp) else elemTree
|
||||
if (elemTree.tpe.typeSymbol != tp.typeSymbol) gen.mkAttributedCast(elemTree, tp) else elemTree
|
||||
}
|
||||
else tree1
|
||||
case _ =>
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract class Mixin extends InfoTransform {
|
|||
* maps all other types to themselves.
|
||||
*/
|
||||
private def toInterface(tp: Type): Type =
|
||||
atPhase(currentRun.mixinPhase)(tp.symbol.toInterface).tpe
|
||||
atPhase(currentRun.mixinPhase)(tp.typeSymbol.toInterface).tpe
|
||||
|
||||
/** Maps all parts of this type that refer to implementation classes to
|
||||
* their corresponding interfaces.
|
||||
|
@ -377,7 +377,7 @@ abstract class Mixin extends InfoTransform {
|
|||
EmptyTree
|
||||
}
|
||||
case Apply(tapp @ TypeApply(fn, List(arg)), List()) =>
|
||||
if (arg.tpe.symbol.isImplClass) {
|
||||
if (arg.tpe.typeSymbol.isImplClass) {
|
||||
val ifacetpe = toInterface(arg.tpe)
|
||||
arg.tpe = ifacetpe
|
||||
tapp.tpe = MethodType(List(), ifacetpe)
|
||||
|
@ -666,7 +666,7 @@ abstract class Mixin extends InfoTransform {
|
|||
|
||||
// change every node type that refers to an implementation class to its
|
||||
// corresponding interface, unless the node's symbol is an implementation class.
|
||||
if (tree.tpe.symbol.isImplClass &&
|
||||
if (tree.tpe.typeSymbol.isImplClass &&
|
||||
((tree.symbol eq null) || !tree.symbol.isImplClass))
|
||||
tree.tpe = toInterface(tree.tpe);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ abstract class OverridingPairs {
|
|||
{ for (val i <- List.range(0, size))
|
||||
subParents(i) = new BitSet(size);
|
||||
for (val p <- parents) {
|
||||
val pIndex = index(p.symbol)
|
||||
val pIndex = index(p.typeSymbol)
|
||||
for (val bc <- p.baseClasses) include(subParents(index(bc)), pIndex)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,7 +237,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.typeSymbol)) &&
|
||||
isRecursiveCall(fun))
|
||||
rewriteTailCall(fun, transformTrees(vargs, mkContext(ctx, false)))
|
||||
else
|
||||
|
|
|
@ -60,7 +60,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
|
|||
apply(MethodType(List(), restpe))
|
||||
case PolyType(tparams, restpe) =>
|
||||
PolyType(tparams, apply(MethodType(List(), restpe)))
|
||||
case TypeRef(pre, sym, List(arg1, arg2)) if (arg1.symbol == ByNameParamClass) =>
|
||||
case TypeRef(pre, sym, List(arg1, arg2)) if (arg1.typeSymbol == ByNameParamClass) =>
|
||||
assert(sym == FunctionClass(1))
|
||||
apply(typeRef(pre, definitions.ByNameFunctionClass, List(expandAlias(arg1.typeArgs(0)), arg2)))
|
||||
case TypeRef(pre, sym, List(arg)) if (sym == ByNameParamClass) =>
|
||||
|
@ -115,7 +115,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
|
|||
*/
|
||||
def isByNameRef(tree: Tree): boolean =
|
||||
tree.isTerm && tree.hasSymbol &&
|
||||
tree.symbol.tpe.symbol == ByNameParamClass &&
|
||||
tree.symbol.tpe.typeSymbol == ByNameParamClass &&
|
||||
!byNameArgs.contains(tree)
|
||||
|
||||
/** Uncurry a type of a tree node.
|
||||
|
@ -267,7 +267,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
|
|||
var members = List(
|
||||
DefDef(Modifiers(FINAL), nme.apply, List(), List(fun.vparams), TypeTree(restpe), fun.body)
|
||||
setSymbol applyMethod);
|
||||
if (fun.tpe.symbol == PartialFunctionClass) {
|
||||
if (fun.tpe.typeSymbol == PartialFunctionClass) {
|
||||
val isDefinedAtMethod = anonClass.newMethod(fun.pos, nme.isDefinedAt)
|
||||
.setFlag(FINAL).setInfo(MethodType(formals, BooleanClass.tpe))
|
||||
anonClass.info.decls enter isDefinedAtMethod
|
||||
|
@ -323,7 +323,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
|
|||
case _ => args
|
||||
}
|
||||
List.map2(formals, args1) { (formal, arg) =>
|
||||
if (formal.symbol != ByNameParamClass) {
|
||||
if (formal.typeSymbol != ByNameParamClass) {
|
||||
arg
|
||||
} else if (isByNameRef(arg)) {
|
||||
byNameArgs.addEntry(arg)
|
||||
|
@ -518,7 +518,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
|
|||
applyUnary(tree);
|
||||
case Select(qual, name) =>
|
||||
/* Function1.apply to ByNameFunction.apply if qualifier is a ByNameFunction */
|
||||
if (qual.tpe.symbol == ByNameFunctionClass) {
|
||||
if (qual.tpe.typeSymbol == ByNameFunctionClass) {
|
||||
assert(tree.symbol.name == nme.apply && tree.symbol.owner == FunctionClass(1), tree.symbol)
|
||||
tree.symbol = getMember(ByNameFunctionClass, nme.apply)
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ trait Contexts { self: Analyzer =>
|
|||
|
||||
(pre == NoPrefix) || {
|
||||
val ab = sym.accessBoundary(sym.owner)
|
||||
((ab == NoSymbol)
|
||||
((ab.isTerm || ab == definitions.RootClass)
|
||||
||
|
||||
(accessWithin(ab) || accessWithin(ab.linkedClassOfClass)) &&
|
||||
(!sym.hasFlag(LOCAL) ||
|
||||
|
@ -391,8 +391,8 @@ trait Contexts { self: Analyzer =>
|
|||
||
|
||||
(sym hasFlag PROTECTED) &&
|
||||
(superAccess ||
|
||||
(pre.widen.symbol.isNonBottomSubClass(sym.owner) &&
|
||||
(isSubClassOfEnclosing(pre.widen.symbol) || phase.erasedTypes))))
|
||||
(pre.widen.typeSymbol.isNonBottomSubClass(sym.owner) &&
|
||||
(isSubClassOfEnclosing(pre.widen.typeSymbol) || phase.erasedTypes))))
|
||||
// note: phase.erasedTypes disables last test, because fater addinterfaces
|
||||
// implementation classes are not in the superclass chain. If we enable the
|
||||
// test, bug780 fails.
|
||||
|
|
|
@ -31,7 +31,7 @@ trait Infer {
|
|||
assert(tvar.constr.inst != tvar, tvar.origin)
|
||||
|
||||
def isVarArgs(formals: List[Type]) =
|
||||
!formals.isEmpty && (formals.last.symbol == RepeatedParamClass)
|
||||
!formals.isEmpty && (formals.last.typeSymbol == RepeatedParamClass)
|
||||
|
||||
/** The formal parameter types corresponding to <code>formals</code>.
|
||||
* If <code>formals</code> has a repeated last parameter, a list of
|
||||
|
@ -360,7 +360,7 @@ trait Infer {
|
|||
}
|
||||
|
||||
def isWeaklyCompatible(tp: Type, pt: Type): boolean =
|
||||
pt.symbol == UnitClass || isCompatible(tp, pt)
|
||||
pt.typeSymbol == UnitClass || isCompatible(tp, pt)
|
||||
|
||||
def isCoercible(tp: Type, pt: Type): boolean = false
|
||||
|
||||
|
@ -490,12 +490,13 @@ trait Infer {
|
|||
}
|
||||
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) {
|
||||
if (targ.typeSymbol == AllClass && (varianceInType(restpe)(tparam) & COVARIANT) == 0) {
|
||||
uninstantiated += tparam
|
||||
tparam.tpe //@M TODO: might be affected by change to tpe in Symbol
|
||||
} else targ}
|
||||
} else targ.widen
|
||||
}
|
||||
// println("meth type args "+", tparams = "+tparams+", formals = "+formals+", restpe = "+restpe+", argtpes = "+argtpes+", underlying = "+(argtpes map (_.widen))+", pt = "+pt+", uninstantiated = "+uninstantiated.toList+", result = "+res) //DEBUG
|
||||
}
|
||||
|
||||
|
||||
/** Is there an instantiation of free type variables <code>undetparams</code>
|
||||
* such that function type <code>ftpe</code> is applicable to
|
||||
|
@ -796,8 +797,8 @@ trait Infer {
|
|||
tparam.variance != 0 || arg1 =:= arg2
|
||||
} contains false)
|
||||
}
|
||||
if (tp1.symbol.isClass && tp1.symbol.hasFlag(FINAL))
|
||||
tp1 <:< tp2 || isNumericValueClass(tp1.symbol) && isNumericValueClass(tp2.symbol)
|
||||
if (tp1.typeSymbol.isClass && tp1.typeSymbol.hasFlag(FINAL))
|
||||
tp1 <:< tp2 || isNumericValueClass(tp1.typeSymbol) && isNumericValueClass(tp2.typeSymbol)
|
||||
else tp1.baseClasses forall (bc =>
|
||||
tp2.closurePos(bc) < 0 || isConsistent(tp1.baseType(bc), tp2.baseType(bc)))
|
||||
}
|
||||
|
@ -866,7 +867,7 @@ trait Infer {
|
|||
}
|
||||
|
||||
def instantiateTypeVar(tvar: TypeVar) = {
|
||||
val tparam = tvar.origin.symbol
|
||||
val tparam = tvar.origin.typeSymbol
|
||||
if (false &&
|
||||
tvar.constr.inst != NoType &&
|
||||
isFullyDefined(tvar.constr.inst) &&
|
||||
|
@ -1040,7 +1041,7 @@ trait Infer {
|
|||
}
|
||||
|
||||
def checkDead(tree: Tree): Tree = {
|
||||
if (settings.Xwarndeadcode.value && tree.tpe.symbol == AllClass)
|
||||
if (settings.Xwarndeadcode.value && tree.tpe.typeSymbol == AllClass)
|
||||
context.warning (tree.pos, "dead code following this construct")
|
||||
tree
|
||||
}
|
||||
|
|
|
@ -374,9 +374,9 @@ trait Namers { self: Analyzer =>
|
|||
|
||||
def getterTypeCompleter(tree: Tree) = new TypeCompleter(tree) {
|
||||
override def complete(sym: Symbol) {
|
||||
if (settings.debug.value) log("defining " + sym);
|
||||
if (settings.debug.value) log("defining " + sym)
|
||||
sym.setInfo(PolyType(List(), typeSig(tree)))
|
||||
if (settings.debug.value) log("defined " + sym);
|
||||
if (settings.debug.value) log("defined " + sym)
|
||||
validate(sym)
|
||||
}
|
||||
}
|
||||
|
@ -406,12 +406,27 @@ trait Namers { self: Analyzer =>
|
|||
}
|
||||
}
|
||||
|
||||
private def deconstIfNotFinal(sym: Symbol, tpe: Type): Type =
|
||||
private def widenIfNotFinal(sym: Symbol, tpe: Type): Type = {
|
||||
val getter =
|
||||
if (sym.isValue && sym.owner.isClass && (sym hasFlag PRIVATE))
|
||||
sym.getter(sym.owner)
|
||||
else sym
|
||||
def isHidden(tp: Type): Boolean = tp match {
|
||||
case SingleType(pre, sym) =>
|
||||
(sym isLessAccessibleThan getter) || isHidden(pre)
|
||||
case ThisType(sym) =>
|
||||
sym isLessAccessibleThan getter
|
||||
case p: TypeProxy =>
|
||||
isHidden(p.tp)
|
||||
case _ =>
|
||||
false
|
||||
}
|
||||
if (sym.isVariable ||
|
||||
!(sym hasFlag FINAL) ||
|
||||
sym.isMethod && !(sym hasFlag ACCESSOR)) tpe.deconst
|
||||
else tpe;
|
||||
|
||||
sym.isMethod && !(sym hasFlag ACCESSOR) ||
|
||||
isHidden(tpe)) tpe.widen
|
||||
else if (!(sym hasFlag FINAL)) tpe.deconst
|
||||
else tpe
|
||||
}
|
||||
|
||||
def enterValueParams(owner: Symbol, vparamss: List[List[ValDef]]): List[List[Symbol]] = {
|
||||
def enterValueParam(param: ValDef): Symbol = if (doEnterValueParams) {
|
||||
|
@ -429,8 +444,8 @@ trait Namers { self: Analyzer =>
|
|||
val clazz = context.owner
|
||||
def checkParent(tpt: Tree): Type = {
|
||||
val tp = tpt.tpe
|
||||
if (tp.symbol == context.owner) {
|
||||
context.error(tpt.pos, ""+tp.symbol+" inherits itself")
|
||||
if (tp.typeSymbol == context.owner) {
|
||||
context.error(tpt.pos, ""+tp.typeSymbol+" inherits itself")
|
||||
AnyRefClass.tpe
|
||||
} else if (tp.isError) {
|
||||
AnyRefClass.tpe
|
||||
|
@ -481,11 +496,14 @@ trait Namers { self: Analyzer =>
|
|||
def apply(tp: Type) = {
|
||||
tp match {
|
||||
case SingleType(_, sym) =>
|
||||
if (settings.Xexperimental.value && sym.owner == meth && (vparams contains sym)) {
|
||||
if (sym.owner == meth && (vparams contains sym)) {
|
||||
/*
|
||||
if (sym hasFlag IMPLICIT) {
|
||||
context.error(sym.pos, "illegal type dependence on implicit parameter")
|
||||
ErrorType
|
||||
} else DeBruijnIndex(level, vparams indexOf sym)
|
||||
} else
|
||||
*/
|
||||
DeBruijnIndex(level, vparams indexOf sym)
|
||||
} else tp
|
||||
case MethodType(formals, restpe) =>
|
||||
val formals1 = List.mapConserve(formals)(this)
|
||||
|
@ -502,8 +520,7 @@ trait Namers { self: Analyzer =>
|
|||
def traverse(tp: Type) = {
|
||||
tp match {
|
||||
case SingleType(_, sym) =>
|
||||
if (settings.Xexperimental.value && sym.owner == meth &&
|
||||
(vparamSymss exists (_ contains sym)))
|
||||
if (sym.owner == meth && (vparamSymss exists (_ contains sym)))
|
||||
context.error(
|
||||
sym.pos,
|
||||
"illegal dependent method type: parameter appears in the type "+
|
||||
|
@ -583,7 +600,7 @@ trait Namers { self: Analyzer =>
|
|||
thisMethodType(
|
||||
if (tpt.isEmpty) {
|
||||
val pt = resultPt.substSym(tparamSyms, tparams map (_.symbol))
|
||||
tpt.tpe = deconstIfNotFinal(meth, typer.computeType(rhs, pt))
|
||||
tpt.tpe = widenIfNotFinal(meth, typer.computeType(rhs, pt))
|
||||
tpt.tpe
|
||||
} else typer.typedType(tpt).tpe)
|
||||
}
|
||||
|
@ -676,7 +693,7 @@ trait Namers { self: Analyzer =>
|
|||
context.error(tpt.pos, "missing parameter type");
|
||||
ErrorType
|
||||
} else {
|
||||
tpt.tpe = deconstIfNotFinal(sym,
|
||||
tpt.tpe = widenIfNotFinal(sym,
|
||||
newTyper(typer1.context.make(vdef, sym)).computeType(rhs, WildcardType))
|
||||
tpt.tpe
|
||||
}
|
||||
|
@ -764,7 +781,7 @@ trait Namers { self: Analyzer =>
|
|||
context.error(sym.pos, "`override' modifier not allowed for constructors")
|
||||
if (sym.hasFlag(ABSOVERRIDE) && !sym.owner.isTrait)
|
||||
context.error(sym.pos, "`abstract override' modifier only allowed for members of traits")
|
||||
if (sym.info.symbol == FunctionClass(0) &&
|
||||
if (sym.info.typeSymbol == FunctionClass(0) &&
|
||||
sym.isValueParameter && sym.owner.isClass && sym.owner.hasFlag(CASE))
|
||||
context.error(sym.pos, "pass-by-name arguments not allowed for case class parameters");
|
||||
if ((sym.flags & DEFERRED) != 0) {
|
||||
|
|
|
@ -150,13 +150,13 @@ abstract class RefChecks extends InfoTransform {
|
|||
return;
|
||||
}
|
||||
if (clazz.info.parents exists (parent =>
|
||||
(parent.symbol isSubClass other.owner) && (parent.symbol isSubClass member.owner) &&
|
||||
(parent.typeSymbol isSubClass other.owner) && (parent.typeSymbol isSubClass member.owner) &&
|
||||
((member hasFlag DEFERRED) || !(other hasFlag DEFERRED)))) {
|
||||
//Console.println(infoString(member) + " shadows2 " + infoString(other) + " in " + clazz);//DEBUG
|
||||
return;
|
||||
}
|
||||
if (clazz.info.parents forall (parent =>
|
||||
(parent.symbol isSubClass other.owner) == (parent.symbol isSubClass member.owner))) {
|
||||
(parent.typeSymbol isSubClass other.owner) == (parent.typeSymbol isSubClass member.owner))) {
|
||||
//Console.println(infoString(member) + " shadows " + infoString(other) + " in " + clazz);//DEBUG
|
||||
return;
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ abstract class RefChecks extends InfoTransform {
|
|||
}
|
||||
val mb = member.accessBoundary(member.owner)
|
||||
val ob = other.accessBoundary(member.owner)
|
||||
if (mb != NoSymbol &&
|
||||
(ob == NoSymbol ||
|
||||
if (mb != RootClass && mb != NoSymbol && // todo: change
|
||||
(ob == RootClass || ob == NoSymbol ||
|
||||
mb != ob && !(ob.ownerChain contains mb) ||
|
||||
(other hasFlag PROTECTED) && !(member hasFlag PROTECTED))) {
|
||||
overrideAccessError()
|
||||
|
@ -274,8 +274,8 @@ abstract class RefChecks extends InfoTransform {
|
|||
}
|
||||
}
|
||||
val parents = bc.info.parents
|
||||
if (!parents.isEmpty && parents.head.symbol.hasFlag(ABSTRACT))
|
||||
checkNoAbstractDecls(parents.head.symbol)
|
||||
if (!parents.isEmpty && parents.head.typeSymbol.hasFlag(ABSTRACT))
|
||||
checkNoAbstractDecls(parents.head.typeSymbol)
|
||||
}
|
||||
if (!(clazz hasFlag ABSTRACT)) checkNoAbstractDecls(clazz)
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ abstract class RefChecks extends InfoTransform {
|
|||
}
|
||||
|
||||
def validateType(tp: Type, includeSuper: boolean): unit = {
|
||||
val baseClass = tp.symbol
|
||||
val baseClass = tp.typeSymbol
|
||||
if (baseClass.isClass) {
|
||||
val index = clazz.info.closurePos(baseClass)
|
||||
if (index >= 0) {
|
||||
|
@ -523,9 +523,9 @@ abstract class RefChecks extends InfoTransform {
|
|||
name match {
|
||||
case nme.EQ | nme.NE | nme.LT | nme.GT | nme.LE | nme.GE =>
|
||||
def underlyingClass(tp: Type): Symbol = {
|
||||
var sym = tp.widen.symbol
|
||||
var sym = tp.widen.typeSymbol
|
||||
while (sym.isAbstractType)
|
||||
sym = sym.info.bounds.hi.widen.symbol
|
||||
sym = sym.info.bounds.hi.widen.typeSymbol
|
||||
sym
|
||||
}
|
||||
val formal = underlyingClass(fn.tpe.paramTypes.head)
|
||||
|
@ -536,7 +536,7 @@ abstract class RefChecks extends InfoTransform {
|
|||
(alwaysEqual == (name == nme.EQ || name == nme.LE || name == nme.GE)))
|
||||
def nonSensible(pre: String, alwaysEqual: boolean) =
|
||||
nonSensibleWarning(pre+"values of types "+normalizeAll(qual.tpe.widen)+" and "+normalizeAll(args.head.tpe.widen),
|
||||
alwaysEqual) // @MAT normalize for consistency in error message, otherwise part is normalized due to use of `symbol', but the rest isn't
|
||||
alwaysEqual) // @MAT normalize for consistency in error message, otherwise part is normalized due to use of `typeSymbol', but the rest isn't
|
||||
def hasObjectEquals = receiver.info.member(nme.equals_) == Object_equals
|
||||
if (formal == UnitClass && actual == UnitClass)
|
||||
nonSensible("", true)
|
||||
|
@ -563,10 +563,10 @@ abstract class RefChecks extends InfoTransform {
|
|||
/* Convert a reference to a case factory of type `tpe' to a new of the class it produces. */
|
||||
def toConstructor(pos: Position, tpe: Type): Tree = {
|
||||
var rtpe = tpe.finalResultType
|
||||
assert(rtpe.symbol hasFlag CASE, tpe);
|
||||
assert(rtpe.typeSymbol hasFlag CASE, tpe);
|
||||
localTyper.typedOperator {
|
||||
atPos(pos) {
|
||||
Select(New(TypeTree(rtpe)), rtpe.symbol.primaryConstructor)
|
||||
Select(New(TypeTree(rtpe)), rtpe.typeSymbol.primaryConstructor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ abstract class RefChecks extends InfoTransform {
|
|||
} else {
|
||||
def mkArgument(vparam: Symbol) = {
|
||||
val id = Ident(vparam)
|
||||
if (vparam.tpe.symbol == RepeatedParamClass) Typed(id, Ident(nme.WILDCARD_STAR.toTypeName))
|
||||
if (vparam.tpe.typeSymbol == RepeatedParamClass) Typed(id, Ident(nme.WILDCARD_STAR.toTypeName))
|
||||
else id
|
||||
}
|
||||
val caseFactoryDef =
|
||||
|
@ -686,8 +686,8 @@ abstract class RefChecks extends InfoTransform {
|
|||
def isIrrefutable(pat: Tree, seltpe: Type): boolean = {
|
||||
val result = pat match {
|
||||
case Apply(_, args) =>
|
||||
val clazz = pat.tpe.symbol;
|
||||
clazz == seltpe.symbol &&
|
||||
val clazz = pat.tpe.typeSymbol;
|
||||
clazz == seltpe.typeSymbol &&
|
||||
clazz.isClass && (clazz hasFlag CASE) &&
|
||||
List.forall2(
|
||||
args,
|
||||
|
@ -779,7 +779,7 @@ abstract class RefChecks extends InfoTransform {
|
|||
}
|
||||
|
||||
case New(tpt) =>
|
||||
enterReference(tree.pos, tpt.tpe.symbol)
|
||||
enterReference(tree.pos, tpt.tpe.typeSymbol)
|
||||
|
||||
case Ident(name) =>
|
||||
if (sym.isSourceMethod && sym.hasFlag(CASE))
|
||||
|
|
|
@ -53,14 +53,14 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
|
|||
*/
|
||||
private def transformArgs(args: List[Tree], formals: List[Type]) =
|
||||
List.map2(args, formals){ (arg, formal) =>
|
||||
if (formal.symbol == definitions.ByNameParamClass)
|
||||
if (formal.typeSymbol == definitions.ByNameParamClass)
|
||||
withInvalidOwner { checkPackedConforms(transform(arg), formal.typeArgs.head) }
|
||||
else transform(arg)
|
||||
} :::
|
||||
(args drop formals.length map transform)
|
||||
|
||||
private def checkPackedConforms(tree: Tree, pt: Type): Tree = {
|
||||
if (tree.tpe exists (_.symbol.isExistentialSkolem)) {
|
||||
if (tree.tpe exists (_.typeSymbol.isExistentialSkolem)) {
|
||||
val packed = typer.packedType(tree, NoSymbol)
|
||||
if (!(packed <:< pt)) typer.infer.typeError(tree.pos, packed, pt)
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
|
|||
*/
|
||||
private def makeArg(v: Symbol, obj: Symbol, expectedTpe: Type): Tree = {
|
||||
val res = Ident(v)
|
||||
val sym = obj.tpe.symbol
|
||||
val sym = obj.tpe.typeSymbol
|
||||
var ownerClass: Symbol = NoSymbol
|
||||
|
||||
val isDependentType = expectedTpe match {
|
||||
|
@ -337,7 +337,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
|
|||
if (res) {
|
||||
val host = hostForAccessorOf(sym, currentOwner.enclClass)
|
||||
if (host.thisSym != host) {
|
||||
if (host.thisSym.tpe.symbol.hasFlag(JAVA) || currentOwner.enclClass.isTrait)
|
||||
if (host.thisSym.tpe.typeSymbol.hasFlag(JAVA) || currentOwner.enclClass.isTrait)
|
||||
unit.error(pos, "Implementation restriction: " + currentOwner.enclClass + " accesses protected "
|
||||
+ sym + " from self type " + host.thisSym.tpe)
|
||||
false
|
||||
|
|
|
@ -130,7 +130,7 @@ trait SyntheticMethods { self: Analyzer =>
|
|||
{ vparamss =>
|
||||
val that = Ident(vparamss.head.head)
|
||||
val constrParamTypes = clazz.primaryConstructor.tpe.paramTypes
|
||||
val hasVarArgs = !constrParamTypes.isEmpty && constrParamTypes.last.symbol == RepeatedParamClass
|
||||
val hasVarArgs = !constrParamTypes.isEmpty && constrParamTypes.last.typeSymbol == RepeatedParamClass
|
||||
if (clazz.isStatic) {
|
||||
val target = getMember(ScalaRunTimeModule, if (hasVarArgs) nme._equalsWithVarArgs else nme._equals)
|
||||
Apply(
|
||||
|
@ -147,7 +147,7 @@ trait SyntheticMethods { self: Analyzer =>
|
|||
val guards = new ListBuffer[Tree]
|
||||
val params = for ((acc, cpt) <- clazz.caseFieldAccessors zip constrParamTypes) yield {
|
||||
val name = context.unit.fresh.newName(acc.name+"$")
|
||||
val isVarArg = cpt.symbol == RepeatedParamClass
|
||||
val isVarArg = cpt.typeSymbol == RepeatedParamClass
|
||||
guards += Apply(
|
||||
Select(
|
||||
Ident(name),
|
||||
|
|
|
@ -176,8 +176,8 @@ trait Typers { self: Analyzer =>
|
|||
*/
|
||||
private def inferView(pos: Position, from: Type, name: Name, tp: Type, reportAmbiguous: Boolean): Tree = {
|
||||
val to = refinedType(List(WildcardType), NoSymbol)
|
||||
val psym = (if (name.isTypeName) to.symbol.newAbstractType(pos, name)
|
||||
else to.symbol.newValue(pos, name)) setInfo tp
|
||||
val psym = (if (name.isTypeName) to.typeSymbol.newAbstractType(pos, name)
|
||||
else to.typeSymbol.newValue(pos, name)) setInfo tp
|
||||
to.decls.enter(psym)
|
||||
inferView(pos, from, to, reportAmbiguous)
|
||||
}
|
||||
|
@ -286,9 +286,9 @@ trait Typers { self: Analyzer =>
|
|||
def checkParamsConvertible(pos: Position, tpe: Type) {
|
||||
tpe match {
|
||||
case MethodType(formals, restpe) =>
|
||||
if (formals.exists(_.symbol == ByNameParamClass) && formals.length != 1)
|
||||
if (formals.exists(_.typeSymbol == 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 (_.typeSymbol == 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");
|
||||
|
@ -342,8 +342,8 @@ trait Typers { self: Analyzer =>
|
|||
if (hiddenSymbols.isEmpty) tree setType tp1
|
||||
else if (hiddenSymbols exists (_.isErroneous)) setError(tree)
|
||||
else if (isFullyDefined(pt)) tree setType pt //todo: eliminate
|
||||
else if (tp1.symbol.isAnonymousClass) // todo: eliminate
|
||||
check(owner, scope, pt, tree setType anonymousClassRefinement(tp1.symbol))
|
||||
else if (tp1.typeSymbol.isAnonymousClass) // todo: eliminate
|
||||
check(owner, scope, pt, tree setType anonymousClassRefinement(tp1.typeSymbol))
|
||||
else if (owner == NoSymbol)
|
||||
tree setType packSymbols(hiddenSymbols.reverse, tp1)
|
||||
else { // privates
|
||||
|
@ -444,12 +444,16 @@ trait Typers { self: Analyzer =>
|
|||
typer1
|
||||
} else this
|
||||
|
||||
final val xtypes = false
|
||||
|
||||
/** Does the context of tree <code>tree</code> require a stable type?
|
||||
*/
|
||||
private def isStableContext(tree: Tree, mode: Int, pt: Type) =
|
||||
pt.isStable ||
|
||||
isNarrowable(tree.tpe) && ((mode & (EXPRmode | LHSmode)) == EXPRmode) &&
|
||||
(xtypes ||
|
||||
(pt.isStable ||
|
||||
(mode & QUALmode) != 0 && !tree.symbol.isConstant ||
|
||||
pt.symbol.isAbstractType && pt.bounds.lo.isStable && !(tree.tpe <:< pt)
|
||||
pt.typeSymbol.isAbstractType && pt.bounds.lo.isStable && !(tree.tpe <:< pt)))
|
||||
|
||||
/** <p>
|
||||
* Post-process an identifier or selection node, performing the following:
|
||||
|
@ -476,13 +480,36 @@ trait Typers { self: Analyzer =>
|
|||
} else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && !sym.isValue) { // (2)
|
||||
errorTree(tree, sym+" is not a value")
|
||||
} else {
|
||||
if (sym.isStable && pre.isStable && tree.tpe.symbol != ByNameParamClass &&
|
||||
if (sym.isStable && pre.isStable && tree.tpe.typeSymbol != ByNameParamClass &&
|
||||
(isStableContext(tree, mode, pt) || sym.isModule && !sym.isMethod))
|
||||
tree.setType(singleType(pre, sym))
|
||||
else tree
|
||||
}
|
||||
}
|
||||
|
||||
private def isNarrowable(tpe: Type): Boolean = tpe match {
|
||||
case TypeRef(_, _, _) | RefinedType(_, _) => true
|
||||
case ExistentialType(_, tpe1) => isNarrowable(tpe1)
|
||||
case AnnotatedType(_, tpe1) => isNarrowable(tpe1)
|
||||
case PolyType(_, tpe1) => isNarrowable(tpe1)
|
||||
case _ => !phase.erasedTypes
|
||||
}
|
||||
|
||||
private def stabilizedType(tree: Tree): Type = tree.tpe
|
||||
/*{
|
||||
val sym = tree.symbol
|
||||
val res = tree match {
|
||||
case Ident(_) if (sym.isStable) =>
|
||||
val pre = if (sym.owner.isClass) sym.owner.thisType else NoPrefix
|
||||
singleType(pre, sym)
|
||||
case Select(qual, _) if (qual.tpe.isStable && sym.isStable) =>
|
||||
singleType(qual.tpe, sym)
|
||||
case _ =>
|
||||
tree.tpe
|
||||
}
|
||||
res
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* @param tree ...
|
||||
* @param mode ...
|
||||
|
@ -634,7 +661,7 @@ trait Typers { self: Analyzer =>
|
|||
// @M: don't check tree.tpe.symbol.typeParams. check tree.tpe.typeParams!!!
|
||||
// (e.g., m[Int] --> tree.tpe.symbol.typeParams.length == 1, tree.tpe.typeParams.length == 0!)
|
||||
tree.tpe.typeParams.length != pt.typeParams.length &&
|
||||
!(tree.tpe.symbol==AnyClass || tree.tpe.symbol==AllClass || pt == WildcardType )) {
|
||||
!(tree.tpe.typeSymbol==AnyClass || tree.tpe.typeSymbol==AllClass || pt == WildcardType )) {
|
||||
// Check that the actual kind arity (tree.symbol.typeParams.length) conforms to the expected
|
||||
// kind-arity (pt.typeParams.length). Full checks are done in checkKindBounds in Infer.
|
||||
// Note that we treat Any and Nothing as kind-polymorphic.
|
||||
|
@ -650,7 +677,7 @@ trait Typers { self: Analyzer =>
|
|||
} else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode)) { // (5)
|
||||
val constr = tree.symbol.filter(_.isCaseFactory)
|
||||
if (constr != NoSymbol) {
|
||||
val clazz = constr.tpe.finalResultType.symbol
|
||||
val clazz = constr.tpe.finalResultType.typeSymbol
|
||||
assert(clazz hasFlag CASE, tree)
|
||||
val prefix = tree.tpe.finalResultType.prefix
|
||||
val tree1 = TypeTree(clazz.primaryConstructor.tpe.asSeenFrom(prefix, clazz.owner)) setOriginal tree
|
||||
|
@ -707,7 +734,7 @@ trait Typers { self: Analyzer =>
|
|||
if ((mode & (EXPRmode | FUNmode)) == EXPRmode) {
|
||||
pt.normalize match {
|
||||
case TypeRef(_, sym, _) =>
|
||||
// note: was if (pt.symbol == UnitClass) but this leads to a potentially
|
||||
// note: was if (pt.typeSymbol == UnitClass) but this leads to a potentially
|
||||
// infinite expansion if pt is constant type ()
|
||||
if (sym == UnitClass && tree.tpe <:< AnyClass.tpe) // (12)
|
||||
return typed(atPos(tree.pos)(Block(List(tree), Literal(()))), mode, pt)
|
||||
|
@ -769,7 +796,7 @@ trait Typers { self: Analyzer =>
|
|||
val qtpe = qual.tpe.widen
|
||||
if (qual.isTerm && ((qual.symbol eq null) || !qual.symbol.isTerm || qual.symbol.isValue) &&
|
||||
phase.id <= currentRun.typerPhase.id && !qtpe.isError && !tp.isError &&
|
||||
qtpe.symbol != AllRefClass && qtpe.symbol != AllClass && qtpe != WildcardType) {
|
||||
qtpe.typeSymbol != AllRefClass && qtpe.typeSymbol != AllClass && qtpe != WildcardType) {
|
||||
val coercion = inferView(qual.pos, qtpe, name, tp, true)
|
||||
if (coercion != EmptyTree)
|
||||
typedQualifier(atPos(qual.pos)(Apply(coercion, List(qual))))
|
||||
|
@ -794,10 +821,10 @@ trait Typers { self: Analyzer =>
|
|||
|
||||
// Normalize supertype and mixins so that supertype is always a class, not a trait.
|
||||
var supertpt = typedTypeConstructor(templ.parents.head)
|
||||
val firstParent = supertpt.tpe.symbol
|
||||
val firstParent = supertpt.tpe.typeSymbol
|
||||
var mixins = templ.parents.tail map typedType
|
||||
// If first parent is a trait, make it first mixin and add its superclass as first parent
|
||||
while ((supertpt.tpe.symbol ne null) && supertpt.tpe.symbol.initialize.isTrait) {
|
||||
while ((supertpt.tpe.typeSymbol ne null) && supertpt.tpe.typeSymbol.initialize.isTrait) {
|
||||
val supertpt1 = typedType(supertpt)
|
||||
if (!supertpt1.tpe.isError) {
|
||||
mixins = supertpt1 :: mixins
|
||||
|
@ -847,7 +874,7 @@ trait Typers { self: Analyzer =>
|
|||
scall match {
|
||||
case Apply(_, _) =>
|
||||
val sarg = treeInfo.firstArgument(scall)
|
||||
if (sarg != EmptyTree && supertpe.symbol != firstParent)
|
||||
if (sarg != EmptyTree && supertpe.typeSymbol != firstParent)
|
||||
error(sarg.pos, firstParent+" is a trait; does not take constructor arguments")
|
||||
if (!supertparams.isEmpty) supertpt = TypeTree(cbody2.tpe) setPos supertpt.pos
|
||||
case _ =>
|
||||
|
@ -888,15 +915,15 @@ trait Typers { self: Analyzer =>
|
|||
|
||||
def validateParentClass(parent: Tree, superclazz: Symbol) {
|
||||
if (!parent.tpe.isError) {
|
||||
val psym = parent.tpe.symbol.initialize
|
||||
val psym = parent.tpe.typeSymbol.initialize
|
||||
if (!psym.isClass) {
|
||||
error(parent.pos, "class type expected")
|
||||
} else if (psym != superclazz) {
|
||||
if (psym.isTrait) {
|
||||
val ps = psym.info.parents
|
||||
if (!ps.isEmpty && !superclazz.isSubClass(ps.head.symbol))
|
||||
if (!ps.isEmpty && !superclazz.isSubClass(ps.head.typeSymbol))
|
||||
error(parent.pos, "illegal inheritance; super"+superclazz+
|
||||
"\n is not a subclass of the super"+ps.head.symbol+
|
||||
"\n is not a subclass of the super"+ps.head.typeSymbol+
|
||||
"\n of the mixin " + psym);
|
||||
} else if (settings.migrate.value) {
|
||||
error(parent.pos, migrateMsg+psym+" needs to be a declared as a trait")
|
||||
|
@ -920,17 +947,17 @@ trait Typers { self: Analyzer =>
|
|||
"'s selftype "+parent.tpe.typeOfThis)
|
||||
if (settings.explaintypes.value) explainTypes(selfType, parent.tpe.typeOfThis)
|
||||
}
|
||||
if (parents exists (p => p != parent && p.tpe.symbol == psym && !psym.isError))
|
||||
if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError))
|
||||
error(parent.pos, psym+" is inherited twice")
|
||||
}
|
||||
}
|
||||
|
||||
if (!parents.isEmpty && !parents.head.tpe.isError)
|
||||
for (p <- parents) validateParentClass(p, parents.head.tpe.symbol)
|
||||
for (p <- parents) validateParentClass(p, parents.head.tpe.typeSymbol)
|
||||
}
|
||||
|
||||
def checkFinitary(classinfo: ClassInfoType) {
|
||||
val clazz = classinfo.symbol
|
||||
val clazz = classinfo.typeSymbol
|
||||
for (tparam <- clazz.typeParams) {
|
||||
if (classinfo.expansiveRefs(tparam) contains tparam) {
|
||||
error(tparam.pos, "class graph is not finitary because type parameter "+tparam.name+" is expansively recursive")
|
||||
|
@ -1108,7 +1135,7 @@ trait Typers { self: Analyzer =>
|
|||
case Apply(fn, args) =>
|
||||
val (superConstr, args1) = decompose(fn)
|
||||
val formals = fn.tpe.paramTypes
|
||||
val args2 = if (formals.isEmpty || formals.last.symbol != RepeatedParamClass) args
|
||||
val args2 = if (formals.isEmpty || formals.last.typeSymbol != RepeatedParamClass) args
|
||||
else args.take(formals.length - 1) ::: List(EmptyTree)
|
||||
if (args2.length != formals.length)
|
||||
assert(false, "mismatch " + clazz + " " + formals + " " + args2);//debug
|
||||
|
@ -1190,7 +1217,7 @@ trait Typers { self: Analyzer =>
|
|||
if (meth.isPrimaryConstructor && meth.isClassConstructor &&
|
||||
phase.id <= currentRun.typerPhase.id && !reporter.hasErrors)
|
||||
computeParamAliases(meth.owner, vparamss1, rhs1)
|
||||
if (tpt1.tpe.symbol != AllClass && !context.returnsSeen) rhs1 = checkDead(rhs1)
|
||||
if (tpt1.tpe.typeSymbol != AllClass && !context.returnsSeen) rhs1 = checkDead(rhs1)
|
||||
copy.DefDef(ddef, ddef.mods, ddef.name, tparams1, vparamss1, tpt1, rhs1) setType NoType
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1258,7 @@ trait Typers { self: Analyzer =>
|
|||
*/
|
||||
def anonymousClassRefinement(clazz: Symbol): Type = {
|
||||
val tp = refinedType(clazz.info.parents, clazz.owner)
|
||||
val thistp = tp.symbol.thisType
|
||||
val thistp = tp.typeSymbol.thisType
|
||||
for (sym <- clazz.info.decls.toList) {
|
||||
if (sym.isPublic && !sym.isClass && !sym.isConstructor)
|
||||
addMember(thistp, tp, sym)
|
||||
|
@ -1313,18 +1340,18 @@ trait Typers { self: Analyzer =>
|
|||
* @return ...
|
||||
*/
|
||||
def typedFunction(fun: Function, mode: Int, pt: Type): Tree = {
|
||||
val codeExpected = !forCLDC && !forMSIL && (pt.symbol isNonBottomSubClass CodeClass)
|
||||
val codeExpected = !forCLDC && !forMSIL && (pt.typeSymbol isNonBottomSubClass CodeClass)
|
||||
|
||||
def decompose(pt: Type): (Symbol, List[Type], Type) =
|
||||
if ((isFunctionType(pt)
|
||||
||
|
||||
pt.symbol == PartialFunctionClass &&
|
||||
pt.typeSymbol == PartialFunctionClass &&
|
||||
fun.vparams.length == 1 && fun.body.isInstanceOf[Match])
|
||||
&& // see bug901 for a reason why next conditions are neeed
|
||||
(pt.normalize.typeArgs.length - 1 == fun.vparams.length
|
||||
||
|
||||
fun.vparams.exists(_.tpt.isEmpty)))
|
||||
(pt.symbol, pt.normalize.typeArgs.init, pt.normalize.typeArgs.last)
|
||||
(pt.typeSymbol, pt.normalize.typeArgs.init, pt.normalize.typeArgs.last)
|
||||
else
|
||||
(FunctionClass(fun.vparams.length), fun.vparams map (x => NoType), WildcardType)
|
||||
|
||||
|
@ -1568,6 +1595,10 @@ trait Typers { self: Analyzer =>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
case SingleType(_, _) =>
|
||||
doTypedApply(tree, fun setType fun.tpe.widen, args, mode, pt)
|
||||
|
||||
case ErrorType =>
|
||||
setError(copy.Apply(tree, fun, args))
|
||||
/* --- begin unapply --- */
|
||||
|
@ -1634,7 +1665,7 @@ trait Typers { self: Analyzer =>
|
|||
|
||||
/* --- end unapply --- */
|
||||
case _ =>
|
||||
errorTree(tree, fun+" does not take parameters")
|
||||
errorTree(tree, fun+" of type "+fun.tpe+" does not take parameters")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1694,10 +1725,10 @@ trait Typers { self: Analyzer =>
|
|||
}
|
||||
for (name <- names) {
|
||||
if (!name.attributes.contains(AnnotationInfo(AnnotationDefaultAttr.tpe, List(), List()))) {
|
||||
error(annot.constr.pos, "attribute " + annType.symbol.fullNameString + " is missing element " + name.name)
|
||||
error(annot.constr.pos, "attribute " + annType.typeSymbol.fullNameString + " is missing element " + name.name)
|
||||
}
|
||||
}
|
||||
if (annType.symbol.hasFlag(JAVA) && settings.target.value == "jvm-1.4") {
|
||||
if (annType.typeSymbol.hasFlag(JAVA) && settings.target.value == "jvm-1.4") {
|
||||
context.warning (annot.constr.pos, "Java annotation will not be emitted in classfile unless you use the '-target:jvm-1.5' option")
|
||||
}
|
||||
if (attrError) AnnotationInfo(ErrorType, List(), List())
|
||||
|
@ -1706,6 +1737,17 @@ trait Typers { self: Analyzer =>
|
|||
}
|
||||
}
|
||||
|
||||
protected def existentialBound(sym: Symbol): Type =
|
||||
if (sym.isClass)
|
||||
parameterizedType(
|
||||
sym.typeParams, mkTypeBounds(AllClass.tpe, anonymousClassRefinement(sym)))
|
||||
else if (sym.isAbstractType)
|
||||
sym.info
|
||||
else if (sym.isTerm)
|
||||
mkTypeBounds(AllClass.tpe, intersectionType(List(sym.tpe, SingletonClass.tpe)))
|
||||
else
|
||||
throw new Error("unexpected alias type: "+sym)
|
||||
|
||||
/** 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.
|
||||
|
@ -1721,19 +1763,8 @@ trait Typers { self: Analyzer =>
|
|||
*/
|
||||
protected def existentialTransform(rawSyms: List[Symbol], tp: Type) = {
|
||||
val typeParams: List[Symbol] = rawSyms map { sym =>
|
||||
val (name, bound) =
|
||||
if (sym.isClass)
|
||||
(sym.name,
|
||||
parameterizedType(
|
||||
sym.typeParams, mkTypeBounds(AllClass.tpe, anonymousClassRefinement(sym))))
|
||||
else if (sym.isAbstractType)
|
||||
(sym.name,
|
||||
sym.info)
|
||||
else if (sym.isTerm)
|
||||
(newTypeName(sym.name+".type"),
|
||||
mkTypeBounds(AllClass.tpe, intersectionType(List(sym.tpe, SingletonClass.tpe))))
|
||||
else
|
||||
throw new Error("unexpected alias type: "+sym)
|
||||
val name = if (sym.isType) sym.name else newTypeName(sym.name+".type")
|
||||
val bound = existentialBound(sym)
|
||||
val quantified: Symbol = sym.owner.newAbstractType(sym.pos, name)
|
||||
quantified setFlag EXISTENTIAL setInfo bound.cloneInfo(quantified)
|
||||
}
|
||||
|
@ -1770,20 +1801,31 @@ trait Typers { self: Analyzer =>
|
|||
while (o != owner && o != NoSymbol && !(o hasFlag PACKAGE)) o = o.owner
|
||||
o == owner && !isVisibleParameter(sym)
|
||||
}
|
||||
var localSyms = collection.immutable.Set[Symbol]()
|
||||
var boundSyms = collection.immutable.Set[Symbol]()
|
||||
def addLocals(tp: Type) {
|
||||
def isLocal(sym: Symbol): Boolean =
|
||||
if (owner == NoSymbol) tree exists (defines(_, sym))
|
||||
else containsDef(owner, sym)
|
||||
var localSyms = collection.immutable.Set[Symbol]()
|
||||
var boundSyms = collection.immutable.Set[Symbol]()
|
||||
for (t <- tree.tpe) {
|
||||
def addIfLocal(sym: Symbol) {
|
||||
if (sym != NoSymbol &&
|
||||
!sym.isRefinementClass &&
|
||||
!(localSyms contains sym) && !(boundSyms contains sym) &&
|
||||
isLocal(sym)) {
|
||||
localSyms += sym
|
||||
addLocals(existentialBound(sym))
|
||||
}
|
||||
}
|
||||
for (t <- tp) {
|
||||
t match {
|
||||
case ExistentialType(tparams, _) => boundSyms ++= tparams
|
||||
case _ =>
|
||||
}
|
||||
val sym = t.symbol
|
||||
if (sym != NoSymbol && !(localSyms contains sym) && !(boundSyms contains sym) && isLocal(sym))
|
||||
localSyms += sym
|
||||
addIfLocal(t.termSymbol)
|
||||
addIfLocal(t.typeSymbol)
|
||||
}
|
||||
}
|
||||
addLocals(tree.tpe)
|
||||
packSymbols(localSyms.toList, tree.tpe)
|
||||
}
|
||||
|
||||
|
@ -1805,7 +1847,7 @@ trait Typers { self: Analyzer =>
|
|||
*/
|
||||
protected def typed1(tree: Tree, mode: int, pt: Type): Tree = {
|
||||
//Console.println("typed1("+tree.getClass()+","+Integer.toHexString(mode)+","+pt+")")
|
||||
def ptOrLub(tps: List[Type]) = if (isFullyDefined(pt)) pt else lub(tps)
|
||||
def ptOrLub(tps: List[Type]) = if (isFullyDefined(pt)) pt else lub(tps map (_.deconst))
|
||||
|
||||
//@M! get the type of the qualifier in a Select tree, otherwise: NoType
|
||||
def prefixType(fun: Tree): Type = fun match {
|
||||
|
@ -1954,12 +1996,12 @@ trait Typers { self: Analyzer =>
|
|||
.setOriginal(tpt1) /* .setPos(tpt1.pos) */
|
||||
.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")
|
||||
else if (tpt1.tpe.symbol.thisSym != tpt1.tpe.symbol &&
|
||||
if (tpt1.tpe.typeSymbol hasFlag ABSTRACT)
|
||||
error(tree.pos, tpt1.tpe.typeSymbol + " is abstract; cannot be instantiated")
|
||||
else if (tpt1.tpe.typeSymbol.thisSym != tpt1.tpe.typeSymbol &&
|
||||
!(tpt1.tpe <:< tpt1.tpe.typeOfThis) &&
|
||||
!phase.erasedTypes)
|
||||
error(tree.pos, tpt1.tpe.symbol +
|
||||
error(tree.pos, tpt1.tpe.typeSymbol +
|
||||
" cannot be instantiated because it does not conform to its self-type "+
|
||||
tpt1.tpe.typeOfThis)
|
||||
copy.New(tree, tpt1).setType(tpt1.tpe)
|
||||
|
@ -2022,12 +2064,14 @@ trait Typers { self: Analyzer =>
|
|||
(arg, tparam) => typedHigherKindedType(arg, parameterizedType(tparam.typeParams, AnyClass.tpe))
|
||||
}
|
||||
typedTypeApply(fun, args1)
|
||||
case SingleType(_, _) =>
|
||||
typedTypeApply(fun setType fun.tpe.widen, args)
|
||||
case PolyType(tparams, restpe) if (tparams.length != 0) =>
|
||||
if (tparams.length == args.length) {
|
||||
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)
|
||||
if (!targs.head.typeSymbol.isClass || targs.head.typeSymbol.isRefinementClass)
|
||||
error(args.head.pos, "class type required");
|
||||
Literal(Constant(targs.head)) setPos tree.pos setType ClassClass.tpe
|
||||
} else {
|
||||
|
@ -2209,10 +2253,10 @@ trait Typers { self: Analyzer =>
|
|||
if ((mode & SUPERCONSTRmode) != 0) clazz.info.parents.head
|
||||
else intersectionType(clazz.info.parents)
|
||||
else {
|
||||
val ps = clazz.info.parents filter (p => p.symbol.name == mix)
|
||||
val ps = clazz.info.parents filter (p => p.typeSymbol.name == mix)
|
||||
if (ps.isEmpty) {
|
||||
if (settings.debug.value)
|
||||
Console.println(clazz.info.parents map (_.symbol.name))//debug
|
||||
Console.println(clazz.info.parents map (_.typeSymbol.name))//debug
|
||||
error(tree.pos, mix+" does not name a parent class of "+clazz)
|
||||
ErrorType
|
||||
} else if (ps.tail.isEmpty) {
|
||||
|
@ -2261,7 +2305,7 @@ trait Typers { self: Analyzer =>
|
|||
alt == tree.symbol || alt.isTerm && (alt.tpe matches tree.symbol.tpe))))
|
||||
assert(false, "symbol "+tree.symbol+tree.symbol.locationString+" not in "+alts+" of "+qual.tpe+
|
||||
"\n members = "+qual.tpe.members+
|
||||
"\n type history = "+qual.tpe.symbol.infosString+
|
||||
"\n type history = "+qual.tpe.termSymbol.infosString+
|
||||
"\n phase = "+phase)
|
||||
}
|
||||
tree.symbol
|
||||
|
@ -2273,7 +2317,7 @@ trait Typers { self: Analyzer =>
|
|||
if (qual1 ne qual) return typed(copy.Select(tree, qual1, name), mode, pt)
|
||||
}
|
||||
if (!sym.exists) {
|
||||
if (settings.debug.value) Console.err.println("qual = "+qual+":"+qual.tpe+"\nSymbol="+qual.tpe.symbol+"\nsymbol-info = "+qual.tpe.symbol.info+"\nscope-id = "+qual.tpe.symbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+"\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner)
|
||||
if (settings.debug.value) Console.err.println("qual = "+qual+":"+qual.tpe+"\nSymbol="+qual.tpe.termSymbol+"\nsymbol-info = "+qual.tpe.termSymbol.info+"\nscope-id = "+qual.tpe.termSymbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+"\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner)
|
||||
if (!qual.tpe.widen.isErroneous) {
|
||||
error(tree.pos,
|
||||
if (name == nme.CONSTRUCTOR)
|
||||
|
@ -2462,7 +2506,7 @@ trait Typers { self: Analyzer =>
|
|||
else {
|
||||
val decls = newDecls(tree.asInstanceOf[CompoundTypeTree])
|
||||
val self = refinedType(parents1 map (_.tpe), context.enclClass.owner, decls)
|
||||
newTyper(context.make(templ, self.symbol, decls)).typedRefinement(templ.body)
|
||||
newTyper(context.make(templ, self.typeSymbol, decls)).typedRefinement(templ.body)
|
||||
tree setType self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,46 @@ final class Array[A](_length: Int) extends RandomAccessSeq[A] {
|
|||
*/
|
||||
override def filter(p: A => Boolean): Array[A] = throw new Error()
|
||||
|
||||
/** Returns an array consisting only over the first <code>n</code>
|
||||
* elements of this array, or else the whole array, if it has less
|
||||
* than <code>n</code> elements.
|
||||
*
|
||||
* @param n the number of elements to take
|
||||
* @return the new array
|
||||
*/
|
||||
override def take(n: Int): Array[A] = throw new Error()
|
||||
|
||||
/** Returns this array without its <code>n</code> first elements
|
||||
* If this array has less than <code>n</code> elements, the empty
|
||||
* array is returned.
|
||||
*
|
||||
* @param n the number of elements to drop
|
||||
* @return the new array
|
||||
*/
|
||||
override def drop(n: Int): Array[A] =throw new Error()
|
||||
|
||||
/** Returns the longest prefix of this array whose elements satisfy
|
||||
* the predicate <code>p</code>.
|
||||
*
|
||||
* @param p the test predicate.
|
||||
* @return the longest prefix of this array whose elements satisfy
|
||||
* the predicate <code>p</code>.
|
||||
*/
|
||||
override def takeWhile(p: A => Boolean): Array[A] = throw new Error()
|
||||
|
||||
/** Returns the longest suffix of this array whose first element
|
||||
* does not satisfy the predicate <code>p</code>.
|
||||
*
|
||||
* @param p the test predicate.
|
||||
* @return the longest suffix of the array whose first element
|
||||
* does not satisfy the predicate <code>p</code>.
|
||||
*/
|
||||
override def dropWhile(p: A => Boolean): Array[A] = throw new Error()
|
||||
|
||||
/** A array consisting of all elements of this array in reverse order.
|
||||
*/
|
||||
override def reverse: Array[A] = throw new Error()
|
||||
|
||||
/** Returns an array consisting of all elements of this array followed
|
||||
* by all elements of the argument iterable.
|
||||
*/
|
||||
|
@ -294,8 +334,11 @@ final class Array[A](_length: Int) extends RandomAccessSeq[A] {
|
|||
*/
|
||||
def zipWithIndex: Array[Tuple2[A,Int]] = throw new Error()
|
||||
|
||||
/** Returns an array that contains all indices of this array */
|
||||
def indices: Array[Int] = throw new Error()
|
||||
|
||||
/**
|
||||
* @return a deep string representation of this sequence.
|
||||
* @return a deep string representation of this array.
|
||||
*/
|
||||
def deepToString(): String = throw new Error()
|
||||
|
||||
|
|
|
@ -123,6 +123,29 @@ abstract class BoxedArray extends RandomAccessSeq[Any] {
|
|||
result
|
||||
}
|
||||
|
||||
/** Returns an array that contains all indices of this array */
|
||||
def indices: Array[Int] = Array.range(0, length)
|
||||
|
||||
override def slice(start: Int, end: Int): BoxedArray = throw new Error("internal: slice")
|
||||
|
||||
override def take(n: Int) = slice(0, n)
|
||||
|
||||
override def drop(n: Int) = slice(n, length)
|
||||
|
||||
override def takeWhile(p: Any => Boolean) = {
|
||||
val c = length + 1
|
||||
take((findIndexOf(!p(_)) + c) % c)
|
||||
}
|
||||
override def dropWhile(p: Any => Boolean) = {
|
||||
val c = length + 1
|
||||
drop((findIndexOf(!p(_)) + c) % c)
|
||||
}
|
||||
|
||||
/*
|
||||
/** A array consisting of all elements of this array in reverse order.
|
||||
*/
|
||||
def reverse: Array[A] = super.reverse.toArray
|
||||
*/
|
||||
final def deepToString() = deepMkString(stringPrefix + "(", ",", ")")
|
||||
|
||||
final def deepMkString(start: String, sep: String, end: String): String = {
|
||||
|
|
|
@ -59,9 +59,11 @@ final class BoxedIntArray(val value: Array[Int]) extends BoxedArray {
|
|||
}
|
||||
|
||||
final override def slice(start: Int, end: Int): BoxedArray = {
|
||||
val len = end - start
|
||||
var s = start max 0
|
||||
var e = end min value.length
|
||||
var len = e - s
|
||||
val result = new Array[Int](len)
|
||||
Array.copy(value, start, result, 0, len)
|
||||
Array.copy(value, s, result, 0, len)
|
||||
new BoxedIntArray(result)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
bug1181.scala:9: error: not a legal formal parameter
|
||||
_ => buildMap(map.update(keyList.head, valueList.head), keyList.tail, valueList.tail)
|
||||
^
|
||||
one error found
|
|
@ -0,0 +1,12 @@
|
|||
package test
|
||||
|
||||
import scala.collection.immutable.Map
|
||||
|
||||
class CompilerTest(val valueList: List[Symbol]) {
|
||||
def buildMap(map: Map[Symbol, Symbol], keyList: List[Symbol], valueList: List[Symbol]): Map[Symbol, Symbol] = {
|
||||
(keyList, valueList) match {
|
||||
case (Nil, Nil) => map
|
||||
_ => buildMap(map.update(keyList.head, valueList.head), keyList.tail, valueList.tail)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
bug961.scala:11: error: Temp.this.B does not take parameters
|
||||
bug961.scala:11: error: Temp.this.B of type object Temp.this.B does not take parameters
|
||||
B() match {
|
||||
^
|
||||
one error found
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
bug997.scala:7: error: wrong number of arguments for object Foo of type Foo.type
|
||||
bug997.scala:7: error: wrong number of arguments for object Foo of type object Foo
|
||||
"x" match { case Foo(a) => Console.println(a) }
|
||||
^
|
||||
bug997.scala:7: error: not found: value a
|
||||
"x" match { case Foo(a) => Console.println(a) }
|
||||
^
|
||||
bug997.scala:13: error: wrong number of arguments for object Foo of type Foo.type
|
||||
bug997.scala:13: error: wrong number of arguments for object Foo of type object Foo
|
||||
"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
|
||||
^
|
||||
bug997.scala:13: error: not found: value a
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
object Test extends Application {
|
||||
|
||||
trait SpecialException {}
|
||||
|
||||
try {
|
||||
throw new Exception
|
||||
} catch {
|
||||
case e : SpecialException => {
|
||||
println("matched SpecialException: "+e)
|
||||
assume(e.isInstanceOf[SpecialException])
|
||||
}
|
||||
case e : Exception => {
|
||||
assume(e.isInstanceOf[Exception])
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Array(1, 2)
|
||||
Array(3, 4)
|
|
@ -0,0 +1,7 @@
|
|||
object Test extends Application {
|
||||
val v1: Array[Array[Int]] = Array(Array(1, 2), Array(3, 4))
|
||||
def f[T](w: Array[Array[T]]) {
|
||||
for (val r <- w) println(r.toString)
|
||||
}
|
||||
f(v1)
|
||||
}
|
Loading…
Reference in New Issue