diff options
author | Martin Odersky <odersky@gmail.com> | 2006-04-04 12:18:15 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-04-04 12:18:15 +0000 |
commit | ac8b46abda17de619beb2b27dfe9d820c5e189cf (patch) | |
tree | b908b07eb95280352dea767dd0fd8ac9890d8472 /src | |
parent | 486042e89abaa69b82f2d602d342f7b032ce7047 (diff) | |
download | scala-ac8b46abda17de619beb2b27dfe9d820c5e189cf.tar.gz scala-ac8b46abda17de619beb2b27dfe9d820c5e189cf.tar.bz2 scala-ac8b46abda17de619beb2b27dfe9d820c5e189cf.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 14 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 15 |
3 files changed, 22 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 2e805dd5e3..5ec350c35f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1586,7 +1586,8 @@ trait Types requires SymbolTable { if (constr1.inst != NoType) constr1.inst <:< tp2 else { constr1.hibounds = tp2 :: constr1.hibounds; true } case Pair(_, RefinedType(parents2, ref2)) => - (parents2 forall tp1.<:<) && (ref2.toList forall tp1.specializes) + (parents2 forall tp1.<:<) && (ref2.toList forall tp1.specializes) && + (!parents2.exists(.symbol.isAbstractType) || tp1.symbol != AllRefClass) case Pair(RefinedType(parents1, ref1), _) => parents1 exists (.<:<(tp2)) /* todo: replace following with diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 11d2aa2a3e..f24d2a21a4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -263,7 +263,7 @@ trait Contexts requires Analyzer { private def collectImplicits(syms: List[Symbol], pre: Type): List[ImplicitInfo] = for (val sym <- syms; sym.hasFlag(IMPLICIT) && isAccessible(sym, pre, false)) - yield ImplicitInfo(sym.name, pre.memberType(sym), sym); + yield new ImplicitInfo(sym.name, pre, sym); private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = { val pre = imp.qual.tpe; @@ -274,7 +274,7 @@ trait Contexts requires Analyzer { var impls = collect(sels1) filter (info => info.name != from); if (to != nme.WILDCARD) { val sym = imp.importedSymbol(to); - if (sym.hasFlag(IMPLICIT)) impls = ImplicitInfo(to, pre.memberType(sym), sym) :: impls; + if (sym.hasFlag(IMPLICIT)) impls = new ImplicitInfo(to, pre, sym) :: impls; } impls } @@ -338,9 +338,15 @@ trait Contexts requires Analyzer { override def toString() = tree.toString(); } - case class ImplicitInfo(val name: Name, val tpe: Type, val sym: Symbol); + class ImplicitInfo(val name: Name, pre: Type, val sym: Symbol) { + private var tpeCache: Type = null; + def tpe: Type = { + if (tpeCache == null) tpeCache = pre.memberType(sym) + tpeCache + } + } - val NoImplicitInfo = ImplicitInfo(null, null, null) + val NoImplicitInfo = new ImplicitInfo(null, null, null) case class ImportType(expr: Tree) extends Type; } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 8637ff3a60..05dd710154 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -485,14 +485,17 @@ trait Typers requires Analyzer { // adapt(tree, mode, pt) // } - def adaptToMember(qual: Tree, name: Name, tp: Type): Tree = + def adaptToMember(qual: Tree, name: Name, tp: Type): Tree = { + val qtpe = qual.tpe.widen; if (qual.isTerm && (qual.symbol == null || qual.symbol.isValue) && - !phase.erasedTypes && !qual.tpe.widen.isError && !tp.isError) { - val coercion = inferView(qual.pos, qual.tpe.widen, name, tp, true) + !phase.erasedTypes && !qtpe.isError && !tp.isError && + qtpe.symbol != AllRefClass && qtpe.symbol != AllClass && qtpe != WildcardType) { + val coercion = inferView(qual.pos, qtpe, name, tp, true) if (coercion != EmptyTree) typedQualifier(atPos(qual.pos)(Apply(coercion, List(qual)))) else qual } else qual + } def adaptToName(qual: Tree, name: Name) = if (qual.tpe.nonLocalMember(name) != NoSymbol) qual @@ -911,7 +914,9 @@ trait Typers requires Analyzer { val vparamSyms = List.map2(fun.vparams, argpts) { (vparam, argpt) => if (vparam.tpt.isEmpty) vparam.tpt.tpe = - if (argpt == NoType) { error(vparam.pos, "missing parameter type"); ErrorType } + if (argpt == NoType || argpt == WildcardType) { + error(vparam.pos, "missing parameter type"); ErrorType + } else argpt namer.enterSym(vparam) vparam.symbol @@ -1782,7 +1787,7 @@ trait Typers requires Analyzer { def implicitsOfClass(clazz: Symbol): List[ImplicitInfo] = ( clazz.initialize.linkedModule.moduleClass.info.members.toList.filter(.hasFlag(IMPLICIT)) map - (sym => ImplicitInfo(sym.name, clazz.linkedModule.tpe.memberType(sym), sym)) + (sym => new ImplicitInfo(sym.name, clazz.linkedModule.tpe, sym)) ) var tree = searchImplicit(context.implicitss, true) |